go #119
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: go | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 1.20.x | |
- name: go.mod tidy | |
run: go mod tidy && git diff --exit-code | |
- name: license header | |
run: go run github.com/elastic/go-licenser@v0.4.1 -d | |
- name: cross-compile | |
run: .ci/scripts/check-cross-compile.sh | |
test: | |
needs: check | |
strategy: | |
matrix: | |
go: | |
- 1.20.x | |
- 1.18.x | |
os: | |
- macos-11 | |
- macos-12 | |
- macos-13 | |
- windows-2019 | |
- windows-2022 | |
- ubuntu-20.04 | |
- ubuntu-22.04 | |
cgo: | |
- cgo | |
- nocgo | |
exclude: | |
# Exclude cgo testing for platforms that don't use CGO. | |
- {cgo: cgo, os: windows-2019} | |
- {cgo: cgo, os: windows-2022} | |
- {cgo: cgo, os: ubuntu-20.04} | |
- {cgo: cgo, os: ubuntu-22.04} | |
# Limit the OS variants tested with the earliest supported Go version (save resources). | |
- {go: 1.18.10, os: macos-11} | |
- {go: 1.18.10, os: macos-12} | |
- {go: 1.18.10, os: windows-2019} | |
- {go: 1.18.10, os: ubuntu-22.04} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v4 | |
id: setup_go | |
with: | |
go-version: ${{ matrix.go }} | |
- name: Set GO_VERSION | |
run: echo "GO_VERSION=${{ steps.setup_go.outputs.go-version }}" >> $GITHUB_ENV | |
- name: Set CGO_ENABLED=1 | |
if: ${{ matrix.cgo }} == "cgo" | |
run: echo "CGO_ENABLED=1" >> $GITHUB_ENV | |
- name: Set CGO_ENABLED=0 | |
if: ${{ matrix.cgo }} == "nocgo" | |
run: echo "CGO_ENABLED=0" >> $GITHUB_ENV | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
if: github.event_name == 'pull_request' | |
with: | |
version: latest | |
only-new-issues: true | |
args: --timeout=5m | |
# Don't cache or restore ~/go/pkg. It conflicts with caching from setup-go@v4. | |
skip-pkg-cache: true | |
- name: Test | |
if: runner.os != 'Windows' | |
run: .ci/scripts/test.sh | |
- name: Test | |
if: runner.os == 'Windows' | |
run: .ci/scripts/test.bat | |
test-freebsd: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test | |
id: test | |
uses: vmactions/freebsd-vm@v1 | |
with: | |
usesh: true | |
prepare: | | |
pkg install -y curl | |
curl -sL -o /usr/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-freebsd-amd64 | |
chmod +x /usr/bin/gvm | |
eval "$(gvm 1.22.1)" | |
go version | |
run: | | |
pwd | |
ls -lah | |
whoami | |
env | |
freebsd-version | |
.ci/scripts/test.sh |