diff --git a/testdata/example-if-cancel/.forgejo/workflows/test.yml b/testdata/example-if-cancel/.forgejo/workflows/test.yml new file mode 100644 index 0000000..6ae5dbd --- /dev/null +++ b/testdata/example-if-cancel/.forgejo/workflows/test.yml @@ -0,0 +1,17 @@ +# +# As of Forgejo v1.20 running this example would require using the web +# endpoints because there is no API to do the same. +# +# It was manually tested to **not work** with Forgejo v1.20 & runner 2.5.0 +# +on: [push] + +jobs: + test: + runs-on: docker + steps: + + - run: sleep infinity + + - if: cancelled() + run: echo IF TEST CANCELLED diff --git a/testdata/example-if-fail/.forgejo/workflows/test.yml b/testdata/example-if-fail/.forgejo/workflows/test.yml new file mode 100644 index 0000000..4c0e5af --- /dev/null +++ b/testdata/example-if-fail/.forgejo/workflows/test.yml @@ -0,0 +1,30 @@ +on: [push] + +jobs: + test: + runs-on: docker + steps: + + - run: false + - if: failure() + run: echo IF TEST FAILURE + - if: always() + run: echo IF TEST ALWAYS + + # + # This is documented in GitHub Actions and does not work in Forgejo Actions + # as of 3.0.0. + # + # If you have a chain of dependent jobs, failure() returns true if any ancestor job fails. + # + # first: + # runs-on: docker + # steps: + # - run: false + + # second: + # runs-on: docker + # needs: [first] + # steps: + # - if: failure() + # run: echo IF TEST FAIL DEPENDS diff --git a/testdata/example-if-fail/expected-to-fail.sh b/testdata/example-if-fail/expected-to-fail.sh new file mode 100755 index 0000000..c4485df --- /dev/null +++ b/testdata/example-if-fail/expected-to-fail.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -ex +grep --quiet 'IF TEST FAILURE' $FORGEJO_RUNNER_LOGS +grep --quiet 'IF TEST ALWAYS' $FORGEJO_RUNNER_LOGS diff --git a/testdata/example-if/.forgejo/workflows/test.yml b/testdata/example-if/.forgejo/workflows/test.yml new file mode 100644 index 0000000..cc9401c --- /dev/null +++ b/testdata/example-if/.forgejo/workflows/test.yml @@ -0,0 +1,17 @@ +on: [push] + +jobs: + basic: + runs-on: docker + steps: + + - name: if true + if: true + id: if_true + run: echo 'check=good' >> $GITHUB_OUTPUT + - name: verify if true was run + run: test ${{ steps.if_true.outputs.check }} = good + + - name: if false + if: false + run: false