Skip to content

Job mode support

Job mode support #41

Workflow file for this run

# 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:
# --- Job mode: composite action with container (multi-step) ---
build-job-mode-image:
name: Build image for job mode test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
run: echo "tags=ghcr.io/${{ github.repository }}:test-${{ github.sha }}" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
job-mode:
name: Job mode (multi-step)
runs-on: ubuntu-latest
needs: build-job-mode-image
container:
image: ghcr.io/${{ github.repository }}:test-${{ github.sha }}
steps:
- uses: actions/checkout@v6
- uses: ./
with:
files: test/sample.lua
args: -q
custom_script: test/validate.lua
custom_args: .
# --- Execution modes (host mode, 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 .
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=false \
-e INPUT_CUSTOM_SCRIPT=test/validate.lua \
-e INPUT_CUSTOM_ARGS=. \
luacheck
[ $? -ne 0 ]
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
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
[ $? -ne 0 ]
# --- 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 ]