Merge pull request #258 from xnox/update-deps #407
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Checks codes | |
# We don't run tests here but on travis as we need to modprobe zfs, and so, needs a VM with the same version | |
# then our libzfs. | |
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
paths-ignore: | |
- '.github/workflows/commands.yaml' | |
- 'po/*' | |
jobs: | |
quality: | |
name: Code quality and mod files up to date | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout code | |
- uses: actions/checkout@v3 | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- name: Code formatting | |
run: | | |
FMT=`go fmt ./...` | |
echo "$FMT" | |
[ -z "$FMT" ] | |
- name: Check mod files | |
run: ./.github/ci/check-modules | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
container: ubuntu:devel | |
steps: | |
- uses: actions/checkout@v3 | |
# Add dependencies | |
- name: Enable proposed | |
run: | | |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list | |
cat <<EOF >/etc/apt/preferences.d/proposed.pref | |
Package: * | |
Pin: release a=*-proposed | |
Pin-Priority: 500 | |
EOF | |
- name: Install dependencies | |
run: | | |
apt update | |
apt install -y ca-certificates gcc libzfslinux-dev | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- name: Building | |
run: go build ./... | |
generators: | |
name: Generated files are up to date | |
runs-on: ubuntu-latest | |
container: ubuntu:devel | |
steps: | |
# Add dependencies | |
- name: Enable proposed | |
run: | | |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list | |
cat <<EOF >/etc/apt/preferences.d/proposed.pref | |
Package: * | |
Pin: release a=*-proposed | |
Pin-Priority: 500 | |
EOF | |
- name: Install dependencies | |
run: | | |
apt update | |
DEBIAN_FRONTEND=noninteractive apt install -y ca-certificates gcc libzfslinux-dev protobuf-compiler gettext git | |
# Checkout code (using git that we just installed) | |
- uses: actions/checkout@v3 | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- name: Install go grpc protoc generator | |
run: | | |
cd .. | |
GOPATH=`pwd` go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \ | |
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | |
cd - | |
extended-quality: | |
name: Extended quality checks | |
runs-on: ubuntu-latest | |
container: ubuntu:devel | |
steps: | |
# Checkout code | |
- uses: actions/checkout@v3 | |
- name: Enable proposed | |
run: | | |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list | |
cat <<EOF >/etc/apt/preferences.d/proposed.pref | |
Package: * | |
Pin: release a=*-proposed | |
Pin-Priority: 500 | |
EOF | |
# Add dependencies | |
- name: Install dependencies | |
run: | | |
apt update | |
apt install -y ca-certificates gcc libzfslinux-dev # go vet needs libzfs headers (for cgo analysis) | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
- name: Report suspicious constructs | |
run: go vet ./... | |
# TODO: add statichecks and others? | |
local-tests: | |
name: Tests with mocks | |
runs-on: ubuntu-latest | |
container: ubuntu:devel | |
steps: | |
- uses: actions/checkout@v3 | |
# Install go | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.x' | |
# Add dependencies | |
- name: Enable proposed | |
run: | | |
sed 's/updates/proposed/' /etc/apt/sources.list > /etc/apt/sources.list.d/proposed.list | |
cat <<EOF >/etc/apt/preferences.d/proposed.pref | |
Package: * | |
Pin: release a=*-proposed | |
Pin-Priority: 500 | |
EOF | |
- name: Install dependencies | |
run: | | |
apt update | |
DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install ca-certificates gcc libzfslinux-dev dbus gettext | |
- name: Run tests with mock | |
run: | | |
go test -coverprofile=coverage.txt -covermode=atomic ./... | |
- name: Run tests (with race detector) | |
run: | | |
go test -race ./... | |
integration-tests: | |
name: Tests with system zfs | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout code | |
- uses: actions/checkout@v3 | |
# Reset env so that apt install golang-go then reads GOROOT with uncompatible local version installed by github | |
- name: Reset environment without GOROOT | |
run: sudo sed -i "/GOROOT/d" /etc/environment | |
# Add dependencies | |
- name: Install dependencies | |
continue-on-error: true | |
run: | | |
sudo add-apt-repository -y ppa:xnox/ubuntu/scratch | |
sudo apt install -y ca-certificates gcc libzfslinux-dev gettext golang-go | |
sudo sync | |
sudo modprobe zfs | |
- name: Run tests | |
continue-on-error: true | |
run: | | |
sudo go test -coverprofile=coverage.txt -covermode=atomic ./... -with-system-zfs | |
- name: Run tests (with race detector) | |
continue-on-error: true | |
run: | | |
sudo go test -race ./... -with-system-zfs | |
- name: Run benchkmarks | |
continue-on-error: true | |
run: | | |
sudo go test -bench -run=Benchmark ./... -with-system-zfs | |
- name: Upload coverage | |
continue-on-error: true | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.txt | |
token: ${{secrets.CODECOV_TOKEN}} | |
# TODO: create a container on a schedule, with the following matrix: | |
# - ubuntu (rolling) | ubuntu (devel) | |
# - go X | go master | |
# every tests with ubuntu devel and go master aren't required (can be transitive failures) | |
# tests (race without race) -> travis |