Skip to content

Build

Build #187

Workflow file for this run

name: Build
on:
workflow_dispatch:
pull_request:
branches:
- 'master'
# 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_0dev_${{ github.event.pull_request.head.sha || github.sha }}"
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
include:
- freebsd_version: FreeBSD-14.0-CURRENT
freebsd_id: freebsd14
steps:
- uses: actions/checkout@v3
- 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-API 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/bin/ssh -o StrictHostKeyChecking=no -o LogLevel=quiet ${{ matrix.freebsd_version }}.jaredhendrickson.com 'sudo pkg-static install -y php81-extensions'
/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@v3
with:
name: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
path: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
unit_tests:
runs-on: self-hosted
needs: [build]
strategy:
matrix:
include:
- pfsense_version: pfSense-2.7.0-RELEASE
freebsd_id: freebsd14
- pfsense_version: pfSense-23.05-RELEASE
freebsd_id: freebsd14
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg
path: pfSense-pkg-API-${{ 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-API 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-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg/pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg admin@${{ matrix.pfsense_version }}.jaredhendrickson.com:/tmp/
- name: Install pfSense-pkg-API on pfSense
run: |
/usr/local/bin/pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com --no_verify -c "pkg -C /dev/null add /tmp/pfSense-pkg-API-${{ env.build_version }}_${{ matrix.freebsd_id }}.pkg" -u admin -p pfsense
/usr/local/bin/pfsense-vshell --host ${{ matrix.pfsense_version }}.jaredhendrickson.com --no_verify -c '/etc/rc.restart_webgui' -u admin -p pfsense || true
sleep 10
- name: Run pfSense-pkg-API unit tests
run: |
ssh -o StrictHostKeyChecking=no -o LogLevel=quiet admin@${{ matrix.pfsense_version }}.jaredhendrickson.com 'pfsense-api 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