forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (147 loc) · 6.47 KB
/
CI.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
# 12PM UTC -> 4AM Pacific
- cron: '0 12 * * *'
workflow_dispatch:
permissions:
contents: read
concurrency:
# If in a PR, use the ref (refs/pull/<num>) so outdated PR runs are cancelled.
# Otherwise, run_id is unique so all other events will never be cancelled.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
setup-matrix:
runs-on: ubuntu-latest
if: github.repository == 'DefinitelyTyped/DefinitelyTyped'
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
# Need this to be able to inquire about origin/master
filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none.
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- id: matrix
run: |
if [ "${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}" == "true" ]; then
TESTS=all
else
TESTS=$(pnpm ls --depth -1 --parseable --filter '...@types/**[HEAD^1]' | wc -)
fi
MATRIX=$(node ./scripts/get-ci-matrix $TESTS)
echo $MATRIX
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
test:
runs-on: ubuntu-latest
if: github.repository == 'DefinitelyTyped/DefinitelyTyped'
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
with:
# Need this to be able to inquire about origin/master
filter: blob:none # https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
fetch-depth: 0 # Default is 1; need to set to 0 to get the benefits of blob:none.
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
# forbid symlinks
- name: 'Pre-run validation'
run: |
symlinks="$(find . -type l)"
if [[ -n "$symlinks" ]]; then
printf "Aborting: symlinks found:\n%s" "$symlinks"; exit 1
fi
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
- name: Get pnpm cache info
id: pnpm-cache
run: |
echo "store=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Restore pnpm cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ steps.pnpm-cache.outputs.store }}
key: ${{ runner.os }}-pnpm-store-cache-
restore-keys: ${{ runner.os }}-pnpm-store-cache-
- run: ./scripts/pnpm-install.sh
name: pnpm install (filtered)
if: ${{ !(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
- run: pnpm install
name: pnpm install
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
- run: pnpm ls
- run: pnpm run test-all --diffBase HEAD^1 --shardCount ${{ matrix.shardCount }} --shardId ${{ matrix.shardId }}
if: ${{ !(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
- run: pnpm run test-all --selection all --shardCount ${{ matrix.shardCount }} --shardId ${{ matrix.shardId }}
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
- name: Get suggestions dir
id: suggestions-dir
run: echo "path=$(node ./scripts/get-suggestions-dir.js)" >> "$GITHUB_OUTPUT"
if: ${{ github.event_name == 'pull_request' }}
- name: Upload suggestions
uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2
with:
name: suggestions_${{ matrix.shardId }}_${{ matrix.shardCount }}
if-no-files-found: ignore
path: ${{ steps.suggestions-dir.outputs.path }}
retention-days: 1
if: ${{ github.event_name == 'pull_request' }}
dangerbot:
runs-on: ubuntu-latest
if: github.repository == 'DefinitelyTyped/DefinitelyTyped' && github.event_name == 'pull_request'
needs:
- test
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
run_install: |
- args: [--filter, ., --filter, '{./scripts}...']
- name: Get suggestions dir
id: suggestions-dir
run: echo "path=$(node ./scripts/get-suggestions-dir.js)" >> "$GITHUB_OUTPUT"
- uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5
with:
path: ${{ steps.suggestions-dir.outputs.path }}
merge-multiple: true
- name: 'Run Danger'
env:
# See https://github.com/danger/danger-js/issues/1042
DANGER_GITHUB_API_BASE_URL: 'https://api.github.com'
# Danger failing (for example through rate-limiting) shouldn't fail the build
run: |
# Exposing this token is safe because the user of it has no other public repositories
# and has no permission to modify this repository. See #62638 for the discussion.
TOKEN='ghp_i5wtj1l2AbpFv3OU96w6R'
TOKEN+='On3bHOkcV2AmVY6'
DANGER_GITHUB_API_TOKEN=$TOKEN pnpm danger ci || $( exit 0 )
scripts:
runs-on: ubuntu-latest
if: github.repository == 'DefinitelyTyped/DefinitelyTyped'
steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '20'
- uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0
with:
run_install: |
- args: [--filter, ., --filter, '{./scripts}...']
- run: pnpm tsc -p ./scripts