-
-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (72 loc) · 3.03 KB
/
ci.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
79
80
81
82
83
84
85
86
87
88
89
90
91
name: ci
on:
push:
branches:
- main
pull_request:
permissions:
actions: read
contents: read
env:
CI: true
DOTENV_PRIVATE_KEY_CI: ${{ secrets.DOTENV_PRIVATE_KEY_CI }}
POSTGRES_URL: postgres://dbuser:secret@localhost:5432
POSTGRES_DB: cat_fostering_api_e2e
NX_CLOUD_DISTRIBUTED_EXECUTION: ${{ vars.NX_CLOUD_DISTRIBUTED_EXECUTION || 'true' }}
# ?NX_CI_EXECUTION_ID: 9682651267
# E2E config
DEBUG:KRATOS_CLI: true
DEBUG:KETO_CLI: true
ORY_KRATOS_PUBLIC_URL: http://127.0.0.1:4433
ORY_KETO_ADMIN_URL: http://127.0.0.1:4467
ORY_KETO_PUBLIC_URL: http://127.0.0.1:4466
API_HOST: 127.0.0.1
API_PORT: 3000
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# TODO: ensure vars are shared with agents --with-env-vars="auto"
# --require-explicit-completion because Nx agents might not receive tasks for more than 30 seconds when preparing the e2e test environment
# @see https://nx.dev/ci/troubleshooting/ci-execution-failed#the-nx-cloud-heartbeat-process-failed-to-report-its-status-in-time
- run: npx nx-cloud start-ci-run --distribute-on="3 custom-linux-small-js" --stop-agents-after="e2e-ci" --require-explicit-completion
if: ${{ env.NX_CLOUD_DISTRIBUTED_EXECUTION == 'true' }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: |
**/package-lock.json
patches/*.patch
- run: npm ci
- uses: nrwl/nx-set-shas@v4
with:
workflow-id: 'ci.yml'
- run: npx nx affected -t lint test build
if: ${{ !env.ACT }}
- run: |
npm run ory:generate:kratos -- -e .env.ci
npm run ory:generate:keto -- -e .env.ci
- run: npx nx run cat-fostering-api:docker-build --no-agents
# can't use --wait --wait-timeout N options since Keto and Kratos migrate containers will exit before the Keto and Kratos services are ready
- run: npx @dotenvx/dotenvx run -- docker compose --profile ci -p cat-fostering up -d
- run: sleep 10
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
- run: npx nx-cloud record -- docker ps
- run: npx nx-cloud record -- docker compose -p cat-fostering logs keto -n 500
- run: npx nx-cloud record -- docker compose -p cat-fostering logs kratos -n 500
- name: Run e2e tests
run: npx nx affected -t e2e --no-agents
if: ${{ env.NX_CLOUD_DISTRIBUTED_EXECUTION == 'false' }}
# to enable DTE for e2e tests splitting, use the following command instead and set stop-agents-after="e2e-ci"
- name: Run distributed e2e tests
run: |
npm run pg:create:connection -- -e .env.ci
docker compose -p cat-fostering restart api
npx nx affected -t e2e-ci
if: ${{ env.NX_CLOUD_DISTRIBUTED_EXECUTION == 'true' }}
- run: npx nx-cloud complete-ci-run
if: always() && ${{ env.NX_CLOUD_DISTRIBUTED_EXECUTION == 'true' }}