-
Notifications
You must be signed in to change notification settings - Fork 48
147 lines (122 loc) · 4.13 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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 software for distribution; perform code-level QA
build:
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>
- uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
cache: 'pip'
- name: Install Hatch
run: pip install hatch
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build distribution
run: hatch build --ext
- name: Run style check
run: hatch fmt --check
- name: Run unit tests
run: hatch test --cover
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path:
- dist/jlmkr
- dist/jlmkr-*.zip
if-no-files-found: error
##########################################################
## Perform rubber-meets-road integration testing
test:
# The type of runner that the job will run on
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
# 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
- uses: actions/setup-python@v5
with:
python-version: '3.11' # TrueNAS SCALE 24.04 Dragonfish
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1
# Create a network namespace in the GitHub-hosted runner VM,
# simulating a primary bridge network on TrueNAS SCALE
- name: Install packages and setup networking
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: Examine the GitHub-hosted runner 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: Build
run: |
python3 -m zipapp src/jlmkr -p "/usr/bin/env python3" -o jlmkr
- uses: actions/upload-artifact@v4
with:
path: jlmkr
# Run multiple commands using the runners shell
- name: Run the test script
env:
PYTHONUNBUFFERED: 1
run: |
sudo chown 0:0 jlmkr ./test/test-jlmkr
sudo bash ./test/test-jlmkr
sudo ./test/test.sh