This repository was archived by the owner on Dec 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 514
107 lines (104 loc) · 4.58 KB
/
examples.yml
File metadata and controls
107 lines (104 loc) · 4.58 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
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
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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: set-examples
run: |
tfDefault=$(cat .terraform.versions.json | jq -r '.default')
examples=$(npx lerna list --scope "@examples/*" | jq -R -s -c --arg tfDefault "${tfDefault}" 'split("\n") | map(select(length > 0)) | { target: values, terraform: [$tfDefault], hclOutput: [false, true] }')
echo $examples
echo "examples=$examples" >> $GITHUB_OUTPUT
examples:
needs: build-example-matrix
# Go documentation example generates bindings for AWS and other providers and hence requires a lot of memory
runs-on: ${{ matrix.target == '@examples/go-documentation' && 'custom-linux-large' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.build-example-matrix.outputs.examples)}}
container:
image: docker.mirror.hashicorp.services/hashicorp/jsii-terraform
env:
CHECKPOINT_DISABLE: "1"
timeout-minutes: 60
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: "Add Git safe.directory" # Go 1.18+ started embedding repo info in the build and e.g. building @cdktf/hcl2json fails without this
run: git config --global --add safe.directory /__w/terraform-cdk/terraform-cdk
- name: ensure correct user
run: chown -R root /__w/terraform-cdk
# Setup caches for yarn, terraform, and go
- name: Get cache directory paths
id: global-cache-dir-path
run: |
echo "yarn=$(yarn cache dir)" >> $GITHUB_OUTPUT
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
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ steps.global-cache-dir-path.outputs.yarn }}
key: yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-examples
restore-keys: |
yarn-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
yarn-${{ runner.os }}-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ steps.global-cache-dir-path.outputs.terraform }}
key: terraform-${{ runner.os }}-${{ matrix.terraform }}-examples
restore-keys: |
terraform-${{ runner.os }}-${{ matrix.terraform }}
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
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: installing dependencies
run: |
yarn install --frozen-lockfile --prefer-offline
- name: lint
run: yarn lint:examples
- name: align version (Python only)
if: startsWith(matrix.target, '@examples/python') # lint:examples ensures this prefix
run: tools/align-version.sh "-dev.$GITHUB_RUN_ID"
- name: compile
run: yarn build
env:
TERRAFORM_BINARY_NAME: "terraform${{ matrix.terraform }}"
TF_PLUGIN_CACHE_DIR: ${{ steps.global-cache-dir-path.outputs.terraform }}
GOCACHE: ${{ steps.global-cache-dir-path.outputs.go }}
- name: create bundle
run: yarn package
- name: examples integration tests
run: test/run-against-dist node tools/build-example.js ${TEST_TARGET}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
TEST_TARGET: "${{ matrix.target }}"
TERRAFORM_BINARY_NAME: "terraform${{ matrix.terraform }}"
MAVEN_OPTS: "-Xmx3G"
TF_PLUGIN_CACHE_DIR: ${{ steps.global-cache-dir-path.outputs.terraform }}
GOCACHE: ${{ steps.global-cache-dir-path.outputs.go }}
SYNTH_HCL_OUTPUT: ${{ matrix.hclOutput }}