Prepare resources in the GitHub action for test scripts #26
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
# This is a basic workflow to help you get started with Actions | |
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: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
test: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-24.04 | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# (temporary) | |
- name: Examine the GitHub-hosted runner environment | |
run: | | |
uname -r | |
cat /etc/os-release | |
python3 --version | |
echo | |
for path in /etc/systemd/network* /etc/systemd/resolve* /etc/resolv.conf ; do | |
echo "✳️ $path" | |
[ -d "$path" ] && ls -la "$path" || cat "$path" | |
echo | |
done | |
ip addr | |
# Create a network namespace in the GitHub-hosted runner VM, | |
# simulating a primary bridge network on TrueNAS SCALE | |
- name: Set up networking resources | |
run: | | |
sudo -s <<END | |
apt-get install -qq -y \ | |
systemd-container \ | |
nftables | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
modprobe br_netfilter | |
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables | |
echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables | |
modprobe iptable_nat | |
modprobe iptable_filter | |
ip link add name br1 type bridge | |
ip address add 192.168.123.1/24 dev br1 | |
nft add table nat | |
nft add chain nat prerouting { type nat hook prerouting priority 0 \; } | |
nft add chain nat postrouting { type nat hook postrouting priority 100 \; } | |
nft add rule nat postrouting masquerade | |
# dnsmasq can't install with systemd-resolved in its way | |
sed -i -e 's/^#DNSStubListener=yes$/DNSStubListener=no/' /etc/systemd/resolved.conf | |
systemctl restart systemd-resolved.service | |
apt-get install dnsmasq -y | |
cat <<DNSMASQ >/etc/dnsmasq.d/synthetic.conf | |
no-dhcp-interface=eth0 | |
interface=br1 | |
bind-interfaces | |
dhcp-authoritative | |
dhcp-rapid-commit | |
dhcp-range=192.168.123.101,192.168.123.199 | |
# designated upstream query servers | |
server=1.1.1.1 | |
server=1.0.0.1 | |
DNSMASQ | |
# systemd-resolved should use dnsmasq as its upstream | |
sed -i -e 's/^#DNS=$/DNS=127.0.0.1/' /etc/systemd/resolved.conf | |
systemctl restart systemd-resolved.service || journalctl -xu systemd-resolved.service | |
systemctl restart dnsmasq.service || journalctl -xu dnsmasq.service | |
END | |
# NOTE: <https://github.com/marketplace/actions/tune-github-hosted-runner-network> | |
# # 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 | |
# Runs a single command using the runners shell | |
- name: Run the test script | |
env: | |
PYTHONUNBUFFERED: 1 | |
run: | | |
sudo chown 0:0 jlmkr.py test/test.sh | |
sudo chmod +x jlmkr.py test/test.sh | |
sudo ./test/test.sh |