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:
|
|
|
|
name: Run tests
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu, macos, windows]
|
2023-03-03 07:06:26 +08:00
|
|
|
go-version: [1.20.x]
|
2022-08-08 19:43:29 +08:00
|
|
|
include:
|
|
|
|
# Test old supported Go version
|
|
|
|
- os: ubuntu
|
2023-03-03 07:06:26 +08:00
|
|
|
go-version: 1.19.x
|
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
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Set up cache
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-11 07:41:17 +08:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/go/pkg/mod
|
|
|
|
~/.cache/go-build
|
|
|
|
~/Library/Caches/go-build
|
|
|
|
~/AppData/Local/go-build
|
|
|
|
key: test/${{ matrix.os }}/${{ matrix.go-version }}/${{ hashFiles('go.sum') }}/${{ github.sha }}
|
|
|
|
restore-keys: test/${{ matrix.os }}/${{ matrix.go-version }}/${{ hashFiles('go.sum') }}/
|
|
|
|
- name: Set up Go
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/setup-go@v3
|
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 08:35:49 +08:00
|
|
|
- name: Set ostype to ${{ matrix.os }}
|
|
|
|
run: echo ostype=${{ matrix.os }} >> $GITHUB_ENV
|
|
|
|
- name: Set ostype to linux
|
|
|
|
if: matrix.os == 'ubuntu'
|
|
|
|
run: echo ostype=linux >> $GITHUB_ENV
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Generate test coverage
|
2023-03-03 07:06:26 +08:00
|
|
|
if: matrix.go-version == '1.20.x'
|
2021-02-11 07:41:17 +08:00
|
|
|
run: go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
|
|
|
|
- name: Save test coverage
|
2023-03-03 07:06:26 +08:00
|
|
|
if: matrix.go-version == '1.20.x'
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-02-11 07:41:17 +08:00
|
|
|
with:
|
2021-02-11 08:35:49 +08:00
|
|
|
name: cover-${{ env.ostype }}
|
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
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-08-02 04:41:18 +08:00
|
|
|
- name: Set up Go
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/setup-go@v3
|
2021-08-02 04:41:18 +08:00
|
|
|
with:
|
2023-03-03 07:06:26 +08:00
|
|
|
go-version: 1.20.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
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Download test coverage
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/download-artifact@v3
|
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
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/checkout@v3
|
2021-02-11 07:41:17 +08:00
|
|
|
- name: Set up Go
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/setup-go@v3
|
2021-07-08 07:17:55 +08:00
|
|
|
with:
|
2023-03-03 07:06:26 +08:00
|
|
|
go-version: 1.20.x
|
2022-12-30 07:33:16 +08:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
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-02-27 04:47:25 +08:00
|
|
|
go install honnef.co/go/tools/cmd/staticcheck@v0.4.2
|
2022-12-30 07:33:16 +08:00
|
|
|
pip install --user codespell==2.2.1
|
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
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/checkout@v3
|
2022-11-08 22:11:50 +08:00
|
|
|
- name: Set up Go
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/setup-go@v3
|
2022-11-08 22:11:50 +08:00
|
|
|
with:
|
2023-03-03 07:06:26 +08:00
|
|
|
go-version: 1.20.x
|
2022-11-08 22:11:50 +08:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v4
|
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
|
2022-11-23 08:02:59 +08:00
|
|
|
uses: actions/checkout@v3
|
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
|