Skip to content

CI: re-organize GitHub Actions #2908

CI: re-organize GitHub Actions

CI: re-organize GitHub Actions #2908

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Vanilla LLVM
on:
- pull_request
- push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- job_name: Ubuntu 20.04, LLVM 18, latest LDC beta
os: ubuntu-20.04
host_dc: ldc-beta
llvm_version: 18
container: liushuyu/ldc-build-environments:20.04-18
- job_name: macOS 14, LLVM 17, latest LDC beta
os: macos-14
host_dc: ldc-beta
llvm_version: 17.0.5
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib
- job_name: macOS 14, LLVM 16, latest LDC beta
os: macos-14
host_dc: ldc-beta
llvm_version: 16.0.5
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DD_COMPILER_FLAGS=-gcc=/usr/bin/c++ -DCMAKE_EXE_LINKER_FLAGS=-L/opt/homebrew/opt/zstd/lib
- job_name: Ubuntu 20.04, LLVM 15, latest LDC beta
os: ubuntu-latest
host_dc: ldc-beta
llvm_version: 15
container: liushuyu/ldc-build-environments:20.04-15
- job_name: macOS 11, LLVM 14, latest DMD beta
os: macos-11
host_dc: dmd-beta
llvm_version: 14.0.6
cmake_flags: -DBUILD_SHARED_LIBS=ON -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON -DCMAKE_CXX_COMPILER=/usr/bin/c++ -DCMAKE_C_COMPILER=/usr/bin/cc
- job_name: Ubuntu 20.04, LLVM 13, latest LDC beta
os: ubuntu-latest
host_dc: ldc-beta
llvm_version: 13
container: liushuyu/ldc-build-environments:20.04-13
cmake_flags: -DRT_SUPPORT_SANITIZERS=ON
- job_name: Ubuntu 20.04, LLVM 12, bootstrap LDC
os: ubuntu-latest
host_dc: ldc-1.19.0
llvm_version: 12
container: liushuyu/ldc-build-environments:20.04-12
cmake_flags: -DBUILD_SHARED_LIBS=ON -DLIB_SUFFIX=64
- job_name: Ubuntu 20.04, LLVM 11, latest DMD beta
os: ubuntu-latest
host_dc: dmd-beta
llvm_version: 11
container: liushuyu/ldc-build-environments:20.04-11
cmake_flags: -DBUILD_SHARED_LIBS=OFF -DRT_SUPPORT_SANITIZERS=ON -DLDC_LINK_MANUALLY=ON
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
env:
# silence `ld: warning: object file (…) was built for newer macOS version (…) than being linked (…)`
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.os == 'macos-14' && '13.6' || '11.6' }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 50
- name: Install ninja
if: runner.os != 'Linux'
uses: symmetryinvestments/gha-setup-ninja@v1
- name: Install D host compiler
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.host_dc }}
- name: Clear LD_LIBRARY_PATH to prevent loading host compiler libs
run: echo "LD_LIBRARY_PATH=" >> $GITHUB_ENV
- name: Install lit
if: runner.os != 'Linux'
run: |
set -euxo pipefail
if [[ '${{ matrix.os }}' == 'macos-14' ]]; then
brew install lit python-setuptools
else
python3 -m pip install --user setuptools wheel
python3 -m pip install --user lit
fi
python3 -c "import lit.main; lit.main.main();" --version . | head -n 1
- name: Try to restore cached LLVM
if: runner.os != 'Linux'
uses: actions/cache@v3
with:
path: llvm
key: llvm-${{ matrix.llvm_version }}-${{ runner.os }}
- name: Download & extract prebuilt vanilla LLVM ${{ matrix.llvm_version }}
if: runner.os != 'Linux'
run: |
set -eux
if [[ -d llvm ]]; then
echo "Already cached"
exit 0
fi
version='${{ matrix.llvm_version }}'
if [[ '${{ runner.os }}' == macOS ]]; then
if [[ "$version" =~ ^1[6-9]\. ]]; then
suffix='arm64-apple-darwin22.0'
else
suffix='x86_64-apple-darwin'
fi
elif [[ "$version" =~ ^1[7-9]\. ]]; then
suffix='x86_64-linux-gnu-ubuntu-22.04' # LLVM 17+
elif [[ "$version" =~ ^1[3-6]\. ]]; then
suffix='x86_64-linux-gnu-ubuntu-18.04' # LLVM 13.0.1+
else
suffix='x86_64-linux-gnu-ubuntu-16.04'
fi
if [[ "$version" = *.* ]]; then
url="https://github.com/llvm/llvm-project/releases/download/llvmorg-$version/clang+llvm-$version-$suffix.tar.xz"
else # short commit SHA of ldc-developers fork
if [[ '${{ runner.os }}' == Linux ]]; then
suffix='linux-x86_64'
elif [[ '${{ runner.os }}' == macOS ]]; then
suffix='osx-arm64'
fi
url="https://github.com/ldc-developers/llvm-project/releases/download/CI/llvm-$version-$suffix.tar.xz"
fi
curl -fL --retry 3 --max-time 300 -o llvm.tar.xz "$url"
mkdir llvm
tar -xf llvm.tar.xz --strip 1 -C llvm
rm llvm.tar.xz
# don't link lib{c++,unwind} libs from LLVM package, they'd need RPATH fiddling
if [[ '${{ runner.os }}' == macOS ]]; then
rm -f llvm/lib/lib{c++,unwind}.*
fi
- name: Build LDC & LDC D unittests & defaultlib unittest runners with extra '${{ matrix.cmake_flags }}'
run: |
set -ex
if [ -z "${LLVM_ROOT_DIR}" ]; then
LLVM_ROOT_DIR="$PWD/llvm"
fi
set -u
cmake -G Ninja . \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ROOT_DIR="${LLVM_ROOT_DIR}" \
-DLDC_LINK_MANUALLY=OFF \
${{ matrix.cmake_flags }}
ninja obj/ldc2.o all ldc2-unittest all-test-runners
bin/ldc2 --version
- name: Run LDC D unittests
if: success() || failure()
run: ctest --output-on-failure -R "ldc2-unittest"
- name: Run LIT testsuite
if: success() || failure()
run: ctest -V -R "lit-tests"
- name: Run DMD testsuite
if: success() || failure()
run: ctest -V -R "dmd-testsuite"
- name: Run defaultlib unittests & druntime integration tests
if: success() || failure()
run: |
set -eux
excludes='dmd-testsuite|lit-tests|ldc2-unittest'
if [[ '${{ runner.os }}' == macOS ]]; then
N=$(sysctl -n hw.logicalcpu)
# FIXME: fails with enabled optimizations on M1 runners
if [[ '${{ matrix.os }}' == macos-14 ]]; then
excludes+='|^std.internal.math.gammafunction(-shared)?$'
fi
else
N=$(nproc)
fi
ctest -j$N --output-on-failure -E "$excludes"