Skip to content

Commit

Permalink
Merge pull request #379 from hashicorp/migrate-to-gha
Browse files Browse the repository at this point in the history
Migrate to GHA
  • Loading branch information
claire-labry authored Oct 26, 2022
2 parents f7a8c48 + 2daac52 commit 7220a3d
Show file tree
Hide file tree
Showing 7 changed files with 947 additions and 284 deletions.
176 changes: 0 additions & 176 deletions .circleci/config.yml

This file was deleted.

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

on: [push]

env:
TEST_RESULTS_PATH: /tmp/test-results

jobs:

linux-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- 1.17
- 1.18
- 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: Setup cache for go modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download

# 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: Install gotestsum
run: go install gotest.tools/[email protected]

- 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/[email protected]'
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@v3
with:
name: linux test results
path: linux_cov.part

windows-tests:
runs-on: windows-latest
strategy:
matrix:
go-version:
- 1.17
- 1.18
- 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: Setup cache for go modules
uses: actions/cache@v3
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download

- name: Install gotestsum
shell: bash
run: go install gotest.tools/[email protected]

- 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/[email protected]'
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@v3
with:
name: windows test results
path: win_cov.part
Loading

0 comments on commit 7220a3d

Please sign in to comment.