-
-
Notifications
You must be signed in to change notification settings - Fork 107
173 lines (144 loc) · 7.58 KB
/
build.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Build
on:
workflow_dispatch:
pull_request:
branches:
- "master"
# Ensure only one build job runs at a time
concurrency: build
# Commit SHAs may differ when trigger via pull request vs workflow_dispatch, ensure the correct commit is referenced.
env:
COMMIT_ID: "${{ github.event.pull_request.head.sha || github.sha }}"
BUILD_VERSION: "0.0_0-dev-${{ github.event.pull_request.head.sha || github.sha }}"
jobs:
build_pkg:
runs-on: self-hosted
strategy:
matrix:
include:
- FREEBSD_VERSION: FreeBSD-14.0-CURRENT
FREEBSD_ID: freebsd14
- FREEBSD_VERSION: FreeBSD-15.0-CURRENT
FREEBSD_ID: freebsd15
steps:
- uses: actions/checkout@v4
- name: Setup FreeBSD build VM
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.FREEBSD_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{ matrix.FREEBSD_VERSION }} restore initial
/usr/local/bin/VBoxManage startvm ${{ matrix.FREEBSD_VERSION }} --type headless
sleep 5
- name: Build pfSense-pkg-RESTAPI on FreeBSD
run: |
/usr/bin/ssh -o StrictHostKeyChecking=no -o LogLevel=quiet ${{ matrix.FREEBSD_VERSION }}.jaredhendrickson.com 'sudo pkill ntpd || true && sudo ntpdate pool.ntp.org || true'
/usr/local/bin/python3 tools/make_package.py --host ${{ matrix.FREEBSD_VERSION }}.jaredhendrickson.com --branch ${{ env.COMMIT_ID }} --tag ${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}
- name: Teardown FreeBSD build VM
if: "${{ always() }}"
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.FREEBSD_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{matrix.FREEBSD_VERSION}} restore initial
- uses: actions/upload-artifact@v4
with:
name: pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg
path: pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg
build_openapi:
runs-on: self-hosted
needs: [build_pkg]
strategy:
matrix:
include:
- PFSENSE_VERSION: pfSense-2.7.2-RELEASE
FREEBSD_ID: freebsd14
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg
path: pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg
- name: Setup pfSense VM
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.PFSENSE_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{ matrix.PFSENSE_VERSION }} restore initial
/usr/local/bin/VBoxManage startvm ${{ matrix.PFSENSE_VERSION }} --type headless
sleep 5
# This is only necessary until GitHub Actions allows an easier way to get a URL to download the artifact within pfSense
- name: Copy pfSense-pkg-RESTAPI build to pfSense
run: |
pfsense-vshell --host ${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com -u admin -p pfsense -c 'pfSsh.php playback enablesshd' -k
pfsense-vshell --host ${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com -u admin -p pfsense -c "mkdir /root/.ssh/ && echo $(cat ~/.ssh/id_rsa.pub) > /root/.ssh/authorized_keys" -k
scp -o StrictHostKeyChecking=no pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg/pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg admin@${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com:/tmp/
- name: Install pfSense-pkg-RESTAPI on pfSense
run: |
ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com "pkg -C /dev/null add /tmp/pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg"
sleep 5
- name: Fetch OpenAPI schema from pfSense
run: curl -s -k -u admin:pfsense -X GET https://${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com/api/v2/schema/openapi > openapi-${{ matrix.PFSENSE_VERSION }}.json
- name: Teardown pfSense VM
if: "${{ always() }}"
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.PFSENSE_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{ matrix.PFSENSE_VERSION }} restore initial
- uses: actions/upload-artifact@v4
with:
name: openapi-${{ matrix.PFSENSE_VERSION }}.json
path: openapi-${{ matrix.PFSENSE_VERSION }}.json
check_openapi:
runs-on: ubuntu-latest
needs: [build_openapi]
strategy:
matrix:
include:
- PFSENSE_VERSION: pfSense-2.7.2-RELEASE
FREEBSD_ID: freebsd14
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: openapi-${{ matrix.PFSENSE_VERSION }}.json
path: openapi-${{ matrix.PFSENSE_VERSION }}.json
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install npm dependencies
run: npm i
- name: Validate OpenAPI schema
run: ./node_modules/.bin/spectral lint openapi-${{ matrix.PFSENSE_VERSION }}.json/openapi-${{ matrix.PFSENSE_VERSION }}.json --fail-severity warn
check_tests:
runs-on: self-hosted
needs: [build_openapi]
strategy:
matrix:
include:
- PFSENSE_VERSION: pfSense-2.7.2-RELEASE
FREEBSD_ID: freebsd14
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg
path: pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg
- name: Setup pfSense VM
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.PFSENSE_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{ matrix.PFSENSE_VERSION }} restore initial
/usr/local/bin/VBoxManage startvm ${{ matrix.PFSENSE_VERSION }} --type headless
sleep 5
# This is only necessary until GitHub Actions allows an easier way to get a URL to download the artifact within pfSense
- name: Copy pfSense-pkg-RESTAPI build to pfSense
run: |
pfsense-vshell --host ${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com -u admin -p pfsense -c 'pfSsh.php playback enablesshd' -k
pfsense-vshell --host ${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com -u admin -p pfsense -c "mkdir /root/.ssh/ && echo $(cat ~/.ssh/id_rsa.pub) > /root/.ssh/authorized_keys" -k
scp -o StrictHostKeyChecking=no pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg/pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg admin@${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com:/tmp/
- name: Install pfSense-pkg-RESTAPI on pfSense
run: |
ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com "pkg -C /dev/null add /tmp/pfSense-pkg-RESTAPI-${{ env.BUILD_VERSION }}-${{ matrix.FREEBSD_ID }}.pkg"
sleep 5
- name: Run pfSense-pkg-RESTAPI tests
run: |
ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@${{ matrix.PFSENSE_VERSION }}.jaredhendrickson.com 'pfsense-restapi runtests'
- name: Teardown pfSense VM
if: "${{ always() }}"
run: |
/usr/local/bin/VBoxManage controlvm ${{ matrix.PFSENSE_VERSION }} poweroff || true
/usr/local/bin/VBoxManage snapshot ${{ matrix.PFSENSE_VERSION }} restore initial