Skip to content

Commit

Permalink
CI: add GitHub Actions workflow for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
lzaoral committed Jan 2, 2023
1 parent 17fc0ef commit fff8e14
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: macOS CI
on:
# TODO: rename to main when we remove the binary blobs from the git history
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: 'macOS (llvm: ${{matrix.llvm}}, build: ${{matrix.build}})'
strategy:
fail-fast: false
matrix:
llvm: [14]
build: [Debug, RelWithDebInfo]

runs-on: macos-latest
env:
# for colours in ninja
CLICOLOR_FORCE: 1

steps:
- name: Checkout llvm2c
uses: actions/checkout@v3

- name: Install dependencies
run: brew install ninja llvm@${{matrix.llvm}}

- name: Set environment
id: env
run: |
# TODO: add sanitizer support to llvm2c's CMakeLists.txt
# Build with sanitizers
CFLAGS="-fsanitize=address,undefined -g -fno-omit-frame-pointer"
CXXFLAGS="-fsanitize=address,undefined -g -fno-omit-frame-pointer"
LDFLAGS="-fsanitize=address,undefined"
# Fail on UBSAN
CFLAGS="-fno-sanitize-recover=all $CFLAGS"
CXXFLAGS="-fno-sanitize-recover=all $CXXFLAGS"
# Make UBSAN print whole stack traces
UBSAN_OPTIONS="print_stacktrace=1"
# Fail on any compiler warning
CFLAGS="-Werror $CFLAGS"
CXXFLAGS="-Werror $CXXFLAGS"
# Force coloured output
CFLAGS="-fcolor-diagnostics $CFLAGS"
CXXFLAGS="-fcolor-diagnostics $CXXFLAGS"
# Save the environment
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CXX" >> $GITHUB_ENV
echo "CFLAGS=$CFLAGS" >> $GITHUB_ENV
echo "CXXFLAGS=$CXXFLAGS" >> $GITHUB_ENV
echo "LDFLAGS=$LDFLAGS" >> $GITHUB_ENV
echo "UBSAN_OPTIONS=$UBSAN_OPTIONS" >> $GITHUB_ENV
- name: '[Dynamic LLVM] Configure CMake project'
run: |
LLVM_CONFIG="$(brew --prefix llvm@${{matrix.llvm}})/bin/llvm-config"
cmake -S. \
-B_build \
-GNinja \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.build}} \
-DLLVM_DIR:PATH="$("$LLVM_CONFIG" --cmakedir)"
- name: '[Dynamic LLVM] Build'
run: cmake --build _build

- name: '[Dynamic LLVM] Run tests'
run: cmake --build _build --target check

- name: '[Static LLVM] Re-configure CMake project'
run: |
cmake -S. \
-B_build \
-DLLVM_LINK_DYLIB:BOOL=OFF
cmake --build _build --target clean
- name: '[Static LLVM] Build'
run: cmake --build _build

- name: '[Static LLVM] Run tests'
run: cmake --build _build --target check

0 comments on commit fff8e14

Please sign in to comment.