-
-
Notifications
You must be signed in to change notification settings - Fork 471
105 lines (93 loc) · 4.13 KB
/
alteration-compatibility-integration-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
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
# This integration test ci job is used to test the DB alterations compatibility with the current codebase.
name: Alteration compatibility integration test
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check-alteration-changes:
runs-on: ubuntu-latest
outputs:
has-alteration-changes: ${{ steps.changes-detection.outputs.has-alteration-changes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# compare the current codebase with HEAD and check if there are any changes under the alterations folder
# if the event is a pull request, we need to compare the merge base with HEAD, otherwise we compare the current commit with the previous commit
- name: Check for alteration changes
id: changes-detection
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE=$(git merge-base origin/${{ github.base_ref }} HEAD)
else
BASE=${{ github.event.before }}
fi
CHANGE_FILES=$(git diff --name-only $BASE | grep 'packages/schemas/alterations/' || true)
if [ -n "$CHANGE_FILES" ]; then
echo "$CHANGE_FILES"
echo "has-alteration-changes=true" >> $GITHUB_OUTPUT
echo "Alteration changes detected"
else
echo "has-alteration-changes=false" >> $GITHUB_OUTPUT
echo "No alteration changes detected"
fi
package:
needs: check-alteration-changes
runs-on: ubuntu-latest
if: ${{ needs.check-alteration-changes.outputs.has-alteration-changes == 'true' }}
env:
INTEGRATION_TEST: true
DEV_FEATURES_ENABLED: false
steps:
- uses: logto-io/actions-package-logto-artifact@v3
with:
artifact-name: alteration-integration-test-${{ github.sha }}
branch: ${{ github.base_ref }}
pnpm-version: 9
run-logto:
strategy:
fail-fast: false
matrix:
target: [api, experience, console]
needs: package
# An error will occur if we use a newer version of Ubuntu in the CI environment, as it has restrictions on unprivileged user namespaces and sandbox usage, which prevents Chromium (used by Puppeteer) from launching properly during integration tests. So we lock the Ubuntu version to 22.04.
# See error record: https://github.com/logto-io/logto/actions/runs/12803809008/job/35697654974
runs-on: ubuntu-22.04
env:
INTEGRATION_TEST: true
DEV_FEATURES_ENABLED: false
DB_URL: postgres://postgres:postgres@localhost:5432/postgres
steps:
- uses: logto-io/actions-run-logto-integration-tests@v4
with:
branch: ${{ github.base_ref }}
logto-artifact: alteration-integration-test-${{ github.sha }}
test-target: ${{ matrix.target }}
db-alteration-target: ${{ github.head_ref }}
pnpm-version: 9
# Automatically rerun the workflow since the integration tests are moody
# From this genius: https://github.com/orgs/community/discussions/67654#discussioncomment-8038649
rerun-on-failure:
needs: run-logto
if: failure() && fromJSON(github.run_attempt) < 3
# An error will occur if we use a newer version of Ubuntu in the CI environment, as it has restrictions on unprivileged user namespaces and sandbox usage, which prevents Chromium (used by Puppeteer) from launching properly during integration tests. So we lock the Ubuntu version to 22.04.
# See error record: https://github.com/logto-io/logto/actions/runs/12803809008/job/35697654974
runs-on: ubuntu-22.04
steps:
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
GH_DEBUG: api
run: gh workflow run rerun.yml -F run_id=${{ github.run_id }}
alteration-compatibility-conclusion:
needs: run-logto
runs-on: ubuntu-latest
if: always() && (needs.run-logto.result == 'success' || needs.run-logto.result == 'skipped')
steps:
- name: Conclusion
run: echo "Alteration compatibility integration test completed successfully"