Skip to content

improve all ci's

improve all ci's #39

Workflow file for this run

name: Build CI
on:
push:
branches: ['main']
pull_request:
workflow_dispatch:
jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}-${{ matrix.config.os-version }}
strategy:
fail-fast: false
matrix:
config:
- name: Windows MSVC Release
os: windows
os-version: 2022
environment: msvc
shell: pwsh
- name: Windows MingGW Release
os: windows
os-version: 2022
environment: mingw
architecture: x86_64
shell: 'msys2 {0}'
- name: Windows UCRT Release
os: windows
os-version: 2022
environment: ucrt
architecture: ucrt-x86_64
shell: 'msys2 {0}'
- name: Linux Release
os: ubuntu
os-version: 24.04
use-clang: false
shell: bash
- name: Linux Clang Release (libstdc++)
os: ubuntu
os-version: 24.04
use-clang: true
use-clang_stdlib: false
shell: bash
- name: Linux Clang Release (libc++)
os: ubuntu
os-version: 24.04
use-clang: true
use-clang_stdlib: true
shell: bash
- name: MacOS Release
os: macos
os-version: 13
arm: false
shell: bash
- name: MacOS Release (Arm64)
os: macos
os-version: 14
arm: true
shell: bash
defaults:
run:
shell: ${{ matrix.config.shell }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'
- uses: actions/checkout@v4
name: Checkout OOPetris main repo
with:
fetch-depth: '0'
repository: OpenBrickProtocolFoundation/oopetris
ref: main
path: ./oopetris
submodules: false
- name: Setup MSVC (Windows)
if: matrix.config.os == 'windows' && matrix.config.environment == 'msvc'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
toolset: 14.41
- name: Setup MYSYS2 (Windows)
if: matrix.config.os == 'windows' && ( matrix.config.environment == 'mingw' || matrix.config.environment == 'ucrt' )
uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.config.environment == 'mingw' && 'MINGW64' || 'UCRT64'}}
update: true
install: >-
mingw-w64-${{matrix.config.architecture}}-gcc
mingw-w64-${{matrix.config.architecture}}-ninja
mingw-w64-${{matrix.config.architecture}}-python
mingw-w64-${{matrix.config.architecture}}-python-pip
mingw-w64-${{matrix.config.architecture}}-pkg-config
mingw-w64-${{matrix.config.architecture}}-ca-certificates
mingw-w64-${{matrix.config.architecture}}-cmake
git
- name: Setup Clang (Linux) (libc++)
if: matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
sudo apt-get install libc++-19* libc++abi*19* -y --no-install-recommends
echo "CC=clang-19" >> "$GITHUB_ENV"
echo "CXX=clang++-19" >> "$GITHUB_ENV"
echo "OBJC=clang-19" >> "$GITHUB_ENV"
- name: Setup Clang (Linux) (libstdc++)
if: matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && (! matrix.config.use-clang_stdlib)
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 19
echo "CC=clang-19" >> "$GITHUB_ENV"
echo "CXX=clang++-19" >> "$GITHUB_ENV"
echo "OBJC=clang-19" >> "$GITHUB_ENV"
# Patch the libstd++ library, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115119
# This is a dirty workaround, but it is needed, since gcc 14.2 (where this was patched usptream) is not easily available
# If we use the oracular (Ubuntu 24.10) repos, we could install gcc 14.2, but clang-19 isn't compatible with that
# TODO: remove this, after it works again
sudo patch -p1 /usr/include/c++/14/bits/unicode.h .github/patches/gcc_14_2.diff
- name: Setup GCC (Linux)
if: matrix.config.os == 'ubuntu' && matrix.config.use-clang == false
uses: egor-tensin/setup-gcc@v1
with:
version: 14
platform: x64
- name: Setup Clang (MacOS)
if: matrix.config.os == 'macos'
run: |
brew update
# TODO annotate with lld@19, after that is accepted, we don't want to use lld@20 without manually updating it !
brew install llvm@19 lld
echo "$(brew --prefix)/opt/llvm/bin" >> $GITHUB_PATH
echo "LDFLAGS=-L$(brew --prefix)/opt/llvm/lib -L$(brew --prefix)/opt/llvm/lib/c++ -Wl,-rpath,$(brew --prefix)/opt/llvm/lib/c++" >> "$GITHUB_ENV"
echo "CPPFLAGS=-I$(brew --prefix)/opt/llvm/include" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
echo "OBJC=clang" >> "$GITHUB_ENV"
echo "CC_LD=lld" >> "$GITHUB_ENV"
echo "CXX_LD=lld" >> "$GITHUB_ENV"
echo "OBJC_LD=lld" >> "$GITHUB_ENV"
- name: Setup meson (MacOS)
if: matrix.config.os == 'macos'
run: |
brew update
brew install meson
# NOTE: meson has no dependencies, so --break-system-packages doesn't really break anything!
- name: Setup meson
if: matrix.config.os != 'macos'
run: |
pip install meson --break-system-packages
- name: Install dependencies (Linux)
if: matrix.config.os == 'ubuntu'
run: |
sudo apt-get update
sudo apt-get install ninja-build libreadline-dev -y --no-install-recommends
sudo pip install meson --break-system-packages
- name: Fix pkg-config (Windows MSVC)
if: matrix.config.os == 'windows' && matrix.config.environment == 'msvc'
run: |
Remove-Item -Path C:\Strawberry\ -Recurse
choco install pkgconfiglite
echo "PKG_CONFIG_PATH=C:/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Build and Install OOPetris
run: |
cd oopetris
meson setup build -Dbuildtype=release -Ddefault_library=static -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }} -Donly_build_libs=true ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }} ${{ (matrix.config.os == 'windows' && ( matrix.config.environment == 'mingw' || matrix.config.environment == 'ucrt' )) && '-Dprefix=$RUNNER_TEMP/msys64${MINGW_PREFIX}/' || ''}}
${{ matrix.config.os == 'ubuntu' && 'sudo' || '' }} meson install -C build
- name: Build Wrapper
run: |
meson setup -Dtests=false -Dexample=true build -Dbuildtype=release -Ddefault_library=static -Dclang_libcpp=${{ ( ( matrix.config.os == 'ubuntu' && matrix.config.use-clang == true && matrix.config.use-clang_stdlib ) || matrix.config.os == 'macos' ) && 'enabled' || 'disabled' }} ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }}
meson compile -C build