Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Merge pull request #42 from hashicorp/tsccr-auto-pinning/trusted/2023… #31

Merge pull request #42 from hashicorp/tsccr-auto-pinning/trusted/2023…

Merge pull request #42 from hashicorp/tsccr-auto-pinning/trusted/2023… #31

Workflow file for this run

name: hashicorp/waypoint-hzn/go-tests
on:
push:
branches:
- main
jobs:
check-vendor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- run: go mod tidy
- run: |
if ! git diff --exit-code; then
echo "Git directory has vendor changes"
exit 1
fi
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
cache: true
cache-dependency-path: go.sum
go-version-file: go.mod
- uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.50.0
args: --timeout 3m00s
skip-pkg-cache: true
skip-build-cache: true
dev-build:
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.go-version.outputs.go-version }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
- id: go-version
run: echo "go-version=$(cat ./.go-version)" >> "$GITHUB_OUTPUT"
- uses: hashicorp/[email protected]
with:
go_version: ${{ steps.go-version.outputs.go-version }}
os: linux
arch: amd64
reproducible: nope
# TODO: inquire about versioning
instructions: |-
mkdir -p dist
go build -o dist ./cmd/waypoint-hzn
go-test:
runs-on: ubuntu-latest
env:
TEST_RESULTS_DIR: "/tmp/test-results"
GO_TAGS: server
GOTESTSUM_RELEASE: 1.8.2
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Start Services
run: |-
docker compose -f .github/services/go-tests/docker-compose.yml up --detach --no-color --wait
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: './go.mod'
- name: Install gotestsum
run: |-
url=https://github.com/gotestyourself/gotestsum/releases/download
curl -sSL "${url}/v${GOTESTSUM_RELEASE}/gotestsum_${GOTESTSUM_RELEASE}_linux_amd64.tar.gz" | \
sudo tar -xz --overwrite -C /usr/local/bin gotestsum
- run: go mod download
- name: Waiting for Postgres to be ready
run: |-
for _ in $(seq 1 10);
do
nc -z localhost 5432 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for Postgres && exit 1
- name: go test
env:
PACKAGE_NAMES: ./...
POSTGRES_USER: postgres
POSTGRES_DB: waypoint_test
run: |-
mkdir -p "$TEST_RESULTS_DIR"
echo "Testing \"$PACKAGE_NAMES\""
gotestsum --format=short-verbose \
--junitfile "$TEST_RESULTS_DIR"/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
-cover -coverprofile=coverage.txt \
"$PACKAGE_NAMES"
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: test-results
path: "/tmp/test-results"
- name: Stop containers
if: always()
run: |-
docker compose -f .github/services/go-tests/docker-compose.yml down
permissions:
contents: read