Use RST for top-level docs, add contributing docs to the developer documentation. #866
Workflow file for this run
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: Tests | |
on: | |
- push | |
- pull_request | |
jobs: | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt install shellcheck | |
- name: Lint | |
run: | | |
make check-lint | |
- name: Ensure go.mod is up to date | |
run: | | |
set -euxo pipefail | |
# The Launchpad build pipeline will run `go mod tidy`. | |
# | |
# Consequently a rebuild could produce a `-dirty` version string if | |
# any of our dependencies have changed. | |
# | |
# While annoying, it is actually a nice feature, because we do want | |
# to make concious choices about updates to our dependencies. | |
# | |
# Check whether a `go mod tidy` would cause go.mod to change and fail | |
# if it does. | |
assert_git_status() { | |
local files="go.mod go.sum" | |
if [ -n "$(git status --porcelain=v2 $files)" ]; then | |
echo "files NOT in sync with git: $files" | |
git status $files | |
exit 1 | |
else | |
echo "files in sync with git: $files" | |
fi | |
} | |
cd microovn | |
assert_git_status | |
go mod tidy -v -x | |
assert_git_status | |
build: | |
name: build | |
needs: | |
- lint | |
runs-on: ubuntu-latest | |
env: | |
MICROOVN_SNAP: microovn.snap | |
# The `base_ref` will only be set for PR and contain the name of the | |
# target branch. The `ref_name` will be correct for the final push | |
# check after a PR is merged. | |
# | |
# This setup may lead to failures on push to arbitrarily named branches | |
# on a fork, but that is a price worth paying. | |
# | |
# Contributors can raise a draft PR to get accurate results. | |
POSSIBLE_TARGET_BRANCH: "${{ github.base_ref || github.ref_name }}" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Clear FORWARD firewall rules | |
run: | | |
# Docker can inject rules causing firewall conflicts | |
sudo iptables -P FORWARD ACCEPT || true | |
sudo ip6tables -P FORWARD ACCEPT || true | |
sudo iptables -F FORWARD || true | |
sudo ip6tables -F FORWARD || true | |
- name: Install dependencies | |
run: | | |
sudo snap refresh | |
sudo snap set lxd daemon.group=adm | |
sudo lxd init --auto | |
test $POSSIBLE_TARGET_BRANCH = main && \ | |
export SNAPCRAFT_CHANNEL=latest/edge | |
sudo snap install snapcraft \ | |
--channel "${SNAPCRAFT_CHANNEL:-latest/stable}" \ | |
--classic | |
- name: Build snap | |
run: | | |
# Build snap with coverage support | |
sed -i 's/MICROOVN_COVERAGE=.*/MICROOVN_COVERAGE="yes"/g' microovn/build-aux/environment | |
make $MICROOVN_SNAP | |
- name: Upload artifacts | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: snaps | |
path: ${{ env.MICROOVN_SNAP }} | |
retention-days: 5 | |
metadata: | |
name: Generate matrix | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.generate-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Generate matrix | |
id: generate-matrix | |
run: | | |
MATRIX_JSON="{\"test-file\": [" | |
TEST_FILES=( $(cd tests; ls -1 *.bats) ) | |
for (( i=0 ; i < "${#TEST_FILES[@]}"; i++ )); do | |
if [ $i -gt 0 ]; then | |
MATRIX_JSON+="," | |
fi | |
MATRIX_JSON+="\"${TEST_FILES[$i]}\"" | |
done | |
MATRIX_JSON+="]}" | |
echo matrix=${MATRIX_JSON} | tee -a ${GITHUB_OUTPUT} | |
system-tests: | |
name: System tests | |
needs: | |
- metadata | |
runs-on: ubuntu-latest | |
env: | |
MICROOVN_SNAP_PATH: ${{ github.workspace }}/microovn.snap | |
MICROOVN_SNAP_CHANNEL: 22.03/stable | |
strategy: | |
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download built snap | |
uses: actions/download-artifact@v4 | |
with: | |
name: snaps | |
- name: Clear FORWARD firewall rules | |
run: | | |
# Docker can inject rules causing firewall conflicts | |
sudo iptables -P FORWARD ACCEPT || true | |
sudo ip6tables -P FORWARD ACCEPT || true | |
sudo iptables -F FORWARD || true | |
sudo ip6tables -F FORWARD || true | |
- name: Install dependencies | |
run: | | |
sudo snap refresh | |
sudo snap set lxd daemon.group=adm | |
sudo lxd init --auto | |
snap list | |
- name: Run system tests | |
run: MICROOVN_COVERAGE_ENABLED=yes make tests/${{ matrix.test-file }} | |
- name: Upload test coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.test-file }}_coverage | |
path: ${{ github.workspace }}/.coverage | |
include-hidden-files: true | |
retention-days: 1 | |
generate-coverage: | |
name: Generate coverage profile | |
needs: | |
- metadata | |
- system-tests | |
# 'ubuntu-latest' currently resolves to '22.04' [0] and since we require "Go >=1.20" | |
# for coverage tools, we need to use explicit 'ubuntu-24.04' image name. | |
# [0] https://github.com/actions/runner-images/issues/10636 | |
runs-on: ubuntu-24.04 | |
env: | |
COVERAGE_DIR: ${{ github.workspace }}/.coverage | |
COVERAGE_MERGED: ${{ github.workspace }}/.coverage/_merged | |
COVERAGE_MERGED_PROFILE: ${{ github.workspace }}/.coverage/_merged/profile.out | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -yqq golang | |
go install github.com/boumenot/[email protected] | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download test coverage data | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ env.COVERAGE_DIR }} | |
pattern: "*_coverage" | |
- name: Merge test coverage data | |
run: | | |
mkdir -p "$COVERAGE_MERGED" | |
coverage_inputs=$(find "$COVERAGE_DIR" -type d -name coverage | tr '\n' ',' | sed 's/,$//g') | |
go tool covdata merge -i="$coverage_inputs" -o="$COVERAGE_MERGED" | |
go tool covdata textfmt -i="$COVERAGE_MERGED" -o="$COVERAGE_MERGED_PROFILE" | |
- name: Generate cobertura.xml | |
run: | | |
cd microovn/ | |
$HOME/go/bin/gocover-cobertura < "$COVERAGE_MERGED_PROFILE" > "$COVERAGE_DIR/cobertura.xml" | |
- name: Upload cobertura.xml | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cobertura.xml | |
path: ${{ env.COVERAGE_DIR }}/cobertura.xml | |
include-hidden-files: true | |