Revert "Coverage" #779
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 | |
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: 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: .bats/bats-core/bin/bats tests/${{ matrix.test-file }} |