Create .gitattributes #59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Self-test: validates input combinations by building and running the container locally. | |
| # For usage examples (using the published action/image), see the README. | |
| name: Luacheck | |
| on: [push, pull_request] | |
| jobs: | |
| # Root action (matches consumer usage); job_summary enabled for this test. | |
| docker-action-root: | |
| name: Action (root action.yml) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Run luacheck | |
| uses: ./ | |
| with: | |
| files: test/sample.lua | |
| args: -q | |
| custom_script: test/validate.lua | |
| custom_args: . | |
| job_summary: true | |
| # --- Execution modes (docker build + run, one-shot) --- | |
| luacheck-only: | |
| name: Luacheck only | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| luacheck | |
| script-only: | |
| name: Custom script only | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=false \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=. \ | |
| luacheck | |
| both-pass: | |
| name: Luacheck and custom script (both pass) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=. \ | |
| luacheck | |
| both-disabled: | |
| name: Both disabled (no-op) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=false \ | |
| luacheck | |
| # --- Failure modes (expect container to fail; job passes when container fails) --- | |
| luacheck-fails: | |
| name: Luacheck fails (expect fail) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| set +e | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/bad.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| luacheck | |
| [ $? -ne 0 ] | |
| script-fails: | |
| name: Custom script fails (expect fail) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| set +e | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=false \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=--fail \ | |
| luacheck | |
| [ $? -ne 0 ] | |
| fail_fast-luacheck-fails: | |
| name: fail_fast=true, luacheck fails (script never runs) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| set +e | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/bad.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| -e INPUT_FAIL_FAST=true \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=. \ | |
| luacheck | |
| [ $? -ne 0 ] | |
| fail_fast-script-fails: | |
| name: fail_fast=true, script fails | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| set +e | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| -e INPUT_FAIL_FAST=true \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=--fail \ | |
| luacheck | |
| [ $? -ne 0 ] | |
| run-both-luacheck-fails: | |
| name: fail_fast=false, both run, luacheck fails | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| # Summary file must live under the workspace mount (not mktemp under /tmp) so every | |
| # Docker host can write reliably; a separate bind for /tmp paths is brittle. | |
| SUMMARY_PATH="$PWD/.ci-step-summary.md" | |
| rm -f "$SUMMARY_PATH" | |
| touch "$SUMMARY_PATH" | |
| set +e | |
| out=$(docker run --rm \ | |
| -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e GITHUB_STEP_SUMMARY=/workspace/.ci-step-summary.md \ | |
| -e INPUT_FILES=test/bad.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| -e INPUT_FAIL_FAST=false \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=. \ | |
| -e INPUT_JOB_SUMMARY=true \ | |
| luacheck 2>&1) | |
| code=$? | |
| printf '%s\n' "$out" | |
| [ "$code" -ne 0 ] | |
| echo "$out" | grep -q 'Validation passed' # script must run after luacheck failure | |
| [ -s "$SUMMARY_PATH" ] | |
| grep -q '### Checks' "$SUMMARY_PATH" | |
| grep -F '**Luacheck** - **fail**' "$SUMMARY_PATH" | |
| grep -q '<pre>' "$SUMMARY_PATH" # luacheck output on failure | |
| grep -F '**validate.lua** - **pass**' "$SUMMARY_PATH" | |
| rm -f "$SUMMARY_PATH" | |
| run-both-script-fails: | |
| name: fail_fast=false, both run, script fails | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| set +e | |
| out=$(docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=true \ | |
| -e INPUT_FAIL_FAST=false \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e INPUT_CUSTOM_ARGS=--fail \ | |
| luacheck 2>&1) | |
| code=$? | |
| printf '%s\n' "$out" | |
| [ "$code" -ne 0 ] | |
| echo "$out" | grep -q 'Running luacheck' | |
| echo "$out" | grep -q 'Validation failed' | |
| # --- Input variations --- | |
| config-url: | |
| name: Config from URL | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_CONFIG="https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/test/luacheckrc.minimal" \ | |
| luacheck | |
| args-quiet: | |
| name: Luacheck args (-q) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_ARGS=-q \ | |
| luacheck | |
| script-from-url: | |
| name: Custom script from URL | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=false \ | |
| -e INPUT_CUSTOM_SCRIPT="https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/test/validate.lua" \ | |
| -e INPUT_CUSTOM_ARGS=. \ | |
| luacheck | |
| script-args: | |
| name: Custom script with multiple args | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=false \ | |
| -e INPUT_CUSTOM_SCRIPT=test/validate.lua \ | |
| -e 'INPUT_CUSTOM_ARGS=--echo foo bar' \ | |
| luacheck | |
| script-writes-repo: | |
| name: Script modifies repo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_RUN_LUACHECK=false \ | |
| -e INPUT_CUSTOM_SCRIPT=test/write.lua \ | |
| luacheck | |
| - name: Verify script wrote file | |
| run: test -f test/.written-by-script | |
| path-subdir: | |
| name: Path subdirectory | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_PATH=test \ | |
| -e INPUT_FILES=sample.lua \ | |
| luacheck | |
| files-specific: | |
| name: Specific file | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/sample.lua \ | |
| -e INPUT_PATH=. \ | |
| luacheck | |
| annotate-warning: | |
| name: Annotate warnings | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build and run | |
| run: | | |
| docker build -t luacheck . | |
| set +e | |
| docker run --rm -v "$PWD:/workspace" \ | |
| -e GITHUB_WORKSPACE=/workspace \ | |
| -e INPUT_FILES=test/bad.lua \ | |
| -e INPUT_PATH=. \ | |
| -e INPUT_ANNOTATE=warning \ | |
| luacheck | |
| [ $? -ne 0 ] |