107 lines
2.8 KiB
YAML
107 lines
2.8 KiB
YAML
name: ci
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: daochi-ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.26.x"
|
|
cache: true
|
|
|
|
- name: Install build dependencies
|
|
run: sudo apt-get update && sudo apt-get install -y cmake
|
|
|
|
- name: Cache vendored liboqs build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: build/liboqs
|
|
key: liboqs-${{ runner.os }}-${{ github.event.repository.name }}-${{ hashFiles('vendor/liboqs/CMakeLists.txt') }}
|
|
|
|
- name: Build liboqs
|
|
run: make liboqs
|
|
|
|
- name: Install golangci-lint
|
|
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
|
|
|
|
- name: Lint
|
|
run: golangci-lint run --timeout=5m
|
|
env:
|
|
CGO_ENABLED: "1"
|
|
GOFLAGS: "-mod=mod"
|
|
CGO_CFLAGS: "-I${{ github.workspace }}/build/liboqs/install/include"
|
|
CGO_LDFLAGS: "-L${{ github.workspace }}/build/liboqs/install/lib -loqs"
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
go-version: ["1.24.x", "1.26.x"]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
cache: true
|
|
|
|
- name: Install build dependencies
|
|
run: sudo apt-get update && sudo apt-get install -y cmake
|
|
|
|
- name: Cache vendored liboqs build
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: build/liboqs
|
|
key: liboqs-${{ runner.os }}-${{ github.event.repository.name }}-${{ hashFiles('vendor/liboqs/CMakeLists.txt') }}
|
|
|
|
- name: Check formatting
|
|
run: test -z "$(gofmt -l .)"
|
|
|
|
- name: Check generated diff hygiene
|
|
run: git diff --check
|
|
|
|
- name: Test
|
|
run: make test
|
|
|
|
- name: Race test
|
|
run: make test GOFLAGS="-mod=mod -race"
|
|
|
|
- name: Report coverage
|
|
if: matrix.go-version == '1.26.x'
|
|
run: |
|
|
CGO_ENABLED=1 GOFLAGS="-mod=mod" \
|
|
CGO_CFLAGS="-I$(pwd)/build/liboqs/install/include" \
|
|
CGO_LDFLAGS="-L$(pwd)/build/liboqs/install/lib -loqs" \
|
|
GOCACHE=/tmp/daochi-gocache \
|
|
go test -coverprofile=coverage.out ./...
|
|
go tool cover -func=coverage.out | tail -1
|
|
|
|
docker-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Build container image
|
|
run: docker build --pull --build-arg VERSION=ci-${{ github.sha }} -t daochi:ci .
|