From c24e41e5ff856ef06efc1d2ace084b5a6c78857e Mon Sep 17 00:00:00 2001 From: Marcus Behrendt Date: Fri, 24 Nov 2023 22:55:47 +0100 Subject: [PATCH] ci: Also check whether all commits build --- .github/workflows/ci.yml | 73 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc7178a0..28102edf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,77 @@ jobs: - name: Run cargo fmt run: cargo fmt --all -- --check + code-analysis: + name: Code Analysis + runs-on: ubuntu-latest + container: + image: bilelmoussaoui/flatpak-github-actions:gnome-45 + options: --privileged + needs: [check-commit-style, typos, rustfmt] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Cache flatpak + id: cache-flatpak + uses: actions/cache@v3 + with: + path: .flatpak-builder + key: ${{ runner.os }}-flatpak-${{ hashFiles('build-aux/com.github.marhkb.Pods.Devel.json') }} + restore-keys: ${{ runner.os }}-flatpak- + + - name: Cache cargo + id: cache-cargo + uses: actions/cache@v3 + with: + path: /github/home/.cargo + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Create dummy versions of configured file + run: | + sed \ + -e 's/str =.*;/str = "";/g' \ + -e 's/i32 =.*;/i32 = 0;/g' \ + src/config.rs.in \ + > src/config.rs + + - name: Build dependencies + run: | + flatpak-builder \ + --disable-rofiles-fuse \ + --install-deps-from=flathub \ + --keep-build-dirs \ + --stop-at=pods \ + flatpak_app build-aux/com.github.marhkb.Pods.Devel.json + + - name: Retrieve rustc version + id: rustc-version + run: | + echo "RUSTC_VERSION=$(flatpak-builder --run flatpak_app build-aux/com.github.marhkb.Pods.Devel.json rustc -V)" >> $GITHUB_OUTPUT + + - name: Cache target + id: cache-target + uses: actions/cache@v3 + with: + path: target + key: ${{ runner.os }}-target-${{ steps.rustc-version.outputs.RUSTC_VERSION }}-${{ hashFiles('Cargo.lock') }} + restore-keys: ${{ runner.os }}-target-${{ steps.rustc-version.outputs.RUSTC_VERSION }} + + - name: Test if all commits build + run: | + git config --global --add safe.directory /__w/pods/pods + + for commit in $(git rev-list ${{ github.base_ref }}..${{ github.head_ref }}); do + git checkout $commit + + flatpak-builder \ + --run \ + flatpak_app build-aux/com.github.marhkb.Pods.Devel.json \ + cargo build + done + flatpak: name: Flatpak runs-on: ubuntu-latest @@ -51,7 +122,7 @@ jobs: arch: [x86_64] # Don't fail the whole workflow if one architecture fails fail-fast: false - needs: [check-commit-style, typos, rustfmt] + needs: [code-analysis] steps: - uses: actions/checkout@v4 # Docker is required by the docker/setup-qemu-action which enables emulation