160 lines
4.5 KiB
YAML
160 lines
4.5 KiB
YAML
# ABOUTME: CI workflow for pull requests and main branch pushes
|
|
# ABOUTME: Tests on Linux, builds player + server on Linux/macOS/Windows
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
# Tell every `go` invocation across every job to drop the libopusfile parts of
|
|
# gopkg.in/hraban/opus.v2. Our code never calls the opus.Stream API, and the
|
|
# tag lets us skip installing libopusfile-dev / opusfile / mingw-w64-x86_64-opusfile
|
|
# on the runners and lets the released binary not depend on libopusfile0 at runtime.
|
|
env:
|
|
GOFLAGS: -tags=nolibopusfile
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libopus-dev libasound2-dev
|
|
|
|
- name: Run tests
|
|
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
|
|
|
|
- name: Upload coverage
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
file: ./coverage.out
|
|
fail_ci_if_error: false
|
|
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libopus-dev libasound2-dev shellcheck
|
|
|
|
- name: Shellcheck
|
|
run: shellcheck scripts/*.sh install-deps.sh
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
version: latest
|
|
args: --timeout=5m
|
|
|
|
build:
|
|
name: Build ${{ matrix.os }}/${{ matrix.arch }}
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: linux
|
|
arch: amd64
|
|
runner: ubuntu-latest
|
|
ext: ""
|
|
- os: linux
|
|
arch: arm64
|
|
runner: ubuntu-24.04-arm
|
|
ext: ""
|
|
- os: darwin
|
|
arch: arm64
|
|
runner: macos-latest
|
|
ext: ""
|
|
- os: windows
|
|
arch: amd64
|
|
runner: windows-latest
|
|
ext: ".exe"
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
|
|
# Linux dependencies
|
|
- name: Install dependencies (Linux)
|
|
if: matrix.os == 'linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libopus-dev libasound2-dev
|
|
|
|
# macOS dependencies
|
|
- name: Install dependencies (macOS)
|
|
if: matrix.os == 'darwin'
|
|
run: brew install opus
|
|
|
|
# Windows dependencies via MSYS2
|
|
- name: Install dependencies (Windows)
|
|
if: matrix.os == 'windows'
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: MINGW64
|
|
update: false
|
|
install: >-
|
|
mingw-w64-x86_64-gcc
|
|
mingw-w64-x86_64-pkg-config
|
|
mingw-w64-x86_64-opus
|
|
|
|
- name: Get version
|
|
id: version
|
|
shell: bash
|
|
run: echo "VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo dev)" >> $GITHUB_OUTPUT
|
|
|
|
# Linux + macOS build
|
|
- name: Build (Unix)
|
|
if: matrix.os != 'windows'
|
|
env:
|
|
CGO_ENABLED: "1"
|
|
run: |
|
|
LDFLAGS="-X github.com/Sendspin/sendspin-go/internal/version.Version=${{ steps.version.outputs.VERSION }}"
|
|
go build -ldflags "${LDFLAGS}" -o sendspin-player-${{ matrix.os }}-${{ matrix.arch }} .
|
|
go build -ldflags "${LDFLAGS}" -o sendspin-server-${{ matrix.os }}-${{ matrix.arch }} ./cmd/sendspin-server
|
|
|
|
# Windows build — needs MSYS2 MinGW on PATH for CGO
|
|
- name: Build (Windows)
|
|
if: matrix.os == 'windows'
|
|
shell: cmd
|
|
run: |
|
|
set PATH=D:\a\_temp\msys64\mingw64\bin;%PATH%
|
|
set CGO_ENABLED=1
|
|
set CC=gcc
|
|
set LDFLAGS=-X github.com/Sendspin/sendspin-go/internal/version.Version=${{ steps.version.outputs.VERSION }}
|
|
go build -ldflags "%LDFLAGS%" -o sendspin-player-windows-amd64.exe .
|
|
go build -ldflags "%LDFLAGS%" -o sendspin-server-windows-amd64.exe .\cmd\sendspin-server
|
|
|
|
- name: Upload player
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sendspin-player-${{ matrix.os }}-${{ matrix.arch }}
|
|
path: sendspin-player-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}
|
|
|
|
- name: Upload server
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: sendspin-server-${{ matrix.os }}-${{ matrix.arch }}
|
|
path: sendspin-server-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }}
|