Skip to content

Merge pull request #205 from go-faster/dependabot/go_modules/github.c… #2

Merge pull request #205 from go-faster/dependabot/go_modules/github.c…

Merge pull request #205 from go-faster/dependabot/go_modules/github.c… #2

Workflow file for this run

name: ci
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
flags: [""]
arch:
- amd64
runner:
- ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Get Go environment
id: go-env
shell: bash
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
# Build cache key prefix, using runner OS and arch.
- name: Compute cache prefix
id: cache-prefix
shell: bash
env:
RUNNER_PREFIX: ${{ runner.os }}-${{ runner.arch }}-go
ARCH_PREFIX: ${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
RACE_PREFIX: ${{ contains(matrix.flags, '-race') && '-race' || '' }}
run:
echo "cache_prefix=$RUNNER_PREFIX$ARCH_PREFIX$RACE_PREFIX" >> $GITHUB_ENV
- name: Set up cache
uses: actions/cache@v4
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ env.cache_prefix }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.cache_prefix }}-
- name: Run tests
env:
GOARCH: ${{ matrix.arch }}
GOFLAGS: ${{ matrix.flags }}
run: go test --timeout 15m ./...
# Keep benchmark up to date.
- name: Run benchmarks
if: ${{ !contains(matrix.flags, '-race') }}
env:
GOARCH: ${{ matrix.arch }}
GOFLAGS: ${{ matrix.flags }}
run: go test --timeout 15m --benchtime 3x --benchmem --bench "Benchmark" --run=$^. ./...