Skip to content

build

build #395

Workflow file for this run

name: build
on:
pull_request:
branches:
- main
- v*
push:
branches:
- main
- v*
tags:
- v*
repository_dispatch:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: Linux - Go 1.13
go: '1.13'
build: yes
test: yes
lint: no
coverage: no
- name: Linux - Go 1.x
go: '1.x'
build: yes
test: yes
lint: no
coverage: no
- name: Linters
go: '1.x'
build: no
test: no
lint: yes
coverage: no
- name: Coverage
go: '1.x'
build: yes
test: yes
lint: no
coverage: yes
name: ${{ matrix.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get -y install g++ pkg-config scons ragel gengetopt \
libuv1-dev libunwind-dev libspeexdsp-dev libsox-dev libpulse-dev \
libtool intltool autoconf automake make cmake meson
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Build Roc
run: |
git clone https://github.com/roc-streaming/roc-toolkit.git /tmp/roc
scons -C /tmp/roc -Q --build-3rdparty=openfec
sudo scons -C /tmp/roc -Q --build-3rdparty=openfec install
- name: Build bindings
if: ${{ matrix.build == 'yes' }}
run: |
cd roc
go list -f {{.IgnoredGoFiles}} .
go get -v .
- name: Run tests
if: ${{ matrix.test == 'yes' }}
run: |
cd roc
go build && go test -count=1 -covermode=count -coverprofile=coverage.out
- name: Run tests under race detector
if: ${{ matrix.test == 'yes' }}
run: |
cd roc
go build && go test -count=1 -race
- name: Run tests with cgocheck
if: ${{ matrix.test == 'yes' }}
run: |
cd roc
GOEXPERIMENT=cgocheck2 go build && go test -count=1 .
- name: Run linters
if: ${{ matrix.lint == 'yes' }}
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
working-directory: roc
- name: Prepare coverage report
if: ${{ matrix.coverage == 'yes' }}
uses: jandelgado/[email protected]
with:
working-directory: roc
- name: Send coverage report
if: ${{ matrix.coverage == 'yes' }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: roc/coverage.lcov
macos:
runs-on: macos-latest
name: macOS
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install system dependencies
run: |
brew install scons ragel gengetopt libuv speexdsp sox cpputest
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: '1.x'
- name: Build Roc
run: |
git clone https://github.com/roc-streaming/roc-toolkit.git /tmp/roc
scons -C /tmp/roc -Q --build-3rdparty=openfec
sudo scons -C /tmp/roc -Q --build-3rdparty=openfec install
- name: Build bindings
run: |
cd roc
go list -f {{.IgnoredGoFiles}} .
go get -v .
- name: Run tests
run: |
cd roc
go build && go test -count=1
- name: Run tests under race detector
run: |
cd roc
go build && go test -count=1 -race
- name: Run tests with cgocheck
run: |
cd roc
GOEXPERIMENT=cgocheck2 go build && go test -count=1 .
formatting:
runs-on: ubuntu-latest
name: Code formatting
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run gofmt
uses: Jerome1337/[email protected]
with:
gofmt-path: './roc'
gofmt-flags: '-s -l -d'
generation:
runs-on: ubuntu-latest
name: Code generation
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.x
- name: Install stringer
run: go install golang.org/x/tools/cmd/stringer@latest
- name: Run go generate
run: |
cd roc
go generate
- name: Check for git changes
shell: bash -e {0}
run: |
if [[ $(git status --porcelain | grep -E "^\s*[MARCD?].*\.go$") ]]; then
echo "please run 'go generate' and commit generated files"
exit 1
fi
release:
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
needs: [linux, macos, formatting, generation]
name: Release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Check version
shell: bash
run: |
version_git="$(git describe --tags --abbrev=0 | sed s/v//g)"
version_src="$(sed -rn 's,.*bindingsVersion\s*=\s*"(\S+)".*,\1,p' ./roc/version.go)"
if [[ "$version_git" != "$version_src" ]]; then
echo "please update hardcoded version to current git version \"$version_git\"" \
>> "$GITHUB_OUTPUT"
exit 1
fi
- name: Create release
uses: softprops/action-gh-release@v1
with:
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}