Skip to content

Commit

Permalink
feat(run): args: false will install+cache but not run
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinKennedy committed Jan 13, 2025
1 parent b666182 commit 1204822
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
version: ^0.17
token: ${{ secrets.GITHUB_TOKEN }}
args: --check ./test
args: --check ./test/sample.lua
smoketest_latest_version_provided:
runs-on: ubuntu-latest
steps:
Expand All @@ -44,4 +44,23 @@ jobs:
with:
version: latest
token: ${{ secrets.GITHUB_TOKEN }}
args: --check ./test
args: --check ./test/sample.lua
# only install / cache the StyLua install, don't run it
smoketest_args_false:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Copy Test File
run: |
cp ./test/needs_spaces.lua{,.copy}
- uses: ./
with:
version: latest
token: ${{ secrets.GITHUB_TOKEN }}
args: false

- name: Confirm test file was not changed
run: |
cmp ./test/needs_spaces.lua{,.copy}
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ Installs the StyLua binary (from GitHub releases), and caches it. Any StyLua com
args: --check .
```
### Advanced Usage - Skip Running StyLua
This action can be summarized as 2 main steps
1. Get An Installation Of [StyLua](https://github.com/JohnnyMorganz/StyLua)
1a. From the cache
1b. If no cache, install + cache it
2. Run `stylua` with the user-provided `args`

If you would like to keep step 1 but skip step 2 because you want more manual
control, use `args: false`.

```yaml
- uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes
# This disables running `stylua`
args: false
```
### Parameters
#### `token` (Required)
Expand Down
10 changes: 7 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ async function run(): Promise<void> {
const args = core.getInput('args')
core.debug(`Running stylua with arguments: ${args}`)

await exec(`stylua ${args}`)
if (args !== 'false') {
await exec(`stylua ${args}`)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
core.setFailed(error.message)
Expand Down
1 change: 1 addition & 0 deletions test/needs_spaces.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local x=1

0 comments on commit 1204822

Please sign in to comment.