-
Notifications
You must be signed in to change notification settings - Fork 1.7k
223 lines (190 loc) · 6.62 KB
/
downstreams.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
name: downstreams
permissions: read-all
on:
push:
branches:
- main
- 'FEATURE-BRANCH-*'
pull_request:
concurrency:
group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('commit-{0}', github.sha) }}
cancel-in-progress: true
# concurrency:
# group: downstreams-${{ github.event.inputs.owner }}-${{ github.event.inputs.repo }}-${{ github.event.inputs.branch }}
# cancel-in-progress: true
jobs:
build-downstreams:
name: ${{ matrix.repo }}
strategy:
fail-fast: false
matrix:
repo: ['terraform-provider-google', 'terraform-provider-google-beta', 'terraform-google-conversion', 'docs-examples']
runs-on: ubuntu-22.04
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
ruby-version: '3.1'
- name: Cache Bundler gems
uses: actions/cache@v2
with:
path: mmv1/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Ruby dependencies
run: |
bundle config path mmv1/vendor/bundle
bundle install
working-directory: mmv1
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '^1.19'
# Cache Go modules
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go install golang.org/x/tools/cmd/goimports@latest
- name: Build ${{ matrix.repo }}
run: |
set -e
set -x
# Set GOPATH to a directory the runner user has access to
export GOPATH=~/go
function clone_repo() {
export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO
mkdir -p "$(dirname $OUTPUT_PATH)"
git clone $GITHUB_PATH $OUTPUT_PATH --branch $BASE_BRANCH
}
GH_REPO="${{ matrix.repo }}"
if [ "$GH_REPO" == "docs-examples" ] && [ "$BASE_BRANCH" == "main" ]; then
BASE_BRANCH="master"
fi
GITHUB_PATH=https://x-access-token:[email protected]/$UPSTREAM_OWNER/$GH_REPO
if [[ "$GH_REPO" == terraform-provider-google* ]]; then
UPSTREAM_OWNER=hashicorp
clone_repo
if [ "$GH_REPO" == "terraform-provider-google" ]; then
export VERSION=ga
else
export VERSION=beta
fi
make clean-provider
make provider
elif [ "$GH_REPO" == "terraform-google-conversion" ]; then
UPSTREAM_OWNER=GoogleCloudPlatform
clone_repo
make clean-tgc
make tgc
elif [ "$GH_REPO" == "docs-examples" ]; then
UPSTREAM_OWNER=terraform-google-modules
clone_repo
make tf-ocis
else
echo "case not supported"
exit 1
fi
(current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .)
- name: Upload built artifacts
uses: actions/upload-artifact@v2
with:
name: artifact-${{ matrix.repo }}
path: output.zip
unit-test-terraform-provider-googele:
name: unit-test-${{ matrix.repo }}
needs: build-downstreams
strategy:
fail-fast: false
matrix:
repo: ['terraform-provider-google', 'terraform-provider-google-beta']
runs-on: ubuntu-22.04
steps:
- name: Download built artifacts
uses: actions/download-artifact@v2
with:
name: artifact-${{ matrix.repo }}
path: artifacts
- name: Unzip the artifacts and delete the zip
run: |
unzip artifacts/output.zip -d ./
rm artifacts/output.zip
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '^1.19'
- name: Cache Go modules and build cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-test-${{ matrix.repo }}-${{hashFiles('go.sum','google-*/transport/**','google-*/tpgresource/**','google-*/acctest/**','google-*/envvar/**','google-*/sweeper/**','google-*/verify/**') }}
restore-keys: |
${{ runner.os }}-test-${{ matrix.repo }}-${{ hashFiles('go.sum') }}
${{ runner.os }}-test-${{ matrix.repo }}-
- name: Build Provider
run: |
go build
- name: Run Unit Tests
run: |
make testnolint
- name: Lint Check
run: |
make lint
- name: Documentation Check
run: |
make docscheck
unit-test-terraform-google-conversion:
needs: build-downstreams
runs-on: ubuntu-22.04
steps:
- name: Download built artifacts
uses: actions/download-artifact@v2
with:
name: artifact-terraform-google-conversion
path: artifacts-tgc
- name: Download built artifacts
uses: actions/download-artifact@v2
with:
name: artifact-terraform-google-conversion
path: artifacts-tpgb
- name: Unzip the artifacts and delete the zip
run: |
unzip artifacts-tgc/output.zip -d ./tgc
unzip artifacts-tpgb/output.zip -d ./tgc
rm artifacts-tgc/output.zip
rm artifacts-tpgb/output.zip
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '^1.19'
- name: Cache Go modules and build cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
key: ${{ runner.os }}-test-terraform-google-conversion-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-test-terraform-google-conversion-${{ hashFiles('**/go.sum') }}
${{ runner.os }}-test-terraform-google-conversion-
- name: Build Terraform Google Conversion
run: |
go mod edit -replace=github.com/hashicorp/terraform-provider-google-beta=../tpgb
go mod tidy
make build
- name: Run Unit Tests
run: |
make test