Skip to content

Test the CLI through cmd.Run, capturing the (stdout, stderr, exit code) triple #353

Test the CLI through cmd.Run, capturing the (stdout, stderr, exit code) triple

Test the CLI through cmd.Run, capturing the (stdout, stderr, exit code) triple #353

Workflow file for this run

name: Go Test
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: go-version
run: |
echo "go-version=$(cat .tool-versions | grep golang | cut -d ' ' -f 2)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: ${{ steps.go-version.outputs.go-version }}
- name: Download dependencies
run: go mod download
- name: Check formatting
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "The following files are not gofmt-ed:"
echo "$unformatted"
exit 1
fi
- name: Vet
run: go vet ./...
- name: Verify go.mod and go.sum are tidy
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum
- name: Run tests
run: go test -race ./...