-
Notifications
You must be signed in to change notification settings - Fork 285
78 lines (74 loc) · 2.49 KB
/
run-api-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 }}