Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 0 additions & 176 deletions .circleci/config.yml

This file was deleted.

162 changes: 162 additions & 0 deletions .github/workflows/go-getter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: go-getter

on: [push]

env:
TEST_RESULTS_PATH: /tmp/test-results

jobs:

linux-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- 1.19
permissions:
id-token: write
contents: read
steps:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3

- name: Create test directory
run: |
mkdir -p ${{ env.TEST_RESULTS_PATH }}

- name: Download go modules
run: go mod download

- name: Cache / restore go modules
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ 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

# Install gotestsum with go get for 1.14.15 & 1.15.3; otherwise default to go install
- name: Install gotestsum
run: |
if [ ${{ matrix.go-version }} != 1.19 ]; then
go get gotest.tools/gotestsum@v1.8.2; else
go install gotest.tools/gotestsum@v1.8.2
fi

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# 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@v0.4.0'
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/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@v3
with:
name: linux test results
path: linux_cov.part

windows-tests:
runs-on: windows-latest
strategy:
matrix:
go-version:
- 1.19
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@v3
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3

- name: Download go modules
run: go mod download

- name: Setup cache for go modules
uses: actions/cache@v3
with:
path: |
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

# Install gotestsum with go get for 1.14.15 & 1.15.3; otherwise default to go install
- name: Install gotestsum
shell: bash
run: |
if [ ${{ matrix.go-version }} != 1.19 ]; then
go get gotest.tools/gotestsum@v1.8.2; else
go install gotest.tools/gotestsum@v1.8.2
fi

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# 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@v0.4.0'
with:
workload_identity_provider: 'projects/328212837253/locations/global/workloadIdentityPools/hc-go-getter-test/providers/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@v3
with:
name: windows test results
path: win_cov.part
Loading