-
Notifications
You must be signed in to change notification settings - Fork 67
160 lines (150 loc) · 5.74 KB
/
integration-tests.yaml
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
# This workflow splits the tests to run across multiple nodes. This significantly reduces the testing time, as the
# tests require starting Octopus, MSSQL, and then running Terraform against the Octopus instance.
# See # Refer to https://github.com/hashicorp-forge/go-test-split-action for more information on how the tests are split.
name: Tests
'on':
workflow_dispatch: {}
pull_request:
jobs:
tests:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallel: [ 15 ]
index: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ]
steps:
- uses: actions/checkout@v3
- name: Install Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Set up Go
uses: actions/setup-go@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python JWT module
run: pip install jwt
# In order to test git integration, we need a token generated from a JWT.
# The first step is to generate a JWT from the GitHub App private key.
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app#example-using-python-to-generate-a-jwt
- name: Generate a JWT
run: ./github-app-jwt.py >> "$GITHUB_ENV"
env:
GH_APP_ID: ${{ secrets.GH_APP_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
# The next step is to generate an access token from the JWT.
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app#generating-an-installation-access-token
- name: Generate an access token
run: |
curl \
--silent \
--request POST \
--url "https://api.github.com/app/installations/${GH_APP_INSTALLATION_ID}/access_tokens" \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ env.jwt }}" \
--header "X-GitHub-Api-Version: 2022-11-28" | jq -r '"GIT_CREDENTIAL=" + .token' > "$GITHUB_ENV"
env:
GH_APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID }}
- name: Download JUnit Summary from Previous Workflow
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: success
name: junit-test-summary
if_no_artifact_found: warn
branch: main
- name: Split tests
id: test_split
uses: hashicorp-forge/go-test-split-action@v1
with:
index: ${{ matrix.index }}
total: ${{ matrix.parallel }}
junit-summary: ./junit-test-summary.xml
- name: Install Dependencies
run: go get ./...
shell: bash
- name: Build the Terraform provider from source
run: go build -o terraform-provider-octopusdeploy
- name: Override the location used by Terraform provider
run: |-
cat <<EOT >> ~/.terraformrc
provider_installation {
dev_overrides {
"octopusdeploylabs/octopusdeploy" = "${{ github.workspace }}"
}
direct {}
}
EOT
- name: Test
run: |
GOBIN=$PWD/bin go install gotest.tools/gotestsum@latest
./bin/gotestsum --junitfile node-summary.xml --format standard-verbose -- -run "${{ steps.test_split.outputs.run }}" -timeout 0 ./... -createSharedContainer=true
shell: bash
env:
LICENSE: ${{ secrets.OCTOPUS_SERVER_BASE64_LICENSE }}
ECR_ACCESS_KEY: ${{ secrets.ECR_ACCESS_KEY }}
ECR_SECRET_KEY: ${{ secrets.ECR_SECRET_KEY }}
GIT_USERNAME: x-access-token
OCTODISABLEOCTOCONTAINERLOGGING: true
OCTOTESTSKIPINIT: true
GOMAXPROCS: 1
OCTOTESTVERSION: latest
OCTOTESTIMAGEURL: docker.packages.octopushq.com/octopusdeploy/octopusdeploy
OCTOTESTRETRYCOUNT: 1
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: junit-test-summary-${{ matrix.index }}
path: node-summary.xml
retention-days: 1
tests-combine-summaries:
if: always()
name: Combine Test Reports
needs: [ tests ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Install junit-report-merger
run: npm install -g junit-report-merger
- name: Merge reports
run: >
jrm ./junit-test-summary.xml
"junit-test-summary-0/*.xml"
"junit-test-summary-1/*.xml"
"junit-test-summary-2/*.xml"
"junit-test-summary-3/*.xml"
"junit-test-summary-4/*.xml"
"junit-test-summary-5/*.xml"
"junit-test-summary-6/*.xml"
"junit-test-summary-7/*.xml"
"junit-test-summary-8/*.xml"
"junit-test-summary-9/*.xml"
"junit-test-summary-10/*.xml"
"junit-test-summary-11/*.xml"
"junit-test-summary-12/*.xml"
"junit-test-summary-13/*.xml"
"junit-test-summary-14/*.xml"
- name: Upload test artifacts
uses: actions/upload-artifact@v3
with:
name: junit-test-summary
path: ./junit-test-summary.xml
- name: Report
uses: dorny/test-reporter@v1
with:
name: Go Tests
path: junit-test-summary.xml
reporter: java-junit
fail-on-error: 'true'
permissions:
id-token: write
checks: write
contents: write