Skip to content

ci: simplify macos build, fix codeql workflow #588

ci: simplify macos build, fix codeql workflow

ci: simplify macos build, fix codeql workflow #588

Workflow file for this run

name: format
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-22.04
env:
CLANG_FORMAT_VERSION: -15
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Dependencies
run: |
sudo apt -q update
sudo apt install -q -y "clang-format${CLANG_FORMAT_VERSION}"
- name: Check
run: |
if [[ -n "${GITHUB_BASE_REF}" ]]; then
# pull request, check head branch against base branch
GITHUB_BEFORE="$(git ls-remote origin "${GITHUB_BASE_REF}" | cut -f1)"
elif [[ "${GITHUB_REF}" != "refs/heads/main" ]]; then
# workflow triggered from some branch other than main, assume that
# the branch will eventually be merged into main
GITHUB_BEFORE="$(git ls-remote origin refs/heads/main | cut -f1)"
else
# main branch, compare against previous state
# (jq comes preinstalled on github runners)
GITHUB_BEFORE="$(jq -r '.before' "${GITHUB_EVENT_PATH}")"
fi
# github interleaves stderr and stdout, redirect everything to stdout
/bin/bash -eu build-aux/ci/format-code.sh "${GITHUB_BEFORE}..${GITHUB_SHA}" 2>&1