mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
119 lines
2.9 KiB
YAML
119 lines
2.9 KiB
YAML
name: test
|
|
on:
|
|
# run tests on push to master, but not when other branches are pushed to
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
# run tests for all pull requests
|
|
pull_request:
|
|
merge_group:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
latest_go: "1.24.x"
|
|
GO111MODULE: on
|
|
|
|
jobs:
|
|
test:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- job_name: Linux
|
|
go: 1.24.x
|
|
os: ubuntu-latest
|
|
check_changelog: true
|
|
|
|
- job_name: Linux (race)
|
|
go: 1.24.x
|
|
os: ubuntu-latest
|
|
test_opts: "-race"
|
|
|
|
- job_name: Linux
|
|
go: 1.23.x
|
|
os: ubuntu-latest
|
|
|
|
name: ${{ matrix.job_name }} Go ${{ matrix.go }}
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
env:
|
|
GOPROXY: https://proxy.golang.org
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up Go ${{ matrix.go }}
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
|
|
- name: Build with build.go
|
|
run: |
|
|
go run build.go --goos linux
|
|
go run build.go --goos windows
|
|
go run build.go --goos darwin
|
|
|
|
- name: Run local Tests
|
|
run: |
|
|
go test -cover ${{matrix.test_opts}} ./...
|
|
|
|
- name: Check changelog files with calens
|
|
run: |
|
|
echo "install calens"
|
|
go install github.com/restic/calens@latest
|
|
|
|
echo "check changelog files"
|
|
calens
|
|
if: matrix.check_changelog
|
|
|
|
lint:
|
|
name: lint
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
# allow annotating code in the PR
|
|
checks: write
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up Go ${{ env.latest_go }}
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version: ${{ env.latest_go }}
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
|
version: v1.64.8
|
|
args: --verbose --timeout 5m
|
|
|
|
# only run golangci-lint for pull requests, otherwise ALL hints get
|
|
# reported. We need to slowly address all issues until we can enable
|
|
# linting the master branch :)
|
|
if: github.event_name == 'pull_request'
|
|
|
|
- name: Check go.mod/go.sum
|
|
run: |
|
|
echo "check if go.mod and go.sum are up to date"
|
|
go mod tidy
|
|
git diff --exit-code go.mod go.sum
|
|
|
|
analyze:
|
|
name: Analyze results
|
|
needs: [test, lint]
|
|
if: always()
|
|
|
|
permissions: # no need to access code
|
|
contents: none
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Decide whether the needed jobs succeeded or failed
|
|
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
|
|
with:
|
|
jobs: ${{ toJSON(needs) }}
|