-
Notifications
You must be signed in to change notification settings - Fork 459
268 lines (249 loc) · 11.5 KB
/
yarn-upgrade.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: Yarn Upgrade
on:
schedule:
# At 04:04 every Monday
- cron: 4 4 * * 1
workflow_dispatch: {}
# We special-case @types/node because we want to stay on the current major (minimum supported node release)
# We special-case @types/fs-extra because the current major (9.x) is broken with @types/node >= 10
# We special-case typescript because it's not semantically versioned
# We special-case constructs because we want to stay in control of the minimum compatible version
# We special-case lerna because we have a patch on it that stops applying if Lerna upgrades. Remove this once https://github.com/lerna/lerna/pull/2874 releases.
# We special-case graphology-types because the newer version has type definitions that are not compatible with our typescript version.
# We special-case @types/prettier because the underlying TS types aren't supported by our TS version anymore since prettier v2.6.1
jobs:
upgradeRoot:
name: Yarn Upgrade Root
permissions:
contents: read
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Check Out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get yarn cache directory path
id: global-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ${{ steps.global-cache-dir-path.outputs.dir }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-upgrade
restore-keys: |
yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
yarn-${{ runner.os }}-
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Install Tools
run: |-
npm -g install lerna npm-check-updates@^9.0.0
- name: List Mono-Repo Packages
id: list-packages
# These need to be ignored from the `ncu` runs!
run: |-
echo "list=$(node -p "$(lerna ls --all --json 2>/dev/null).map(item => item.name).join(',')")" >> $GITHUB_OUTPUT
- name: Run "ncu -u"
run: |-
# Upgrade dependencies at repository root
ncu --upgrade --filter=@types/node,@types/fs-extra --target=minor
ncu --upgrade --filter=typescript --target=patch
ncu --upgrade --reject=@types/node,@types/fs-extra,constructs,typescript,lerna,@types/prettier --target=minor
# This will ensure the current lockfile is up-to-date with the dependency specifications (necessary for "yarn upgrade" to run)
- name: Run "yarn install"
run: yarn install --prefer-offline
# Next, create and upload the changes as a patch file. This will later be downloaded to create a pull request
# Creating a pull request requires write permissions and it's best to keep write privileges isolated.
- name: Create Patch
run: |-
git add .
git diff --patch --staged > ./upgrade.patch
- name: Upload Patch
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: upgrade.patch
path: ./upgrade.patch
prRoot:
name: Create Pull Request Root
needs: upgradeRoot
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download patch
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: upgrade.patch
- name: Apply patch
run: '[ -s ./upgrade.patch ] && git apply ./upgrade.patch || echo "Empty patch. Skipping."'
- name: Remove patch file
run: rm -f ./upgrade.patch
- name: Make Pull Request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
# Git commit details
branch: automation/yarn-upgrade
commit-message: |-
chore: npm-check-updates && yarn upgrade
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
# Pull Request details
title: "chore: npm-check-updates && yarn upgrade"
body: |-
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
labels: dependencies,auto-approve,ci/run-all
team-reviewers: cdktf
token: ${{ secrets.TERRAFORM_CDK_PUSH_GITHUB_TOKEN }}
upgradePackage:
name: Yarn Upgrade Package
permissions:
contents: read
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
strategy:
fail-fast: false
matrix:
pr: [
{ name: "cli", packages: ["cdktf-cli", "@cdktf/cli-core"] },
# A dumb hack to make the resulting expansion expression work since { cdktf }
# searches for the literal string, whereas { cdktf, cdktf } searches for either cdktf or cdktf
{ name: "lib", packages: ["cdktf", "cdktf"] },
{
name: "util",
packages:
[
"@cdktf/hcl2cdk",
"@cdktf/hcl2json",
"@cdktf/provider-schema",
"@cdktf/provider-generator",
"@cdktf/commons",
],
},
# Sometimes we are very lucky and all packages can be updated in one go
# We should take the chance and spare us some rebases
{
name: "all",
packages:
[
"cdktf-cli",
"@cdktf/cli-core",
"cdktf",
"@cdktf/hcl2cdk",
"@cdktf/hcl2json",
"@cdktf/provider-schema",
"@cdktf/provider-generator",
"@cdktf/commons",
],
},
]
steps:
- name: Check Out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get yarn cache directory path
id: global-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ${{ steps.global-cache-dir-path.outputs.dir }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-upgrade
restore-keys: |
yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
yarn-${{ runner.os }}-
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Install Tools
run: |-
npm -g install lerna npm-check-updates@^9.0.0
- name: List Mono-Repo Packages
id: list-packages
# These need to be ignored from the `ncu` runs!
run: |-
echo "list=$(node -p "$(lerna ls --all --json 2>/dev/null).map(item => item.name).join(',')")" >> $GITHUB_OUTPUT
- name: Run "ncu -u"
run: |-
# Upgrade all the packages
lerna exec --scope='{${{ join(matrix.pr.packages, ',') }}}' ncu -- --upgrade --filter=@types/node,@types/fs-extra --target=minor
lerna exec --scope='{${{ join(matrix.pr.packages, ',') }}}' ncu -- --upgrade --filter=typescript --target=patch
lerna exec --scope='{${{ join(matrix.pr.packages, ',') }}}' ncu -- --upgrade --reject='@types/node,@types/fs-extra,constructs,typescript,graphology-types,jsii,jsii-pacmak,jsii-rosetta,jsii-docgen,codemaker,${{ steps.list-packages.outputs.list }}' --target=minor
# This will ensure the current lockfile is up-to-date with the dependency specifications (necessary for "yarn upgrade" to run)
- name: Run "yarn install"
run: yarn install --prefer-offline
- name: Set git identity
run: |-
git config --global user.email "[email protected]"
git config --global user.name "team-tf-cdk"
- name: Make Pull Request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
# Git commit details
branch: automation/yarn-upgrade-${{ matrix.pr.name }}
commit-message: |-
chore: Upgrade dependencies for ${{matrix.pr.name}}
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
# Pull Request details
title: "chore: Upgrade dependencies for ${{matrix.pr.name}}"
body: |-
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
This PR touches the following packages:
${{ join(matrix.pr.packages, '\n -')}}
labels: dependencies,auto-approve
team-reviewers: cdktf
token: ${{ secrets.TERRAFORM_CDK_PUSH_GITHUB_TOKEN }}
author: team-tf-cdk <[email protected]>
upgradeJSII:
name: Yarn Upgrade JSII
permissions:
contents: read
runs-on: ubuntu-latest
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
steps:
- name: Check Out
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get yarn cache directory path
id: global-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ${{ steps.global-cache-dir-path.outputs.dir }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-upgrade
restore-keys: |
yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
yarn-${{ runner.os }}-
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
- name: Install Tools
run: |-
npm -g install lerna npm-check-updates@^9.0.0
- name: List Mono-Repo Packages
id: list-packages
# These need to be ignored from the `ncu` runs!
run: |-
echo "list=$(node -p "$(lerna ls --all --json 2>/dev/null).map(item => item.name).join(',')")" >> $GITHUB_OUTPUT
- name: Run "ncu -u"
run: |-
# Upgrade all the packages
lerna exec ncu -- --upgrade --filter='jsii,jsii-pacmak,jsii-rosetta,jsii-docgen,codemaker,constructs' --target=minor
# This will ensure the current lockfile is up-to-date with the dependency specifications (necessary for "yarn upgrade" to run)
- name: Run "yarn install"
run: yarn install --prefer-offline
- name: Set git identity
run: |-
git config --global user.email "[email protected]"
git config --global user.name "team-tf-cdk"
- name: Make Pull Request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
# Git commit details
branch: automation/yarn-upgrade-jsii
commit-message: |-
chore: Upgrade dependencies for JSII
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
# Pull Request details
title: "chore: Upgrade dependencies for JSII"
body: |-
Ran npm-check-updates and yarn upgrade to keep the `yarn.lock` file up-to-date.
This PR updates JSII across all packages.
labels: dependencies,auto-approve
team-reviewers: cdktf
token: ${{ secrets.TERRAFORM_CDK_PUSH_GITHUB_TOKEN }}
author: team-tf-cdk <[email protected]>