Repository navigation
117 lines (98 loc) · 3.49 KB
/
Copy pathci.yml
File metadata and controls
117 lines (98 loc) · 3.49 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
application:
name: Application checks
runs-on: ubuntu-latest
timeout-minutes: 25
defaults:
run:
working-directory: stackaudit
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: stackaudit/package-lock.json
- name: Install locked dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Unit tests
run: npm test
- name: Production build
env:
NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321
SUPABASE_SERVICE_ROLE_KEY: dummy-build-service-role-key
STACKAUDIT_DATABASE_MODE: local
STACKAUDIT_WORKSPACE_ORG_ID: 8a775c7f-e31c-8f9b-9000-000000000001
run: npm run build
database:
name: Supabase migrations and integration
runs-on: ubuntu-latest
timeout-minutes: 35
defaults:
run:
working-directory: stackaudit
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: stackaudit/package-lock.json
- name: Install locked dependencies and Supabase CLI
run: npm ci
- name: Start disposable local Supabase
shell: bash
run: |
if ! npx supabase start --exclude studio,edge-runtime,logflare,vector,imgproxy,inbucket,supavisor > "$RUNNER_TEMP/supabase-start.log" 2>&1; then
sed -E \
-e 's/(service_role key:|SERVICE_ROLE_KEY=)[[:space:]]*[^[:space:]]+/\1[REDACTED]/Ig' \
-e 's/(anon key:|ANON_KEY=)[[:space:]]*[^[:space:]]+/\1[REDACTED]/Ig' \
"$RUNNER_TEMP/supabase-start.log" >&2
exit 1
fi
- name: Apply complete migration history to an empty database
run: npx supabase db reset
- name: Run SQL integration tests and RPC assertions
run: npx supabase test db
- name: Export local Supabase test credentials
shell: bash
run: |
npx supabase status -o env > "$RUNNER_TEMP/supabase-status.env"
api_url="$(sed -n 's/^API_URL=//p' "$RUNNER_TEMP/supabase-status.env" | tr -d '\"')"
service_role_key="$(sed -n 's/^SERVICE_ROLE_KEY=//p' "$RUNNER_TEMP/supabase-status.env" | tr -d '\"')"
if [[ -z "$api_url" || -z "$service_role_key" ]]; then
echo "Supabase CLI did not provide the local API URL and service-role key." >&2
exit 1
fi
echo "::add-mask::$service_role_key"
echo "NEXT_PUBLIC_SUPABASE_URL=$api_url" >> "$GITHUB_ENV"
echo "SUPABASE_SERVICE_ROLE_KEY=$service_role_key" >> "$GITHUB_ENV"
echo "STACKAUDIT_DATABASE_MODE=local" >> "$GITHUB_ENV"
echo "STACKAUDIT_WORKSPACE_ORG_ID=8a775c7f-e31c-8f9b-9000-000000000001" >> "$GITHUB_ENV"
- name: Run database-backed application tests
run: npm run test:integration
- name: Stop disposable local Supabase
if: always()
run: npx supabase stop --no-backup