Merge pull request #99 from opensafely-core/iaindillingham/update-dat… #173
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: [push] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
STATA_LICENSE: ${{ secrets.STATA_LICENSE }} | |
jobs: | |
test-action: | |
runs-on: ubuntu-20.04 | |
name: Test action | |
env: | |
HONEYCOMB_API_KEY: dummy-key | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Checkout gh-testing-research | |
uses: actions/checkout@v2 | |
with: | |
repository: opensafely/gh-testing-research | |
path: gh-testing-research | |
- name: Run action | |
uses: ./ | |
with: | |
directory: gh-testing-research | |
- name: Assert extracted stats file created | |
run: | | |
if test -f gh-testing-research/metadata/extracted_stats.json; then | |
echo "extracted_stats.json file exists" | |
else | |
echo "Action should have created extracted_stats.json file" | |
exit 1 | |
fi | |
test-no-honeycomb-api-key: | |
runs-on: ubuntu-20.04 | |
name: Test no Honeycomb API key | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Checkout gh-testing-research | |
uses: actions/checkout@v2 | |
with: | |
repository: opensafely/gh-testing-research | |
path: gh-testing-research-no-honeycomb-key | |
- name: Run action | |
uses: ./ | |
with: | |
directory: gh-testing-research-no-honeycomb-key | |
- name: Assert extracted stats file not created | |
run: | | |
if test -f gh-testing-research-no-honeycomb-key/metadata/extracted_stats.json; then | |
echo "Action should have skipped running extract-stats" | |
exit 1 | |
fi | |
test-honeycomb-api-key-empty: | |
runs-on: ubuntu-20.04 | |
name: Test Honeycomb API key empty | |
env: | |
HONEYCOMB_API_KEY: | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Checkout gh-testing-research | |
uses: actions/checkout@v2 | |
with: | |
repository: opensafely/gh-testing-research | |
path: gh-testing-research-no-honeycomb-key | |
- name: Run action | |
uses: ./ | |
with: | |
directory: gh-testing-research-no-honeycomb-key | |
- name: Assert extracted stats file not created | |
run: | | |
if test -f gh-testing-research-no-honeycomb-key/metadata/extracted_stats.json; then | |
echo "Action should have skipped running extract-stats" | |
exit 1 | |
fi | |
lint-action: | |
runs-on: ubuntu-20.04 | |
name: Lint action | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Lint | |
run: make lint | |
test-codelists: | |
runs-on: ubuntu-20.04 | |
name: Test report codelists need updating | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Test project with failing codelists check | |
uses: ./ | |
id: codelists | |
continue-on-error: true | |
with: | |
directory: tests/codelists | |
- name: Assert codelists check failed | |
run: | | |
if test "${{ steps.codelists.outcome }}" != "failure"; then | |
echo "Action should have failed with codelists error" | |
exit 1 | |
fi | |
test-check: | |
runs-on: ubuntu-20.04 | |
name: Test dataset check failure | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Test project with failing codelists check | |
uses: ./ | |
id: dataset | |
continue-on-error: true | |
with: | |
directory: tests/dataset | |
users: '@nobody' | |
- name: Assert check failed and created issue | |
env: | |
ISSUE_URL: ${{ steps.dataset.outputs.issue }} | |
run: | | |
fail() { | |
echo "$@" | |
exit 1 | |
} | |
cleanup() { | |
gh issue close "$ISSUE_URL" || true | |
} | |
trap cleanup EXIT | |
test "${{ steps.dataset.outcome }}" = "failure" || fail "Action should have failed with dataset error" | |
test -n "$ISSUE_URL" || fail "No issue url output from dataset step" | |
gh issue view "$ISSUE_URL" || fail "Could not view issue at $ISSUE_URL" | |