elvish/.github/workflows/ci.yml
Qi Xiao ea88e07e31 Various CI config updates.
GitHub Actions:

- Fix skipping of test coverage on old Go; GitHub Actions doesn't have true
  booleans (https://github.com/actions/runner/issues/1483)

- Update workflow versions.

Cirrus:

- Download Go toolchain from go.dev on all BSD platforms.

Both:

- Bump Go to 1.22 (with one GitHub Actions job still running Go 1.21).
2024-02-10 17:34:27 +00:00

148 lines
4.2 KiB
YAML

name: CI
on:
push:
pull_request:
defaults:
run:
# PowerShell's behavior for -flag=value is undesirable, so run all commands with bash.
shell: bash
jobs:
test:
# The default name will include the "go-version-is" parameter, whcih is
# derived from go-version and redundant, so we supply an explicit templated
# name.
name: Run tests (${{ matrix.os }}, ${{ matrix.go-version }})
strategy:
matrix:
os: [ubuntu, macos, windows]
go-version: [1.22.x]
go-version-is: [new]
include:
# Test old supported Go version
- os: ubuntu
go-version: 1.21.x
go-version-is: [old]
env:
ELVISH_TEST_TIME_SCALE: 20
runs-on: ${{ matrix.os }}-latest
steps:
# autocrlf is problematic for fuzz testdata.
- name: Turn off autocrlf
if: matrix.os == 'windows'
run: git config --global core.autocrlf false
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Test with race detection
run: |
go test -race ./...
cd website; go test -race ./...
- name: Generate test coverage
if: matrix.go-version-is == 'new'
run: go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
- name: Save test coverage
if: matrix.go-version-is == 'new'
uses: actions/upload-artifact@v4
with:
name: cover-${{ matrix.os == 'ubuntu' && 'linux' || matrix.os }}
path: cover
# The purpose of running benchmarks in GitHub Actions is primarily to ensure
# that the benchmark code runs and doesn't crash. GitHub Action runners don't
# have a stable enough environment to produce reliable benchmark numbers.
benchmark:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Run benchmarks
run: go test -bench=. -run='^$' ./...
upload-coverage:
name: Upload test coverage
strategy:
matrix:
ostype: [linux, macos, windows]
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download test coverage
uses: actions/download-artifact@v4
with:
name: cover-${{ matrix.ostype }}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
files: ./cover
flags: ${{ matrix.ostype }}
checks:
name: Run checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install tools
run: |
go install golang.org/x/tools/cmd/stringer@latest
go install golang.org/x/tools/cmd/goimports@latest
# Keep the versions of staticcheck and codespell in sync with CONTRIBUTING.md
go install honnef.co/go/tools/cmd/staticcheck@v0.4.6
pip install --user codespell==2.2.6
- name: Run checks
run: make all-checks
check-rellinks:
name: Check relative links in website
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Python dependency
run: pip3 install beautifulsoup4
- name: Check relative links
run: make -C website check-rellinks
lsif:
name: Upload SourceGraph LSIF
if: github.repository == 'elves/elvish' && github.event_name == 'push'
runs-on: ubuntu-latest
container: sourcegraph/lsif-go:latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate LSIF data
run: lsif-go
- name: Upload LSIF data
run: src lsif upload -github-token=${{ secrets.GITHUB_TOKEN }} -ignore-upload-failure