diff --git a/.github/workflows/build-debs.yml b/.github/workflows/build-debs.yml new file mode 100644 index 000000000000..c99be7503312 --- /dev/null +++ b/.github/workflows/build-debs.yml @@ -0,0 +1,37 @@ +name: Build DEBs + +on: + push: + branches: + - master + pull_request: + branches: [master] + workflow_dispatch: + schedule: + - cron: '0 0 * * *' +jobs: + DEB: + strategy: + matrix: + distro: [ubuntu22] + runs-on: ubuntu-latest + name: Build ${{ matrix.distro }} + steps: + - uses: actions/checkout@v2 + - name: Build Docker Image + run: docker build . -f docker/${{ matrix.distro }}/Dockerfile -t opae-${{ matrix.distro }} + - name: Build DEBs + run: | + docker run --rm -v ${{ github.workspace }}:/opae-${{ matrix.distro }}/opae-sdk opae-${{ matrix.distro }} /opae-${{ matrix.distro }}/opae-sdk + - name: Install and Test DEBs + if: ${{ github.event_name != 'pull_request'}} + run: | + docker run --rm -v ${{ github.workspace }}:/opae-${{ matrix.distro }}/opae-sdk --workdir /opae-${{ matrix.distro }}/opae-sdk --entrypoint /bin/bash opae-${{ matrix.distro }} -c "/scripts/test-debs.sh" + - name: Upload Artifact + if: ${{ github.event_name != 'pull_request'}} + uses: actions/upload-artifact@v2.1.4 + with: + name: OPAE-${{ matrix.distro }} + path: + ${{ matrix.distro }}/opae-sdk/packaging/opae/deb/*.deb + diff --git a/docker/ubuntu22/Dockerfile b/docker/ubuntu22/Dockerfile new file mode 100644 index 000000000000..2a82bcc446d2 --- /dev/null +++ b/docker/ubuntu22/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:22.04 +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3 python3-pip python3-dev git gcc g++ make cmake uuid-dev libjson-c-dev libhwloc-dev libtbb-dev libedit-dev libudev-dev bsdmainutils devscripts debhelper dh-python +RUN python3 -m pip install setuptools --upgrade --prefix=/usr +RUN python3 -m pip install pyyaml jsonschema pybind11 +WORKDIR /root +COPY scripts/build-debs.sh /scripts/build-debs.sh +COPY scripts/test-debs.sh /scripts/test-debs.sh +ENTRYPOINT ["/scripts/build-debs.sh"] diff --git a/scripts/build-debs.sh b/scripts/build-debs.sh new file mode 100755 index 000000000000..c3457c0dc409 --- /dev/null +++ b/scripts/build-debs.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -x + +src=$(realpath ${1:-$PWD}) + +cmake=cmake +if ! command -v cmake > /dev/null && command -v cmake3 > /dev/null; then + cmake=cmake3 +fi + +${src}/packaging/opae/deb/create diff --git a/scripts/test-debs.sh b/scripts/test-debs.sh new file mode 100755 index 000000000000..8d9a55dcfd06 --- /dev/null +++ b/scripts/test-debs.sh @@ -0,0 +1,52 @@ +#!/bin/bash +debdir=$(realpath ${1:-$PWD}) +debdir="${debdir}/packaging/opae/deb" + +apt-get install -y $debdir/opae*.deb +if [ $? -ne 0 ]; then + echo "Could not install OPAE DEBs" + exit 1 +fi + +failures=0 +test_exit_code(){ + expected_code=$1 + shift + cmd="$@" + echo "testing: $cmd" + $cmd > output.dat + actual_code=$? + if [ $expected_code != $actual_code ]; then + failures=$(echo 1+$failures | bc) + echo "$cmd: expected $expected_code, got $actual_code" >> errors.txt + cat output.dat + fi +} + +if [ -f errors.txt ]; then + unlink errors.txt +fi + +test_exit_code 0 "fpgainfo -h" +test_exit_code 1 "fpgaconf -h" +test_exit_code 0 "pci_device -h" +test_exit_code 0 "fpgasupdate -h" +test_exit_code 0 "hssi -h" +test_exit_code 0 "dummy_afu -h" +test_exit_code 0 "opae.io -h" +test_exit_code 0 "PACSign -h" +test_exit_code 1 "fpgadiag -h" +test_exit_code 100 "fpgadiag -m lpbk1 -h" +test_exit_code 100 "fpgadiag -m read -h" +test_exit_code 100 "fpgadiag -m write -h" +test_exit_code 100 "fpgadiag -m trput -h" + +dd if=/dev/urandom of=dummy.bin bs=1 count=1024 2> /dev/null +test_exit_code 0 \ + "PACSign PR -H openssl_manager -t UPDATE -y -i dummy.bin -o dummy.signed" +echo "unexpected exit codes shown below" +if [ -f errors.txt ]; then + cat errors.txt +fi +echo "failures: $failures" +exit $failures