mirror of
https://github.com/actions/github-script.git
synced 2025-12-08 16:16:21 +00:00
Clean and spruce up the integration tests a bit
- 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.
This commit is contained in:
26
.github/workflows/integration.yml
vendored
26
.github/workflows/integration.yml
vendored
@@ -8,6 +8,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-return:
|
test-return:
|
||||||
|
name: 'Integration test: return'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -18,26 +19,34 @@ jobs:
|
|||||||
result-encoding: string
|
result-encoding: string
|
||||||
input-value: output
|
input-value: output
|
||||||
- run: |
|
- 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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
test-relative-require:
|
test-relative-require:
|
||||||
|
name: 'Integration test: relative-path require'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- id: output-set
|
- id: relative-require
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
script: return require('./package.json').name
|
script: return require('./package.json').name
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
input-value: output
|
|
||||||
- run: |
|
- 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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
test-npm-require:
|
test-npm-require:
|
||||||
|
name: 'Integration test: npm package require'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -47,13 +56,16 @@ jobs:
|
|||||||
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
key: ${{runner.os}}-npm-${{hashFiles('**/package-lock.json')}}
|
||||||
restore-keys: ${{runner.os}}-npm-
|
restore-keys: ${{runner.os}}-npm-
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- id: output-set
|
- id: npm-require
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
script: return require('@actions/core/package.json').name
|
script: return require('@actions/core/package.json').name
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
input-value: output
|
|
||||||
- run: |
|
- 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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
Reference in New Issue
Block a user