Fnm/create new flatten and expands #329
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | |
push: | |
branches: | |
- main | |
jobs: | |
# Pre-warm the cache to avoid conflicts | |
cache-warmup: | |
name: Prepare Cache | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Go Module Cache | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Download dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: go mod download | |
tests: | |
name: Test | |
needs: cache-warmup | |
runs-on: ubuntu-latest | |
timeout-minutes: 75 | |
strategy: | |
fail-fast: false | |
matrix: | |
parallel: [ 6 ] | |
index: [ 0, 1, 2, 3, 4, 5 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- 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: Go Module Cache | |
uses: actions/cache/restore@v3 | |
continue-on-error: true | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install Dependencies | |
run: go get ./... | |
shell: bash | |
- name: Build the Terraform provider from source | |
run: go build -ldflags="-s -w" -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: Pre-pull container images | |
run: | | |
docker pull octopusdeploy/octopusdeploy:latest | |
docker pull mcr.microsoft.com/mssql/server:2019-latest | |
- 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 45m -parallel 4 ./... -createSharedContainer=true | |
shell: bash | |
env: | |
LICENSE: ${{ secrets.OCTOPUS_SERVER_BASE64_LICENSE }} | |
GIT_USERNAME: x-access-token | |
OCTODISABLEOCTOCONTAINERLOGGING: true | |
OCTOTESTSKIPINIT: true | |
GOMAXPROCS: 4 | |
OCTOTESTVERSION: latest | |
OCTOTESTIMAGEURL: octopusdeploy/octopusdeploy | |
OCTOTESTRETRYCOUNT: 0 | |
- name: Upload test artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: junit-test-summary-${{ matrix.index }} | |
path: node-summary.xml | |
retention-days: 1 | |
tests-combine-summaries: | |
if: always() | |
name: Ensure Tests Pass | |
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@v4 | |
- 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" | |
- name: Upload test artifacts | |
uses: actions/upload-artifact@v4 | |
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 |