-
Notifications
You must be signed in to change notification settings - Fork 1.9k
122 lines (108 loc) · 3.43 KB
/
test-js-packages.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: JS Package Tests
on:
push:
branches: [main]
pull_request:
paths:
- package.json
- pnpm-workspace.yaml
- pnpm-lock.yaml
- "packages/**"
- ".github/actions/**"
- ".github/workflows/test-js-packages.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
actions: write
contents: read
pull-requests: read
jobs:
js_packages:
name: "JS Package Tests (${{matrix.os.name}}, Node ${{matrix.node-version}})"
timeout-minutes: 30
runs-on: ${{ matrix.os.runner }}
strategy:
fail-fast: false
matrix:
os:
- name: ubuntu
runner:
- "self-hosted"
- "linux"
- "x64"
- "metal"
- name: macos
runner: macos-13
node-version:
- 18
- 20
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
steps:
# on main -> current + prev commit
# pr -> pr commits + base commit
- name: Determine fetch depth
id: fetch-depth
run: |
echo "depth=$(( ${{ github.event.pull_request.commits || 1 }} + 1 ))" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: ${{ steps.fetch-depth.outputs.depth }}
- name: "Setup Node"
uses: ./.github/actions/setup-node
with:
extra-flags: --no-optional
node-version: ${{ matrix.node-version }}
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- name: Install Global Turbo
uses: ./.github/actions/install-global-turbo
- name: Run tests
# We manually set TURBO_API to an empty string to override Hetzner env
# We filter out turborepo-repository because it's a native package and needs
# to run when turbo core changes. This job (`js_packages`) does not run on turborpeo core
# changes, and we don't want to enable that beahvior for _all_ our JS packages.
run: |
TURBO_API= turbo run check-types test --filter="!turborepo-repository" --filter={./packages/*}...[${{ github.event.pull_request.base.sha || 'HEAD^1' }}] --color --env-mode=strict
env:
NODE_VERSION: ${{ matrix.node-version }}
summary:
name: Turborepo JS Test Summary
runs-on: ubuntu-latest
if: always()
needs:
- js_packages
steps:
- name: Compute info
id: info
if: always()
run: |
cancelled=false
failure=false
subjob () {
local result=$1
if [ "$result" = "cancelled" ]; then
cancelled=true
elif [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
failure=true
fi
}
subjob ${{needs.js_packages.result}}
if [ "$cancelled" = "true" ]; then
echo "cancelled=true" >> $GITHUB_OUTPUT
elif [ "$failure" = "true" ]; then
echo "failure=true" >> $GITHUB_OUTPUT
else
echo "success=true" >> $GITHUB_OUTPUT
fi
- name: Failed
if: steps.info.outputs.failure == 'true'
run: exit 1
- name: Succeeded
if: steps.info.outputs.success == 'true'
run: echo Ok