2021-02-11 07:41:17 +08:00
|
|
|
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:
|
2024-02-11 00:45:20 +08:00
|
|
|
# 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.
|
2024-02-11 00:18:50 +08:00
|
|
|
name: Run tests (${{ matrix.os }}, ${{ matrix.go-version }})
|
2021-02-11 07:41:17 +08:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu, macos, windows]
|
2024-02-11 00:45:20 +08:00
|
|
|
go-version: [1.22.x]
|
|
|
|
go-version-is: [new]
|
2022-08-08 19:43:29 +08:00
|
|
|
include:
|
|
|
|
# Test old supported Go version
|
|
|
|
- os: ubuntu
|
2024-02-11 00:45:20 +08:00
|
|
|
go-version: 1.21.x
|
|
|
|
go-version-is: [old]
|
2021-02-11 07:41:17 +08:00
|
|
|
env:
|
|
|
|
ELVISH_TEST_TIME_SCALE: 20
|
|
|
|
runs-on: ${{ matrix.os }}-latest
|
|
|
|
steps:
|
2022-03-20 22:48:28 +08:00
|
|
|
# autocrlf is problematic for fuzz testdata.
|
|
|
|
- name: Turn off autocrlf
|
|
|
|
if: matrix.os == 'windows'
|
|
|
|
run: git config --global core.autocrlf false
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Checkout code
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Set up Go
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/setup-go@v5
|
2021-02-11 07:41:17 +08:00
|
|
|
with:
|
|
|
|
go-version: ${{ matrix.go-version }}
|
|
|
|
- name: Test with race detection
|
2021-08-21 23:51:19 +08:00
|
|
|
run: |
|
|
|
|
go test -race ./...
|
|
|
|
cd website; go test -race ./...
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Generate test coverage
|
2024-02-11 00:45:20 +08:00
|
|
|
if: matrix.go-version-is == 'new'
|
2021-02-11 07:41:17 +08:00
|
|
|
run: go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
|
|
|
|
- name: Save test coverage
|
2024-02-11 00:45:20 +08:00
|
|
|
if: matrix.go-version-is == 'new'
|
|
|
|
uses: actions/upload-artifact@v4
|
2021-02-11 07:41:17 +08:00
|
|
|
with:
|
2024-01-11 23:44:50 +08:00
|
|
|
name: cover-${{ matrix.os == 'ubuntu' && 'linux' || matrix.os }}
|
2021-02-11 07:41:17 +08:00
|
|
|
path: cover
|
|
|
|
|
2021-08-02 04:41:18 +08:00
|
|
|
# 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
|
2021-08-02 04:58:00 +08:00
|
|
|
steps:
|
2021-08-02 04:41:18 +08:00
|
|
|
- name: Checkout code
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-08-02 04:41:18 +08:00
|
|
|
- name: Set up Go
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/setup-go@v5
|
2021-08-02 04:41:18 +08:00
|
|
|
with:
|
2024-02-11 00:45:20 +08:00
|
|
|
go-version: 1.22.x
|
2021-08-02 04:41:18 +08:00
|
|
|
- name: Run benchmarks
|
2021-08-07 06:49:50 +08:00
|
|
|
run: go test -bench=. -run='^$' ./...
|
2021-08-02 04:41:18 +08:00
|
|
|
|
2021-02-11 07:41:17 +08:00
|
|
|
upload-coverage:
|
|
|
|
name: Upload test coverage
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-02-11 08:35:49 +08:00
|
|
|
ostype: [linux, macos, windows]
|
2021-02-11 07:41:17 +08:00
|
|
|
needs: test
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Download test coverage
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/download-artifact@v4
|
2021-02-11 07:41:17 +08:00
|
|
|
with:
|
2021-02-11 08:35:49 +08:00
|
|
|
name: cover-${{ matrix.ostype }}
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Upload coverage to codecov
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: codecov/codecov-action@v3
|
2021-02-11 07:41:17 +08:00
|
|
|
with:
|
|
|
|
files: ./cover
|
2021-02-11 08:35:49 +08:00
|
|
|
flags: ${{ matrix.ostype }}
|
2021-02-11 07:41:17 +08:00
|
|
|
|
2022-12-30 07:16:16 +08:00
|
|
|
checks:
|
|
|
|
name: Run checks
|
2021-02-11 07:41:17 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Set up Go
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/setup-go@v5
|
2021-07-08 07:17:55 +08:00
|
|
|
with:
|
2024-02-11 00:45:20 +08:00
|
|
|
go-version: 1.22.x
|
2022-12-30 07:33:16 +08:00
|
|
|
- name: Set up Python
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/setup-python@v5
|
2022-12-30 07:33:16 +08:00
|
|
|
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
|
2023-08-21 12:33:58 +08:00
|
|
|
# Keep the versions of staticcheck and codespell in sync with CONTRIBUTING.md
|
2023-12-27 04:47:52 +08:00
|
|
|
go install honnef.co/go/tools/cmd/staticcheck@v0.4.6
|
|
|
|
pip install --user codespell==2.2.6
|
2022-12-30 07:16:16 +08:00
|
|
|
- name: Run checks
|
|
|
|
run: make all-checks
|
2022-02-21 06:40:30 +08:00
|
|
|
|
2021-11-30 04:06:12 +08:00
|
|
|
check-rellinks:
|
2022-12-30 07:16:16 +08:00
|
|
|
name: Check relative links in website
|
2021-11-30 04:06:12 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/checkout@v4
|
2022-11-08 22:11:50 +08:00
|
|
|
- name: Set up Go
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/setup-go@v5
|
2022-11-08 22:11:50 +08:00
|
|
|
with:
|
2024-02-11 00:45:20 +08:00
|
|
|
go-version: 1.22.x
|
2022-11-08 22:11:50 +08:00
|
|
|
- name: Set up Python
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/setup-python@v5
|
2022-11-23 08:02:59 +08:00
|
|
|
with:
|
|
|
|
python-version: '3.x'
|
2022-11-08 22:11:50 +08:00
|
|
|
- name: Install Python dependency
|
|
|
|
run: pip3 install beautifulsoup4
|
2021-11-30 04:06:12 +08:00
|
|
|
- name: Check relative links
|
|
|
|
run: make -C website check-rellinks
|
|
|
|
|
2021-10-02 05:24:51 +08:00
|
|
|
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
|
2024-02-11 00:45:20 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-10-02 05:24:51 +08:00
|
|
|
- name: Generate LSIF data
|
|
|
|
run: lsif-go
|
|
|
|
- name: Upload LSIF data
|
|
|
|
run: src lsif upload -github-token=${{ secrets.GITHUB_TOKEN }} -ignore-upload-failure
|