Files
cunicu/.github/workflows/build.yaml
T
Steffen Vogel ee0e60df68 make project reuse compliant
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2023-05-26 23:25:41 +02:00

194 lines
5.5 KiB
YAML

# SPDX-FileCopyrightText: 2023 Steffen Vogel <post@steffenvogel.de>
# SPDX-License-Identifier: Apache-2.0
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json
---
name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
name: Build for ${{ matrix.target_os }} on ${{ matrix.target_arch }}${{ matrix.target_arch == 'arm' && format('-v{0}', matrix.arm) || ''}}
runs-on: ${{ matrix.runner || 'ubuntu-22.04' }}
strategy:
fail-fast: false
matrix:
include:
- target_os: linux
target_arch: amd64
host_os: linux
host_arch: amd64
runner: ubuntu-latest
- target_os: linux
target_arch: arm64
host_os: linux
host_arch: amd64
runner: ubuntu-latest
- target_os: linux
target_arch: arm
host_os: linux
host_arch: amd64
arm: "7"
runner: ubuntu-latest
# TODO: FreeBSD builds require cgo and FreeBSD
# system headers.
# - target_os: freebsd
# target_arch: amd64
# host_os: linux
# host_arch: amd64
# runner: ubuntu-latest
# - target_os: freebsd
# target_arch: arm64
# host_os: linux
# host_arch: amd64
# runner: ubuntu-latest
# - target_os: freebsd
# target_arch: arm
# host_os: linux
# host_arch: amd64
# arm: "7"
# runner: ubuntu-latest
- target_os: darwin
target_arch: arm64
host_os: darwin
host_arch: amd64
runner: macos-latest
- target_os: darwin
target_arch: amd64
host_os: darwin
host_arch: amd64
runner: macos-latest
- target_os: windows
target_arch: arm64
host_os: windows
host_arch: amd64
runner: windows-latest
- target_os: windows
target_arch: amd64
host_os: windows
host_arch: amd64
runner: windows-latest
- target_os: linux
target_arch: mips
host_os: linux
host_arch: amd64
mips: softfloat
runner: ubuntu-latest
- target_os: linux
target_arch: mips
host_os: linux
host_arch: amd64
mips: hardfloat
runner: ubuntu-latest
env:
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOARM: ${{ matrix.arm || '' }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
if: ${{ matrix.host_os == 'linux' }}
run: sudo apt-get install -y
coturn
protobuf-compiler
make
libpcap-dev
- name: Install dependencies
if: ${{ matrix.host_os == 'darwin' }}
run: brew install
protobuf
make
libpcap
- name: Install dependencies
if: ${{ matrix.host_os == 'windows' }}
run: choco install
protoc
make
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- name: Install build and test dependencies
env:
GOOS: ${{ matrix.host_os }}
GOARCH: ${{ matrix.host_arch }}
run: make install-deps
- name: Run cunīcu build
run: make cunicu
- name: Lint
if: ${{ matrix.host_os != 'windows' }}
run: make lint LINT_OPTS=--timeout=15m
- name: Run tests
if: ${{ matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os != 'windows' }}
run: sudo --preserve-env env "PATH=$PATH" make tests
env:
# Pass token via environment variable to avoid GitHub API rate-limit
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests for Windows # which has no sudo
if: ${{ matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os == 'windows' }}
run: make tests GINKGO_EXTRA_OPTS="--label-filter=!broken-on-windows"
- name: Run end-to-end tests
if: ${{ matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os == 'linux' }}
run: sudo --preserve-env env "PATH=$PATH" make tests-e2e
- name: Upload logs an packet captures as artifacts
if: ${{ always() && matrix.target_arch == matrix.host_arch && matrix.target_os == matrix.host_os && matrix.host_os == 'linux' }}
uses: actions/upload-artifact@v3
with:
name: test-logs-${{ matrix.target_os }}-${{ matrix.target_arch }}
path: test/e2e/logs/
- name: Create merged coverage profile
if: ${{ matrix.target_os == 'linux' && matrix.target_arch == 'amd64' }}
run: |
make coverprofile_merged.out
- name: Report test coverage to Codacy
if: ${{ matrix.target_os == 'linux' && matrix.target_arch == 'amd64' }}
uses: codacy/codacy-coverage-reporter-action@v1
env:
CODACY_REPORTER_TMP_FOLDER: .codacy
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverprofile_merged.out
force-coverage-parser: go
- name: Report test coverage to Codecov
if: ${{ matrix.target_os == 'linux' && matrix.target_arch == 'amd64' }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverprofile_merged.out