Restore code quality tooling #164
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: CI | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events for any branch | |
push: | |
branches: ["**"] | |
pull_request: | |
branches: ["**"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
name: Build jlmkr tool | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
python-version: | |
- "3.11" # TrueNAS SCALE 24.04 Dragonfish | |
steps: | |
# hat tip: <https://github.com/pypa/hatch/issues/669> | |
- name: Tune GitHub network | |
uses: smorimoto/tune-github-hosted-runner-network@v1 | |
########################################################## | |
## Build software for distribution; perform code-level QA | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: 'pyproject.toml' | |
cache: 'pip' | |
- name: Install Hatch | |
run: pip install hatch | |
- name: Build distribution | |
run: python3 -m scripts.build | |
- name: Run style check | |
run: hatch fmt --check || echo IGNORING ADVISORIES | |
- name: Run unit tests | |
run: hatch test --cover | |
########################################################## | |
## Build software for distribution; perform code-level QA | |
# Create a network namespace in the GitHub-hosted runner VM, | |
# simulating a primary bridge network on TrueNAS SCALE | |
- name: Prepare for integration tests | |
run: | | |
sudo -s <<END | |
systemctl disable systemd-resolved --now | |
rm /etc/resolv.conf | |
echo 'nameserver 1.1.1.1' > /etc/resolv.conf | |
apt-get update | |
apt-get install -qq -y systemd-container | |
cat <<NETWORKCONFIG >/etc/systemd/network/10-br1.network | |
[Match] | |
Kind=bridge | |
Name=br1 | |
[Network] | |
# Default to using a /24 prefix, giving up to 253 addresses per virtual network. | |
Address=0.0.0.0/24 | |
LinkLocalAddressing=yes | |
DHCPServer=yes | |
IPMasquerade=both | |
LLDP=yes | |
EmitLLDP=customer-bridge | |
IPv6AcceptRA=no | |
IPv6SendRA=yes | |
NETWORKCONFIG | |
systemctl restart systemd-networkd | |
ip link add name br1 type bridge | |
iptables -I DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT | |
iptables -I DOCKER-USER -i br1 -o eth0 -j ACCEPT | |
END | |
- name: Inspect the runtime environment | |
run: | | |
uname -r | |
cat /etc/os-release | |
python3 --version | |
ip addr | |
# # TODO: create zpool with virtual disks, create jailmaker dataset and test jlmkr.py from there | |
# # https://medium.com/@abaddonsd/zfs-usage-with-virtual-disks-62898064a29b | |
# - name: Create a parent ZFS dataset | |
# run: | | |
# sudo -s <<END | |
# apt-get install -y -qq zfsutils-linux | |
# modinfo zfs | grep version | |
# zfs --version | |
# zpool --version | |
# END | |
- name: Run integration tests | |
env: | |
PYTHONUNBUFFERED: 1 | |
run: | | |
sudo ln dist/jlmkr . | |
sudo chown 0:0 jlmkr ./test/test-jlmkr | |
sudo bash ./test/test-jlmkr | |
sudo ./test/test.sh | |
########################################################## | |
## Release build artifacts | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
path: | | |
dist/jlmkr | |
dist/jlmkr-*.zip | |
if-no-files-found: error |