API Test #16
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: API Test | |
on: | |
workflow_call: | |
inputs: | |
environment: | |
type: string | |
required: true | |
description: "where to test" | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
required: true | |
description: "where to test" | |
default: "tools" | |
options: | |
- tools | |
- production | |
jobs: | |
define-test-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
tests: ${{ steps.tests.outputs.tests }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: tests | |
working-directory: bin/si-api-test/tests | |
run: | | |
# Find .ts files, remove ./ prefix, and format as JSON array | |
files=$(find "." -mindepth 1 -maxdepth 1 -type f -name "*.ts" | sed -r "s/\.\/(.*)\.ts/\1/" | jq -R -s 'split("\n") | map(select(length > 0))') | |
test_output=$(echo "$files" | jq -c '.') | |
echo "tests=$test_output" >> "$GITHUB_OUTPUT" | |
echo "$test_output" | |
api-test: | |
name: API Test SDF | |
environment: ${{ inputs.environment }} | |
runs-on: ubuntu-latest | |
needs: define-test-matrix | |
strategy: | |
# don't fail the entire matrix on failure | |
fail-fast: false | |
matrix: | |
# run copies of the current job in parallel split by test dir | |
# TODO: we really should build once and set it as an | |
# artifact so we aren't rebuilding for each of these | |
tests: ${{ fromJSON(needs.define-test-matrix.outputs.tests) }} | |
env: | |
SDF_API_URL: ${{ vars.SDF_API_URL }} | |
AUTH_API_URL: ${{ vars.AUTH_API_URL }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: v1.x | |
- name: Run the deno exec | |
run: | | |
cd bin/si-api-test | |
echo ${{ github.ref }} | |
deno task run \ | |
--workspaceId ${{ vars.API_TEST_WORKSPACE_ID }} \ | |
--userId ${{ secrets.API_TEST_EMAIL }} \ | |
--password ${{ secrets.API_TEST_PASSWORD }} \ | |
--tests ${{ matrix.tests }} | |
on-failure: | |
runs-on: ubuntu-latest | |
needs: api-test | |
if: ${{ always() && github.ref == 'refs/heads/main' && contains(needs.*.result, 'failure') }} | |
steps: | |
- run: | | |
curl -X POST \ | |
-H 'Content-type: application/json' \ | |
--data "{\"text\": \":si: Failed API Tests for ${{ inputs.environment }}: <https://github.com/systeminit/si/actions/runs/$GITHUB_RUN_ID|:test_tube: Link>\"}" ${{ secrets.SLACK_WEBHOOK_URL }} |