Skip to content

Commit

Permalink
Merge pull request #16 from softwareforgood/test-using-reusable-workflow
Browse files Browse the repository at this point in the history
Add tests for reusable workflows
  • Loading branch information
wwahammy authored Jun 4, 2024
2 parents 99a05e6 + 7214ffe commit 016fa64
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/reusable-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# LICENSE: LGPL-3.0-or-later
name: "Reusable workflow that tests whether the check artifact works when called from another workflow"

on:
workflow_call:
inputs:
name:
type: string
required: true
description: the artifact name to be checked for

jobs:
sets_false_on_missing:
name: Sets false when no artifact for the name exists
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
name: 'missing-dependency'
id: "existence-check"
- name: Fail when expected output isn't set
run: |
exit 1
if: ${{ steps.existence-check.outputs.exists != 'false' }}
sets_true_when_there:
name: Sets true when artifact for the name exists
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./
with:
name: ${{inputs.name}}
id: "existence-check"
- name: Fail when expected output isn't set
run: |
exit 1
if: ${{ steps.existence-check.outputs.exists != 'true' }}

8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
run: |
exit 1
if: ${{ steps.existence-check.outputs.exists != 'true' }}

test_via_reusable_workflow:
name: "Test checking when using a reusable workflow"
needs: [sets_true_when_there]
uses: './.github/workflows/reusable-workflow.yml'
with:
name: 'artifact-that-exists'




Expand Down

0 comments on commit 016fa64

Please sign in to comment.