Repository navigation
185 lines (180 loc) · 8.32 KB
/
Copy pathexamples.yml
File metadata and controls
185 lines (180 loc) · 8.32 KB
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
name: Examples Integration
on:
workflow_call:
inputs:
concurrency_group_prefix:
default: pr
required: false
type: string
workflow_dispatch:
inputs:
concurrency_group_prefix:
default: pr
required: false
type: string
env:
HUSKY: "0"
NX_DEFAULT_OUTPUT_STYLE: static
concurrency:
group: ${{ inputs.concurrency_group_prefix }}-examples-${{ github.head_ref }}
cancel-in-progress: true
jobs:
build-example-matrix:
runs-on: ubuntu-latest
outputs:
examples: ${{ steps.set-examples.outputs.examples }}
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build example matrix
id: set-examples
run: echo "examples=$(node tools/build-example-matrix.mjs)" | tee -a $GITHUB_OUTPUT
prepare-examples:
runs-on: ubuntu-latest
container:
image: ghcr.io/open-constructs/jsii-terraform@sha256:62c00a313a1c9457c0d8d3b6ee86c77d241c2d18c4cc1f9b9015836d6d6a98c8
env:
CHECKPOINT_DISABLE: "1"
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: "Add Git safe.directory" # Go 1.18+ started embedding repo info in the build and e.g. building @cdktn/hcl2json fails without this
run: git config --global --add safe.directory /__w/cdk-terrain/cdk-terrain
- name: Ensure correct user
run: chown -R root /__w/cdk-terrain
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
- name: Setup corepack-managed pnpm
uses: ./.github/actions/setup-corepack-pnpm
- name: Get cache directory paths
id: global-cache-dir-path
run: |
mkdir -p /usr/local/share/.cache/go
echo "go=/usr/local/share/.cache/go" >> $GITHUB_OUTPUT
- name: Cache go
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.global-cache-dir-path.outputs.go }}
key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-examples
restore-keys: |
go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-
go-${{ runner.os }}-
- name: Install dependencies
timeout-minutes: 20
run: pnpm ci
- name: Build packages
timeout-minutes: 30
run: pnpm run build
env:
GOCACHE: ${{ steps.global-cache-dir-path.outputs.go }}
- name: Create dist bundle
timeout-minutes: 30
run: pnpm run package
env:
GOCACHE: ${{ steps.global-cache-dir-path.outputs.go }}
- name: Upload dist
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist-examples
path: dist
examples:
needs: [build-example-matrix, prepare-examples]
name: "${{ matrix.target }} @ tf${{ matrix.terraform }}${{ matrix.hclOutput && ' (HCL)' || '' }}"
# JSII-translated documentation examples generate many provider bindings in parallel; the extra cores/memory let
# `cdktn get` run unthrottled (peaks ~22 GB). go-documentation stays on the larger -16 runner; the rest fit -8's
# 32 GB. typescript-documentation is excluded — TS bindings aren't JSII-translated.
runs-on: ${{ matrix.target == '@examples/go-documentation' && 'depot-ubuntu-24.04-16' || (contains(fromJSON('["@examples/csharp-documentation", "@examples/java-documentation", "@examples/java-documentation-gradle", "@examples/python-documentation"]'), matrix.target) && 'depot-ubuntu-24.04-8' || 'ubuntu-latest') }}
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.build-example-matrix.outputs.examples)}}
max-parallel: 20
container:
image: ghcr.io/open-constructs/jsii-terraform@sha256:62c00a313a1c9457c0d8d3b6ee86c77d241c2d18c4cc1f9b9015836d6d6a98c8
env:
CHECKPOINT_DISABLE: "1"
# jsii >= 1.142 rejects the default cache under HOME, which the container user does not own
JSII_RUNTIME_PACKAGE_CACHE_ROOT: /root/.cache/aws/jsii/package-cache
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: "Add Git safe.directory" # Go 1.18+ started embedding repo info in the build and e.g. building @cdktn/hcl2json fails without this
run: git config --global --add safe.directory /__w/cdk-terrain/cdk-terrain
- name: Ensure correct user
run: chown -R root /__w/cdk-terrain
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
- name: Setup corepack-managed pnpm
uses: ./.github/actions/setup-corepack-pnpm
- name: Get cache directory paths
id: global-cache-dir-path
run: |
mkdir -p /usr/local/share/.cache/terraform
echo "terraform=/usr/local/share/.cache/terraform" >> $GITHUB_OUTPUT
mkdir -p /usr/local/share/.cache/go
echo "go=/usr/local/share/.cache/go" >> $GITHUB_OUTPUT
mkdir -p /usr/local/share/.cache/gradle
echo "gradle=/usr/local/share/.cache/gradle" >> $GITHUB_OUTPUT
- name: Cache terraform plugins
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.global-cache-dir-path.outputs.terraform }}
key: terraform-${{ runner.os }}-${{ matrix.binary }}-examples
restore-keys: |
terraform-${{ runner.os }}-${{ matrix.binary }}
- name: Cache go
# Only Go examples and the cross-language `*-documentation` examples need GOCACHE
if: startsWith(matrix.target, '@examples/go') || endsWith(matrix.target, '-documentation')
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.global-cache-dir-path.outputs.go }}
key: go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-examples
restore-keys: |
go-${{ runner.os }}-${{ hashFiles('**/go.sum') }}-
go-${{ runner.os }}-
- name: Cache gradle
if: endsWith(matrix.target, '-gradle')
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
# Skip daemon/, notifications/, native/ — only the distribution + module jars are worth keeping
path: |
${{ steps.global-cache-dir-path.outputs.gradle }}/caches/modules-2
${{ steps.global-cache-dir-path.outputs.gradle }}/wrapper/dists
key: gradle-${{ runner.os }}-${{ hashFiles('examples/java/*-gradle/gradle/wrapper/gradle-wrapper.properties') }}-examples
restore-keys: gradle-${{ runner.os }}-
- name: Download dist
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist-examples
path: dist
- name: Install dependencies
timeout-minutes: 20
run: pnpm ci
- name: Install test dependencies
timeout-minutes: 15
run: cd test && pnpm ci
- name: Recreate packages/cdktn/dist/go layout for Go examples
# Go examples' go.mod files use `replace ... => ../../../packages/cdktn/dist/go/cdktn`,
# which points at the per-package build output. The matrix job only has the aggregated
# `dist/` artifact, so symlink the per-package path to the aggregated location.
if: startsWith(matrix.target, '@examples/go') || endsWith(matrix.target, '-documentation')
run: |
mkdir -p packages/cdktn/dist/go
ln -sfn "$PWD/dist/go/cdktn" packages/cdktn/dist/go/cdktn
- name: examples integration tests
timeout-minutes: 30
run: test/run-against-dist.mjs node tools/build-example.mjs ${TEST_TARGET}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
TEST_TARGET: "${{ matrix.target }}"
TERRAFORM_BINARY_NAME: ${{ matrix.binary }}
MAVEN_OPTS: "-Xmx3G"
TF_PLUGIN_CACHE_DIR: ${{ steps.global-cache-dir-path.outputs.terraform }}
GOCACHE: ${{ steps.global-cache-dir-path.outputs.go }}
GRADLE_USER_HOME: ${{ steps.global-cache-dir-path.outputs.gradle }}
SYNTH_HCL_OUTPUT: ${{ matrix.hclOutput }}