Build and Test #21
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
name: Build and Test | |
on: | |
push: | |
branches-ignore: | |
- '*.tmp' | |
# Build at 04:00am every Monday | |
schedule: | |
- cron: "0 4 * * 1" | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
golangci: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v5 | |
- uses: actions/checkout@v4 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
man-page: | |
name: Check if man page has been regenerated | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pandoc | |
# Don't check the diff of the final manpage, instead check the | |
# intermediate markdownfile instead as it is a lot less likely to | |
# drastically change with different versions of pandoc etc. | |
cd doc/man/ && ./create_manpage.sh | |
git checkout *.1 | |
git diff --exit-code | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
# Currently nested virtualisation (hence kvm) is not supported on GitHub | |
# actions; but the qemu backend is enough to test Fakemachine | |
# functionality without hardware acceleration since the majority of code | |
# is shared between the qemu and kvm backends. | |
# See https://github.com/actions/runner-images/issues/183 | |
# | |
# For Arch Linux uml is not yet supported, so only test under qemu there. | |
os: [bookworm, trixie] | |
backend: [qemu, uml, kvm] | |
include: | |
- os: arch | |
backend: "qemu" | |
- os: arch | |
backend: "kvm" | |
name: Test ${{matrix.os}} with ${{matrix.backend}} backend | |
runs-on: ${{ matrix.backend == 'kvm' && 'kvm' || 'ubuntu-latest' }} | |
defaults: | |
run: | |
shell: bash | |
container: | |
image: ghcr.io/go-debos/test-containers/${{matrix.os}}:main | |
options: >- | |
--security-opt label=disable | |
--cap-add=SYS_PTRACE | |
--tmpfs /scratch:exec | |
${{ matrix.backend == 'kvm' && '--device /dev/kvm' || '' }} | |
env: | |
TMP: /scratch | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Test build | |
run: go build -o fakemachine cmd/fakemachine/main.go | |
- name: Run unit tests (${{matrix.backend}} backend) | |
run: go test -v ./... --backend=${{matrix.backend}} | tee test.out | |
- name: Ensure no tests were skipped | |
run: "! grep -q SKIP test.out" | |
# Job to key success status against | |
allgreen: | |
name: allgreen | |
if: always() | |
needs: | |
- golangci | |
- man-page | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Decide whether the needed jobs succeeded or failed | |
uses: re-actors/alls-green@release/v1 | |
with: | |
jobs: ${{ toJSON(needs) }} |