forked from safe-global/safe-wallet-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (71 loc) · 2.56 KB
/
Copy pathstore-codegen-drift.yml
File metadata and controls
78 lines (71 loc) · 2.56 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
name: Store Codegen Drift
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-dev
cancel-in-progress: true
jobs:
check-drift:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6.0.0
with:
persist-credentials: false
ref: dev
- uses: ./.github/actions/yarn
with:
after-install: 'false'
- name: Test drift PR automation
run: bash .github/scripts/tests/store-codegen-pull-request.test.sh
- run: yarn workspace @safe-global/store build:dev
- name: Test generated endpoint routing
run: bash .github/scripts/tests/store-generated-endpoints.test.sh
- name: Detect drift
id: drift
shell: bash
run: |
codegen_paths=(
packages/store/scripts/api-schema/schema.json
packages/store/src/gateway/AUTO_GENERATED/
)
: > "${RUNNER_TEMP}/drift-files.txt"
while IFS= read -r -d '' changed_path; do
if [[ -n "${changed_path}" ]]; then
printf '%s\n' "${changed_path}" >> "${RUNNER_TEMP}/drift-files.txt"
fi
done < <(
git diff -z --name-only HEAD -- "${codegen_paths[@]}"
git ls-files -z --others --exclude-standard -- "${codegen_paths[@]}"
)
if [[ ! -s "${RUNNER_TEMP}/drift-files.txt" ]]; then
echo "changed=false" >> "${GITHUB_OUTPUT}"
else
echo "changed=true" >> "${GITHUB_OUTPUT}"
fi
- name: Report drift
if: steps.drift.outputs.changed == 'true'
run: |
{
echo "## Store codegen drift detected"
echo
echo 'The generated Store API client is out of sync with the staging CGW schema.'
echo 'The workflow will create or update a review PR with the regenerated snapshot.'
echo
echo '**Changed files:**'
echo '```text'
cat "${RUNNER_TEMP}/drift-files.txt"
echo '```'
} >> "${GITHUB_STEP_SUMMARY}"
- name: Create or update drift PR
if: steps.drift.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_REPOSITORY: ${{ github.repository }}
BASE_BRANCH: dev
AUTOMATION_BRANCH: automation/store-codegen-drift
DRIFT_FILES_PATH: ${{ runner.temp }}/drift-files.txt
run: bash .github/scripts/store-codegen-pull-request.sh