Skip to content

Merge pull request #165 from hashicorp/anita/codeowners #82

Merge pull request #165 from hashicorp/anita/codeowners

Merge pull request #165 from hashicorp/anita/codeowners #82

Workflow file for this run

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
name: Lint and Test
on: ["push", "workflow_dispatch"]
permissions: {}
jobs:
lint-actions:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Lint workflow
uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest
go-version:
runs-on: ubuntu-latest
needs:
- lint-actions
outputs:
go-version: ${{ steps.go-version.outputs.go-version }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Determine Go version
id: go-version
# We use .go-version as our source of truth for current Go
# version, because "goenv" can react to it automatically.
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
lint:
runs-on: ubuntu-latest
needs:
- go-version
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.go-version.outputs.go-version }}
- name: Go CI lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with:
args: "--verbose --enable gofmt"
only-new-issues: false
skip-pkg-cache: true
skip-build-cache: true
unit-tests:
runs-on: ubuntu-latest
needs:
- go-version
env:
TEST_RESULTS_DIR: /tmp/unit-test-results
GOTESTSUM_VERSION: 1.9.0
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.go-version.outputs.go-version }}
- name: Install gotestsum
shell: bash
run: |
url=https://github.com/gotestyourself/gotestsum/releases/download
curl -sSL "${url}/v${{ env.GOTESTSUM_VERSION }}/gotestsum_${{ env.GOTESTSUM_VERSION }}_linux_amd64.tar.gz" | \
tar -xz --overwrite -C /usr/local/bin gotestsum
- name: Test
run: |
mkdir -p "$TEST_RESULTS_DIR/json"
gotestsum \
--format=short-verbose \
--jsonfile "$TEST_RESULTS_DIR/json/go-test-race.log" \
--junitfile "$TEST_RESULTS_DIR/gotestsum-report.xml" \
-- -race ./...
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: unit-test-results
path: ${{ env.TEST_RESULTS_DIR }}
integration-tests:
name: Integration test - Consul ${{ matrix.consul-version }}
runs-on: ubuntu-latest
needs:
- go-version
env:
TEST_RESULTS_DIR: /tmp/integration-test-results
strategy:
fail-fast: false
matrix:
consul-version:
- 1.15.1
- 1.14.5
- 1.13.7
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ needs.go-version.outputs.go-version }}
- name: Install Consul ${{ matrix.consul-version }}
shell: bash
run: |
CONSUL_VERSION="${{ matrix.consul-version }}"
FILENAME="consul_${CONSUL_VERSION}_linux_amd64.zip"
curl -sSLO "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/${FILENAME}" && \
unzip "${FILENAME}" -d /usr/local/bin && \
rm "${FILENAME}"
consul version
- name: Integration tests
run: |
mkdir -p "$TEST_RESULTS_DIR/${{ matrix.consul-version }}"
./scripts/integration.sh "$TEST_RESULTS_DIR/${{ matrix.consul-version }}" \
| tee "$TEST_RESULTS_DIR/${{ matrix.consul-version }}/integration-${{ matrix.consul-version }}.log"
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: "integration-test-results-${{ matrix.consul-version }}"
path: ${{ env.TEST_RESULTS_DIR }}/${{ matrix.consul-version }}