Skip to content

Commit a2f99c4

Browse files
committed
add turbo check action/workflow
1 parent 705c90d commit a2f99c4

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# .github/actions/check-turbo-changes/action.yml
2+
name: Check Turbo Changes
3+
description: Check which packages are marked to build by Turbo
4+
5+
outputs:
6+
torus-wallet:
7+
description: "Whether torus-wallet changed"
8+
value: ${{ steps.changed.outputs.torus-wallet }}
9+
torus-page:
10+
description: "Whether torus-page changed"
11+
value: ${{ steps.changed.outputs.torus-page }}
12+
torus-allocator:
13+
description: "Whether torus-allocator changed"
14+
value: ${{ steps.changed.outputs.torus-allocator }}
15+
torus-cache:
16+
description: "Whether torus-cache changed"
17+
value: ${{ steps.changed.outputs.torus-cache }}
18+
torus-bridge:
19+
description: "Whether torus-bridge changed"
20+
value: ${{ steps.changed.outputs.torus-bridge }}
21+
torus-worker:
22+
description: "Whether torus-worker changed"
23+
value: ${{ steps.changed.outputs.torus-worker }}
24+
torus-governance:
25+
description: "Whether torus-governance changed"
26+
value: ${{ steps.changed.outputs.torus-governance }}
27+
28+
runs:
29+
using: "composite"
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- uses: pnpm/action-setup@v4
36+
name: Install pnpm
37+
with:
38+
run_install: false
39+
40+
- name: Install Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: 20
44+
cache: "pnpm"
45+
46+
- name: Install dependencies
47+
shell: bash
48+
run: pnpm install
49+
50+
- name: Get apps list
51+
shell: bash
52+
run: |
53+
ls -d apps/* | sed 's/apps\///' | jq -R -s -c 'split("\n")[:-1]' > packages_to_track.json
54+
echo "Found packages:"
55+
cat packages_to_track.json
56+
57+
- name: Get build json (PR based)
58+
if: github.event_name == 'pull_request'
59+
shell: bash
60+
run: |
61+
pnpm exec turbo run build --filter="...[origin/${{ github.base_ref }}]" --dry-run=json 2>/dev/null > build.json
62+
63+
- name: Get build json (Push based)
64+
if: github.event_name == 'push'
65+
shell: bash
66+
run: |
67+
# Find the merge-base between current HEAD and the previous known state
68+
69+
if git rev-parse --quiet --verify ${{ github.event.before }}^{commit}; then
70+
BASE_COMMIT=$(git merge-base ${{ github.event.before }} HEAD)
71+
pnpm exec turbo run build --filter="...[${BASE_COMMIT}]" --dry-run=json 2>/dev/null > build.json
72+
else
73+
pnpm exec turbo run build --dry-run=json 2>/dev/null > build.json
74+
fi
75+
# pnpm exec turbo run build --filter="...[HEAD^1]" --dry-run=json 2>/dev/null > build.json
76+
77+
- name: Get changed packages
78+
shell: bash
79+
run: |
80+
cat build.json | jq -c '[.tasks[].package]' > package_list
81+
echo "Changed packages:"
82+
cat package_list
83+
84+
- name: Check changed packages
85+
id: changed
86+
shell: bash
87+
run: |
88+
CHANGED_PACKAGES=$(cat package_list)
89+
90+
while read -r package; do
91+
package=$(echo "$package" | tr -d '"')
92+
IS_CHANGED=$(echo $CHANGED_PACKAGES | jq -r "any(. == \"$package\")")
93+
echo "$package=$IS_CHANGED" >> $GITHUB_OUTPUT
94+
done < <(jq -c '.[]' packages_to_track.json)
95+
96+
- name: Debug outputs
97+
shell: bash
98+
run: |
99+
echo 'Changed packages status:'
100+
echo '${{ toJSON(steps.changed.outputs) }}' | jq '.'

.github/workflows/debug.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# .github/workflows/debug.yml
2+
name: Check Changes
3+
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
pr-push-check:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
skip: ${{ github.event_name == 'push' && steps.findPr.outputs.number != '' }}
13+
steps:
14+
- uses: jwalton/gh-find-current-pr@master
15+
id: findPr
16+
17+
- name: Debug PR info
18+
run: |
19+
echo "PR exists: ${{ steps.findPr.outputs.number != '' }}"
20+
echo "PR number: ${{ steps.findPr.outputs.number }}"
21+
echo "Is push based: ${{ github.event_name == 'push' }}"
22+
23+
turbo-check:
24+
needs: pr-push-check
25+
if: needs.pr-push-check.outputs.skip == 'false'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: ./.github/actions/check-turbo-changes
31+
id: changes
32+
33+
# Simple conditional steps
34+
- name: Build torus-wallet
35+
if: steps.changes.outputs.torus-wallet == 'true'
36+
run: echo "Building torus-wallet..."
37+
38+
- name: Build torus-page
39+
if: steps.changes.outputs.torus-page == 'true'
40+
run: echo "Building torus-page... "
41+
42+
# Debug output
43+
- name: Show changes
44+
run: |
45+
# Print all outputs
46+
echo "All changes:"
47+
echo '${{ toJSON(steps.changes.outputs) }}' | jq '.'

0 commit comments

Comments
 (0)