Skip to content

Commit 1b3f3a0

Browse files
authored
feat(ci): optional args input to run bashunit after install (#697)
1 parent 38fd814 commit 1b3f3a0

4 files changed

Lines changed: 73 additions & 6 deletions

File tree

.github/workflows/test-action.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,39 @@ jobs:
4646
test -n "$BASHUNIT_INSTALLED_VERSION"
4747
# add-to-path defaults to true, so "bashunit" resolves on PATH
4848
bashunit --version
49+
50+
run-via-args:
51+
name: "Run via args input"
52+
runs-on: ubuntu-latest
53+
timeout-minutes: 10
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Write a passing and a failing sample test
58+
run: |
59+
mkdir -p sample_tests
60+
printf 'function test_passes() { assert_same "1" "1"; }\n' > sample_tests/pass_test.sh
61+
printf 'function test_fails() { assert_same "1" "2"; }\n' > sample_tests/fail_test.sh
62+
63+
- name: Run only the passing test via args (step should pass)
64+
uses: ./
65+
with:
66+
directory: vendor/bashunit
67+
args: sample_tests/pass_test.sh
68+
69+
- name: Run the failing test via args (expected to fail the step)
70+
id: failing
71+
continue-on-error: true
72+
uses: ./
73+
with:
74+
directory: vendor/bashunit
75+
add-to-path: 'false'
76+
args: sample_tests/fail_test.sh
77+
78+
- name: Assert the failing run actually executed and failed
79+
env:
80+
OUTCOME: ${{ steps.failing.outcome }}
81+
run: |
82+
set -euo pipefail
83+
# If args were ignored (install-only), the step would have succeeded.
84+
test "$OUTCOME" = "failure"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Added
6+
- GitHub Action `args` input: when set, runs `bashunit <args>` after installing, so a workflow can install and run the suite in a single step
7+
58
## [0.38.0](https://github.com/TypedDevs/bashunit/compare/0.37.0...0.38.0) - 2026-06-07
69

710
### Added

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
description: 'Verify the downloaded binary against the release sha256 checksum asset.'
2424
required: false
2525
default: 'true'
26+
args:
27+
description: 'If set, run "bashunit <args>" after installing (e.g. "tests/ --strict"). Empty = install only.'
28+
required: false
29+
default: ''
2630

2731
outputs:
2832
path:
@@ -42,6 +46,7 @@ runs:
4246
BASHUNIT_DIRECTORY: ${{ inputs.directory }}
4347
BASHUNIT_ADD_TO_PATH: ${{ inputs.add-to-path }}
4448
BASHUNIT_VERIFY_CHECKSUM: ${{ inputs.verify-checksum }}
49+
BASHUNIT_ARGS: ${{ inputs.args }}
4550
BASHUNIT_ACTION_PATH: ${{ github.action_path }}
4651
run: |
4752
set -euo pipefail
@@ -62,3 +67,10 @@ runs:
6267
if [ "$BASHUNIT_ADD_TO_PATH" = "true" ]; then
6368
echo "$target_dir" >> "$GITHUB_PATH"
6469
fi
70+
71+
# Optionally run the suite. Word-splitting of $BASHUNIT_ARGS is intentional
72+
# so callers can pass multiple CLI arguments as a single string.
73+
if [ -n "$BASHUNIT_ARGS" ]; then
74+
# shellcheck disable=SC2086
75+
"$target_dir/bashunit" $BASHUNIT_ARGS
76+
fi

docs/installation.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,21 @@ jobs:
247247
- run: bashunit tests
248248
```
249249

250-
**Inputs:** `version` (default `latest`), `directory` (default `lib`), `add-to-path` (default `true`), `verify-checksum` (default `true`).
251-
**Outputs:** `path` (binary path relative to the workspace), `version` (installed version).
252-
253-
`verify-checksum` validates the downloaded binary against the release `checksum`
254-
asset (sha256) and fails the install on any mismatch. Set it to `false` only when
255-
pinning a release published before checksum assets existed.
250+
```yaml-vue [install + run]
251+
# .github/workflows/bashunit-tests.yml
252+
name: Tests
253+
on: [pull_request, push]
254+
jobs:
255+
tests:
256+
runs-on: ubuntu-latest
257+
steps:
258+
- uses: actions/checkout@v4
259+
# Install and run the suite in a single step via the `args` input.
260+
- uses: TypedDevs/bashunit@<commit-sha> # {{ pkg.version }}
261+
with:
262+
version: '{{ pkg.version }}'
263+
args: tests/ --strict
264+
```
256265

257266
```yaml [via install.sh]
258267
# .github/workflows/bashunit-tests.yml
@@ -283,6 +292,13 @@ jobs:
283292
```
284293
:::
285294
295+
**Inputs:** `version` (default `latest`), `directory` (default `lib`), `add-to-path` (default `true`), `verify-checksum` (default `true`), `args` (default empty — when set, runs `bashunit <args>` after installing).
296+
**Outputs:** `path` (binary path relative to the workspace), `version` (installed version).
297+
298+
`verify-checksum` validates the downloaded binary against the release `checksum`
299+
asset (sha256) and fails the install on any mismatch. Set it to `false` only when
300+
pinning a release published before checksum assets existed.
301+
286302
::: tip
287303
See bashunit's own pipeline for a real example: https://github.com/TypedDevs/bashunit/blob/main/.github/workflows/tests.yml
288304
:::

0 commit comments

Comments
 (0)