From 375960eb23b8ec4e00e49247646c81b8e885a260 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sat, 15 Jun 2024 11:36:46 -0300 Subject: [PATCH] ci: Initial workflow based on Nix Flake Signed-off-by: Otavio Salvador --- .github/dependabot.yml | 6 +++ .github/workflows/ci.yaml | 79 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..bb5f9c2 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,79 @@ +name: "Continuous Integration" + +on: + pull_request: + merge_group: + push: + branches: + - "master" + +concurrency: + group: ${{ github.repository }}-${{ github.workflow }} + cancel-in-progress: false + +jobs: + nix-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v12 + - uses: DeterminateSystems/magic-nix-cache-action@v7 + - id: set-matrix + name: Generate Nix Matrix + run: | + set -euo pipefail + + matrix="$(nix eval --json '.#githubActions.matrix')" + echo "matrix=${matrix}" >> "$GITHUB_OUTPUT" + + nix-build: + needs: nix-matrix + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + max-parallel: 10 + matrix: ${{ fromJSON(needs.nix-matrix.outputs.matrix) }} + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v12 + - uses: DeterminateSystems/magic-nix-cache-action@v7 + - run: nix build -L ".#${{ matrix.attr }}" --keep-going + + + - name: Twister Tests + uses: workflow/nix-shell-action@v3.3.0 + id: twister-tests + with: + flakes-from-devshell: true + script: | + west init -l . + west config --global update.narrow true + west update + + ./scripts/run-tests --clobber-output --inline-logs -v -N -M + + - name: Merge Test Results + if: steps.twister-tests.conclusion == 'failure' + run: | + pip3 install junitparser junit2html + junitparser merge **/twister.xml junit.xml + junit2html junit.xml junit.html + + - name: Upload Unit Test Results in HTML + if: steps.twister-tests.conclusion == 'failure' + uses: actions/upload-artifact@v2 + with: + name: HTML Unit Test Results + if-no-files-found: ignore + path: | + junit.html + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: steps.twister-tests.conclusion == 'failure' + with: + check_name: Unit Test Results + github_token: ${{ secrets.GITHUB_TOKEN }} + files: "**/twister.xml"