96 lines (80 loc) · 2.62 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
name: CI Tests
on:
pull_request:
branches:
- main
jobs:
codegen:
name: Codegen
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- name: Install mockgen
run: |
set -eux -o pipefail
MOCKGEN_VERSION=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/golang/mock/releases/latest | awk -F'/v' '{printf$2}')
MOCKGEN_ZIP=mock_${MOCKGEN_VERSION}_linux_amd64.tar.gz
curl -OL https://github.com/golang/mock/releases/download/v$MOCKGEN_VERSION/$MOCKGEN_ZIP
sudo tar xvzf $MOCKGEN_ZIP --strip-components 1 -C /usr/local
sudo chmod +x /usr/local/mockgen
rm -f $MOCKGEN_ZIP
echo /usr/local/ >> $GITHUB_PATH
- name: Get dependencies
run: go mod download
- name: Generate mocks
run: ./generate_mocks.sh
- name: verify go.mod and go.sum are consistent
run : go mod tidy
- name: Ensure nothing changed
run: git diff --exit-code
tests:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallel: [3]
index: [0, 1, 2]
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- name: Sync dependencies
run: |
go mod download
go mod tidy
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Split integration tests
id: test_split
uses: brandonc/go-test-split-action@v1
with:
index: ${{ matrix.index }}
total: ${{ matrix.parallel }}
- name: Fetch outputs
env:
TFE_TOKEN: "${{ secrets.TF_WORKFLOW_TFLOCAL_CLOUD_TFC_TOKEN }}"
run: |
go run .github/scripts/fetch_outputs/main.go hashicorp-v2 tflocal-go-tfe
- name: Run integration tests
env:
TFC_RUN_TASK_URL: "https://httpstat.us/200"
GITHUB_POLICY_SET_IDENTIFIER: "hashicorp/test-policy-set"
GITHUB_REGISTRY_MODULE_IDENTIFIER: "hashicorp/terraform-random-module"
OAUTH_CLIENT_GITHUB_TOKEN: "${{ secrets.OAUTH_CLIENT_GITHUB_TOKEN }}"
GO111MODULE: "on"
run: |
source $HOME/.env
gotestsum --format short-verbose -- -timeout=29m -run "${{ steps.test_split.outputs.run }}"