Skip to content

Merge pull request #562 from hashicorp/dependabot/github_actions/acti… #430

Merge pull request #562 from hashicorp/dependabot/github_actions/acti…

Merge pull request #562 from hashicorp/dependabot/github_actions/acti… #430

Workflow file for this run

name: go-getter
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
TEST_RESULTS_PATH: /tmp/test-results
jobs:
# Linux basic validation that runs on both PRs and pushes (safe operations)
linux-basic-validation:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- "1.24"
- "1.25"
steps:
- name: Setup go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.0.0
- name: Setup cache for go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go-version }}-
${{ runner.os }}-go-
# Check go fmt output because it does not report non-zero when there are fmt changes
- name: Run gofmt
run: |
go fmt ./...
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- name: Build all packages
run: go build ./...
- name: Run unit tests (without cloud integration)
run: go test -short -v ./...
# Windows basic validation that runs on both PRs and pushes (safe operations)
windows-basic-validation:
runs-on: windows-latest
strategy:
matrix:
go-version:
- "1.24"
- "1.25"
steps:
- name: Run git config # Windows-only
run: git config --global core.autocrlf false
- name: Setup go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.0.0
- name: Setup cache for go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go-version }}-
${{ runner.os }}-go-
# Check go fmt output because it does not report non-zero when there are fmt changes
- name: Run gofmt
shell: bash
run: |
go fmt ./...
files=$(go fmt ./...)
if [ -n "$files" ]; then
echo "The following file(s) do not conform to go fmt:"
echo "$files"
exit 1
fi
- name: Build all packages
run: go build ./...
- name: Run unit tests (without cloud integration)
run: go test -short -v ./...
# 32-bit architecture compatibility test to catch overflow issues
architecture-compatibility:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- "1.24"
- "1.25"
arch:
- "386" # 32-bit x86
- "arm" # 32-bit ARM
steps:
- name: Setup go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.0.0
- name: Setup cache for go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ matrix.arch }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go-version }}-${{ matrix.arch }}-
${{ runner.os }}-go${{ matrix.go-version }}-
${{ runner.os }}-go-
- name: Build for ${{ matrix.arch }}
env:
GOOS: linux
GOARCH: ${{ matrix.arch }}
run: go build ./...
- name: Test for ${{ matrix.arch }} (build only - no execution)
env:
GOOS: linux
GOARCH: ${{ matrix.arch }}
run: |
# Test compile each package individually to avoid binary naming conflicts
for pkg in $(go list ./...); do
echo "Testing compilation for $pkg on ${{ matrix.arch }}"
go test -c "$pkg"
done
# Linter runs on both PRs and pushes (safe operation)
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.0.0
- name: Setup go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: "1.25" # Use latest for linting
- name: Setup cache for go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/.cache/golangci-lint
key: ${{ runner.os }}-lint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-lint-
- name: Lint code
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
- name: Check for modern Go patterns
run: go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test ./...
# Full integration tests with cloud resources (only on push to protected branches)
linux-integration-tests:
runs-on: ubuntu-latest
if: github.event_name == 'push'
strategy:
matrix:
go-version:
- "1.24"
- "1.25"
permissions:
id-token: write
contents: read
steps:
- name: Setup go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.0.0
- name: Create test directory
run: |
mkdir -p ${{ env.TEST_RESULTS_PATH }}
- name: Setup cache for go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go-version }}-
${{ runner.os }}-go-
- name: Install gotestsum
run: go install gotest.tools/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::388664967494:role/hc-go-getter-test
role-session-name: ${{ github.run_id }}
audience: https://github.com/hashicorp
- name: 'Authenticate to Google Cloud'
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
service_account: hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
audience: https://github.com/hashicorp
- name: Run go tests
run: |
PACKAGE_NAMES=$(go list ./...)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -coverprofile=linux_cov.part $PACKAGE_NAMES
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: linux-test-results-${{ matrix.go-version }}
path: linux_cov.part
windows-integration-tests:
runs-on: windows-latest
if: github.event_name == 'push'
strategy:
matrix:
go-version:
- "1.24"
- "1.25"
permissions:
id-token: write
contents: read
steps:
- name: Run git config #Windows-only
run: git config --global core.autocrlf false
- name: Setup Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.0.0
- name: Setup cache for go modules
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go${{ matrix.go-version }}-
${{ runner.os }}-go-
- name: Install gotestsum
shell: bash
run: go install gotest.tools/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 # v5.0.0
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::388664967494:role/hc-go-getter-test
role-session-name: ${{ github.run_id }}
audience: https://github.com/hashicorp
- name: 'Authenticate to Google Cloud'
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/github-hc-go-getter-test'
service_account: hc-go-getter-test@hc-e56c0f7c21c448d2be9e7696073.iam.gserviceaccount.com
audience: https://github.com/hashicorp
- name: Run go tests
shell: bash
run: |
PACKAGE_NAMES=$(go list ./...)
echo "Running $(echo $PACKAGE_NAMES | wc -w) packages"
echo $PACKAGE_NAMES
gotestsum --format=short-verbose --junitfile $TEST_RESULTS_PATH/go-getter/gotestsum-report.xml -- -p 2 -cover -race -coverprofile=win_cov.part $PACKAGE_NAMES
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: windows-test-results-${{ matrix.go-version }}
path: win_cov.part