Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions workflows #54

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "lzaoral"
vmihalko marked this conversation as resolved.
Show resolved Hide resolved
138 changes: 138 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
name: Linux 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: Ubuntu
strategy:
fail-fast: false
matrix:
include:
# Linux with GCC
- {os: 20.04, llvm: '6.0', compiler: gcc}
- {os: 20.04, llvm: 7, compiler: gcc}
- {os: 20.04, llvm: 8, compiler: gcc}
- {os: 20.04, llvm: 9, compiler: gcc}
- {os: 20.04, llvm: 10, compiler: gcc}
- {os: 20.04, llvm: 11, compiler: gcc}
- {os: 20.04, llvm: 12, compiler: gcc}
- {os: 22.04, llvm: 13, compiler: gcc}
- {os: 22.04, llvm: 14, compiler: gcc}
- {os: 22.04, llvm: 14, compiler: gcc, type: Debug}

# Linux with Clang
- {os: 20.04, llvm: '6.0', compiler: clang}
- {os: 20.04, llvm: 7, compiler: clang}
- {os: 20.04, llvm: 8, compiler: clang}
- {os: 20.04, llvm: 9, compiler: clang}
- {os: 20.04, llvm: 10, compiler: clang}
- {os: 20.04, llvm: 11, compiler: clang}
- {os: 20.04, llvm: 12, compiler: clang}
- {os: 22.04, llvm: 13, compiler: clang}
- {os: 22.04, llvm: 14, compiler: clang}
- {os: 22.04, llvm: 14, compiler: clang, type: Debug}

runs-on: ubuntu-${{matrix.os}}
env:
# for colours in ninja
CLICOLOR_FORCE: 1

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

- name: Install dependencies
run: |
sudo apt update
sudo apt install cmake ninja-build clang-${{matrix.llvm}} \
llvm-${{matrix.llvm}}-dev

- name: Set the environment
id: env
run: |
# Set buildtype
if [[ "${{matrix.type}}" != "" ]]; then
echo "BUILD_TYPE=${{matrix.type}}" >> $GITHUB_ENV
else
echo "BUILD_TYPE=RelWithDebInfo" >> $GITHUB_ENV
fi

# 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"

# Select compiler and set compiler flags
if [[ "${{matrix.compiler}}" = "clang" ]]; then
# Clang
CC="clang-${{matrix.llvm}}"
CXX="clang++-${{matrix.llvm}}"

# Force coloured output
CFLAGS="-fcolor-diagnostics $CFLAGS"
CXXFLAGS="-fcolor-diagnostics $CXXFLAGS"
else
# GCC
CC="gcc"
CXX="g++"

# Force coloured output
CFLAGS="-fdiagnostics-color $CFLAGS"
CXXFLAGS="-fdiagnostics-color $CXXFLAGS"
fi

# 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: |
cmake -S. \
-B_build \
-GNinja \
-DCMAKE_BUILD_TYPE:STRING="${{matrix.type}}" \
-DLLVM_DIR:PATH="$(llvm-config-${{matrix.llvm}} --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
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
88 changes: 88 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
name: Windows 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: 'Windows (llvm: ${{matrix.llvm}}, build: ${{matrix.build}})'
strategy:
fail-fast: false
matrix:
llvm: [13]
build: [RelWithDebInfo]

runs-on: windows-latest
steps:
- name: Checkout llvm2c
uses: actions/checkout@v3

- name: Install dependencies
run: |
# Use LLVM build from the authors of the zig language:
# https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows#option-1-use-the-windows-zig-compiler-dev-kit
curl -o llvm.tar.xz "https://ziglang.org/deps/llvm%2bclang%2blld-${{matrix.llvm}}.0.1-x86_64-windows-msvc-release-mt.tar.xz"

# workaround for https://github.com/actions/runner-images/issues/282
$env:Path = "C:\\Program Files\\Git\\usr\\bin;" + $env:Path

# extract twice to deal with dangling symlinks
tar xvf .\llvm.tar.xz
tar xvf .\llvm.tar.xz

- name: Set environment
run: |
# TODO: add sanitizer support to llvm2c's CMakeLists.txt

# Build with sanitizers (TODO: add UBSAN when MSVC supports it)
$CFLAGS = "/fsanitize=address"
$CXXFLAGS = "/fsanitize=address"

# Make UBSAN print whole stack traces
$UBSAN_OPTIONS = "print_stacktrace=1"

# Fail on any compiler warning
$CFLAGS += " /WX"
$CXXFLAGS += " /WX"

# Save the environment
"CFLAGS=$CFLAGS" >> $env:GITHUB_ENV
"CXXFLAGS=$CXXFLAGS" >> $env:GITHUB_ENV
"UBSAN_OPTIONS=$UBSAN_OPTIONS" >> $env:GITHUB_ENV

# TODO: LLVM cannot be build as a DLL on Windows. Uncomment when it is
# possible.
#
#- name: '[Dynamic LLVM] Configure CMake project'
# run: |
# $LLVM_CONFIG = Resolve-Path 'llvm*\bin\llvm-config.exe'
# cmake -S. `
# -B_build `
# -DLLVM_DIR:PATH="$(& "$LLVM_CONFIG" --cmakedir)"
#
#- name: '[Dynamic LLVM] Build'
# run: cmake --build _build --config ${{matrix.build}}
#
#- name: '[Dynamic LLVM] Run tests'
# run: cmake --build _build --target check

- name: '[Static LLVM] Re-configure CMake project'
run: |
$LLVM_CONFIG = Resolve-Path 'llvm*\bin\llvm-config.exe'
cmake -S. `
-B_build `
-DLLVM_LINK_DYLIB:BOOL=OFF `
-DLLVM_DIR:PATH="$(& "$LLVM_CONFIG" --cmakedir)"

- name: '[Static LLVM] Build'
run: cmake --build _build --config ${{matrix.build}}

# FIXME: enable tests on Windows
#- name: '[Static LLVM] Run tests'
# run: cmake --build _build --target check
Loading