-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (93 loc) · 3.58 KB
/
Copy pathverify-examples-sync.yml
File metadata and controls
113 lines (93 loc) · 3.58 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
name: Verify Examples Sync
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches: [main]
paths:
- 'examples/**'
- 'packages/**'
- 'plugins/**'
push:
branches: [main]
paths:
- 'examples/**'
- 'packages/**'
- 'plugins/**'
jobs:
discover:
name: Discover Examples
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.list-examples.outputs.examples }}
steps:
- name: Checkout Repo
uses: actions/checkout@v5
- name: List example directories
id: list-examples
run: |
# List directories in examples folder and format as JSON array
cd examples
directories=($(find . -maxdepth 1 -type d -not -name "." | sed 's|./||' | sort))
# Create JSON array
json_array=()
for dir in "${directories[@]}"; do
json_array+=("\"$dir\"")
done
# Join array elements with commas
json_elements=$(IFS=,; echo "${json_array[*]}")
json_output="[${json_elements}]"
echo "Found examples: $json_output"
echo "examples=$json_output" >> "$GITHUB_OUTPUT"
verify-sync:
name: Verify Sync
runs-on: ubuntu-latest
needs: discover
strategy:
matrix:
example: ${{ fromJSON(needs.discover.outputs.examples) }}
steps:
- name: Checkout Repo
uses: actions/checkout@v5
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: Derive appropriate SHAs for base for `turbo --affected` commands
uses: nrwl/nx-set-shas@dbe0650947e5f2c81f59190a38512cf49126fe6b # v4.3.0
- name: Set environment variable for Turborepo
run: echo "TURBO_SCM_BASE=$NX_BASE" >> $GITHUB_ENV
- name: Cache turbo build setup
uses: rharkor/caching-for-turbo@a1c4079258ae08389be75b57d4d7a70f23c1c66d # 1.8
with:
cache-prefix: verify-sync-${{ matrix.example }}
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: package.json
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build affected packages
run: pnpm build --filter=@baseplate-dev/project-builder-cli
- name: Install dependencies in example project
working-directory: examples/${{ matrix.example }}
run: pnpm install --frozen-lockfile
- name: Run sync diff for example
run: |
echo "Verifying that example '${{ matrix.example }}' has no uncommitted generated code differences..."
# Use the built CLI to check for differences
pnpm start diff ${{ matrix.example }} --fail-on-differences
if [ $? -eq 0 ]; then
echo "✅ Example '${{ matrix.example }}' is in sync with generators"
else
echo "❌ Example '${{ matrix.example }}' has differences between generated and committed code"
echo ""
echo "This means the example project is not in sync with the latest generator code."
echo "Please run 'pnpm start diff ${{ matrix.example }}' locally to see the differences"
echo "and either:"
echo " 1. Update the generators to match the current code, or"
echo " 2. Regenerate the example code with 'baseplate start sync ${{ matrix.example }}'"
exit 1
fi