|
| 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 '.' |
0 commit comments