From 1efb50e67e0590b8e7d69e2b4d4323d4db556f9e Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Mon, 21 Oct 2024 21:12:46 +0100 Subject: [PATCH] ci(github): split build job to build and then tests job. --- .github/workflows/main.yml | 45 +++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34a449ff..7321399e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,10 +9,10 @@ jobs: matrix: os: - ubuntu-24.04 - # - ubuntu-22.04 + - ubuntu-22.04 mode: - default - # - full-system-policy + - full-system-policy steps: - name: Check out repository code uses: actions/checkout@v4 @@ -30,12 +30,10 @@ jobs: if [[ ${{ matrix.mode }} == full-system-policy ]]; then echo -e "\noverride_dh_auto_build:\n\tmake full" >> debian/rules fi - VERSION="0.$(git rev-list --count HEAD)-1" - dch --newversion="$VERSION" --urgency=medium --distribution=stable --controlmaint "Release $VERSION" - dpkg-buildpackage -b -d --no-sign + bash dists/build.sh dpkg - name: Install apparmor.d - run: sudo dpkg --install ../apparmor.d_*_amd64.deb || true + run: sudo dpkg --install .pkg/apparmor.d_*_amd64.deb || true - name: Reload AppArmor run: | @@ -56,14 +54,45 @@ jobs: - name: Show Number of loaded profile run: sudo aa-status --profiled - - name: Install Tests dependencies + - name: Cache the build package if: matrix.mode == 'default' && matrix.os == 'ubuntu-24.04' + uses: actions/cache/save@v4 + with: + path: .pkg/apparmor.d_*_amd64.deb + key: ${{ matrix.os }}-${{ matrix.mode }}-${{ hashFiles('.pkg/apparmor.d_*_amd64.deb') }} + + tests: + runs-on: ubuntu-24.04 + needs: build + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Restore the cached build package + uses: actions/cache/restore@v4 + with: + fail-on-cache-miss: true + path: .pkg/apparmor.d_*_amd64.deb + key: ubuntu-24.04-default-${{ hashFiles('.pkg/apparmor.d_*_amd64.deb') }} + restore-keys: | + ubuntu-24.04-default- + + - name: Install Tests dependencies run: | sudo apt-get update -q sudo apt-get install -y \ + apparmor-profiles apparmor-utils \ bats bats-support + - name: Install apparmor.d + run: | + sudo dpkg --install .pkg/apparmor.d_*_amd64.deb || true + sudo systemctl restart apparmor.service + - name: Run the bats integration tests - if: matrix.mode == 'default' && matrix.os == 'ubuntu-24.04' run: | make bats + + - name: Show final AppArmor logs + run: | + sudo aa-log -s