Skip to content

ci: run unit tests on macos #1619

ci: run unit tests on macos

ci: run unit tests on macos #1619

Workflow file for this run

# See reference docs at
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
name: Pull request CI
on: pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
dev-container:
uses: ./.github/workflows/ci-dev-container.yml
secrets: inherit
permissions:
contents: read
packages: write
pr-head-ci:
needs: [dev-container]
uses: ./.github/workflows/ci-common.yml
with:
container-repo: ${{ needs.dev-container.outputs.container-repo }}
container-version: ${{ needs.dev-container.outputs.container-version }}
secrets: inherit
# Build the firmware on every commit to simplify bisecting the firmware
generate-matrix:
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Clone the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
# HEAD~ because we want to skip the last commit (which is built in job above)
- name: Create jobs for commits in PR history
id: set-matrix
run: |
echo matrix=$(.ci/matrix-from-commit-log ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}~) >> $GITHUB_OUTPUT
# Run this job for every commit in the PR except HEAD.
# This job simulates what github does for the PR HEAD commit but for every other commit in the
# PR. So for every commit, it creates a merge commit between that commit and the base branch.
# Then it runs the CI on that merge commit.
# The only caveat is that this file (pr-ci.yml) is already loaded from the PR HEAD merge commit,
# and therefore we need to load the `.ci` scripts from the PR HEAD merge commit. The outcome of
# that is that changes to the CI is not tested per commit. All commits use the final version.
pr-commit-ci:
runs-on: ubuntu-22.04
needs: [ generate-matrix, dev-container ]
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
if: needs.generate-matrix.outputs.matrix != '' && !cancelled()
container:
image: ${{ needs.dev-container.outputs.container-repo}}:${{ needs.dev-container.outputs.container-version }}
env:
RUSTFLAGS: "-Dwarnings"
steps:
- name: Clone the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.base.sha }}
- name: Mark directory as safe
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Create merge commit
env:
GIT_AUTHOR_NAME: Bot
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: Bot
GIT_COMMITTER_EMAIL: [email protected]
run: |
git fetch origin ${{ matrix.commit }} ${{ github.event.pull_request.merge_commit_sha }}
git merge --no-ff --no-edit ${{ matrix.commit }}
git submodule update --init --recursive
git log -1 --format="Head %H, Parents %P"
# Since the workflow definition is taken from the pull request merge commit, we need to
# get the .ci scripts from there as well.
git checkout -f ${{ github.event.pull_request.merge_commit_sha }} -- .ci .github
- name: build firmware
run: make -j$(($(nproc)+1)) firmware