Skip to content

fixup

fixup #2

Workflow file for this run

name: API Test
on:
push:
branches:
- feat/run-api-tests-in-ci
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
deno task run ${{ vars.API_TEST_WORKSPACE_ID }} ${{ secrets.API_TEST_EMAIL }} ${{ secrets.API_TEST_PASSWORD }} ${{ matrix.tests }}
on-failure:
runs-on: ubuntu-latest
needs: api-test
if: ${{ always() && 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 }}