Skip to content

Commit

Permalink
Clean and spruce up the integration tests a bit
Browse files Browse the repository at this point in the history
- Use test-specific step ids
- Remove unused input parameters
- Provide clear output on what passed or failed, including
  a step summary for each passed test.
  • Loading branch information
mjpieters committed Apr 4, 2023
1 parent 8d76c9a commit 806be26
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

jobs:
test-return:
name: 'Integration test: return'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -18,26 +19,34 @@ jobs:
result-encoding: string
input-value: output
- run: |
if [[ "${{steps.output-set.outputs.result}}" != "output" ]]; then
echo "- Validating output is produced"
expected="output"
if [[ "${{steps.output-set.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected '$expected', got ${{steps.output-set.outputs.result}}"
exit 1
fi
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
test-relative-require:
name: 'Integration test: relative-path require'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: output-set
- id: relative-require
uses: ./
with:
script: return require('./package.json').name
result-encoding: string
input-value: output
- run: |
if [[ "${{steps.output-set.outputs.result}}" != "github-script" ]]; then
echo "- Validating relative require output"
if [[ "${{steps.relative-require.outputs.result}}" != "github-script" ]]; then
echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}"
exit 1
fi
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
test-npm-require:
name: 'Integration test: npm package require'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -47,13 +56,16 @@ jobs:
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
restore-keys: ${{runner.os}}-npm-
- run: npm ci
- id: output-set
- id: npm-require
uses: ./
with:
script: return require('@actions/core/package.json').name
result-encoding: string
input-value: output
- run: |
if [[ "${{steps.output-set.outputs.result}}" != "@actions/core" ]]; then
echo "- Validating npm require output"
expected="@actions/core"
if [[ "${{steps.npm-require.outputs.result}}" != "$expected" ]]; then
echo $'::error::\u274C' "Expected '$expected', got ${{steps.npm-require.outputs.result}}"
exit 1
fi
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY

0 comments on commit 806be26

Please sign in to comment.