Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions actions/github/should-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ inputs:
default: ${{ github.base_ref }}
checkout-repo:
description: >
Boolean flag to control whether the action should check out the repo
default: true
type: boolean
Whether this action should perform its own full (fetch-depth: 0) checkout.
Defaults to "false"; the caller is expected to have already checked out
the repository with sufficient history for the diff. Set to "true" to have
this action perform its own checkout (this will clean the working tree and
remove any untracked files produced by earlier job steps).
default: "false"
config:
description: >
YAML paths configuration. Can be a list of paths, or an object with keys like 'paths' and 'push'.
Expand All @@ -38,7 +41,7 @@ runs:
using: composite
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
if: inputs.checkout-repo
if: inputs.checkout-repo == 'true'
with:
fetch-depth: 0
- uses: envoyproxy/toolshed/actions/bson@7f2aff965c314c8a80a09a48f61552b1a3337af1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
uses: ./actions/github/should-run
id: should-run
with:
checkout-repo: "false"
config: |
paths:
- some/path

before:
- shell: bash
run: |
echo "marker-content" > .should-run-untracked-marker

after:
- shell: bash
run: |
if [[ ! -f ".should-run-untracked-marker" ]]; then
echo "fail:Untracked marker file was removed — checkout ran despite checkout-repo: false" >> "$TEST_OUTPUT"
else
echo "success:Untracked marker file preserved — no checkout occurred with checkout-repo: false" >> "$TEST_OUTPUT"
fi
rm -f .should-run-untracked-marker
21 changes: 21 additions & 0 deletions actions/github/should-run/tests/default-does-not-checkout.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uses: ./actions/github/should-run
id: should-run
with:
config: |
paths:
- some/path

before:
- shell: bash
run: |
echo "marker-content" > .should-run-default-marker

after:
- shell: bash
run: |
if [[ ! -f ".should-run-default-marker" ]]; then
echo "fail:Untracked marker file was removed — checkout ran with default checkout-repo" >> "$TEST_OUTPUT"
else
echo "success:Untracked marker file preserved — default checkout-repo does not checkout" >> "$TEST_OUTPUT"
fi
rm -f .should-run-default-marker
29 changes: 29 additions & 0 deletions actions/github/should-run/tests/paths-match.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
uses: ./actions/github/should-run
id: should-run
with:
checkout-repo: "false"
config: |
paths:
- tmp-should-run-test/**

before:
- shell: bash
run: |
mkdir -p tmp-should-run-test
echo "test" > tmp-should-run-test/file.txt
git add tmp-should-run-test/file.txt
git -c user.name="Test" -c user.email="test@test.com" commit -m "tmp: add test file for should-run paths test"

after:
- shell: bash
run: |
RUN_OUTPUT='${{ steps.should-run.outputs.run }}'
if [[ "$RUN_OUTPUT" != "true" ]]; then
echo "fail:Expected run=true for matching path, got '$RUN_OUTPUT'" >> "$TEST_OUTPUT"
else
echo "success:run=true for matching path tmp-should-run-test/**" >> "$TEST_OUTPUT"
fi
# Clean up the temporary commit and file
git reset HEAD~1 --soft
git restore --staged tmp-should-run-test/file.txt || true
rm -rf tmp-should-run-test