108 lines
2.5 KiB
YAML
108 lines
2.5 KiB
YAML
name: Test, Lint
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go-version: [1.21]
|
|
|
|
steps:
|
|
- name: Setup Go ${{ matrix.go-version }}
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.go-version }}-go-
|
|
|
|
- name: Run tests
|
|
run: make test
|
|
|
|
- uses: codecov/codecov-action@v2
|
|
with:
|
|
file: coverage.out
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go-version: [1.21]
|
|
|
|
steps:
|
|
- name: Setup Go ${{ matrix.go-version }}
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.go-version }}-go-
|
|
|
|
- name: Run linter
|
|
uses: golangci/golangci-lint-action@v3
|
|
with:
|
|
version: latest
|
|
skip-cache: true
|
|
args: --timeout=5m
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '1.21'
|
|
- name: Build
|
|
run: go build -ldflags "-X github.com/FreifunkBremen/yanic/cmd.VERSION=$(git describe --tags)" -v
|
|
env:
|
|
CGO_ENABLED: 0
|
|
- name: Archive build artifacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: build
|
|
path: yanic
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs:
|
|
- lint
|
|
- test
|
|
- build
|
|
steps:
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v2
|
|
with:
|
|
name: build
|
|
path: build/
|
|
- name: Upload binaries to release
|
|
uses: svenstaro/upload-release-action@v2
|
|
with:
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
file: build/yanic
|
|
asset_name: yanic.bin
|
|
tag: ${{ github.ref }}
|
|
overwrite: true
|