Skip to content

Update CI

Update CI #20

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
os: windows
os-version: 2022
- name: Linux
os: ubuntu
os-version: 24.04
- name: MacOS
os: macos
os-version: 13
- name: MacOS (Arm64)
os: macos
os-version: 14
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
- uses: actions/checkout@v4
name: Checkout C Wrapper
with:
fetch-depth: '0'
repository: Totto16/oopetris_wrapper_c
ref: main
path: ./oopetris_c_wrapper
submodules: false
- name: Setup MSVC (Windows)
if: matrix.config.os == 'windows'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
toolset: 14.41
- name: Setup GCC (Linux)
if: matrix.config.os == 'ubuntu'
uses: egor-tensin/setup-gcc@v1
with:
version: 14
platform: x64
- name: Setup GCC Environment (Linux)
if: matrix.config.os == 'ubuntu'
run: |
echo "CC=gcc" >> "$GITHUB_ENV"
echo "CXX=g++" >> "$GITHUB_ENV"
echo "CC_LD=gold" >> "$GITHUB_ENV"
echo "CXX_LD=gold" >> "$GITHUB_ENV"
echo "LD=gold" >> "$GITHUB_ENV"
- 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"
echo "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 -y --no-install-recommends
sudo pip install meson --break-system-packages
- name: Fix pkg-config (Windows)
if: matrix.config.os == 'windows'
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=shared -Dclang_libcpp=${{ matrix.config.os == 'macos' && 'enabled' || 'disabled' }} -Donly_build_libs=true ${{ matrix.config.os == 'windows' && '-Db_vscrt=from_buildtype' || '' }}
${{ matrix.config.os == 'ubuntu' && 'sudo' || '' }} meson install -C build
- name: Build and Install C Wrapper
run: |
cd oopetris_c_wrapper
meson setup -Dtests=false -Dexample=false build -Dbuildtype=release -Ddefault_library=shared
${{ matrix.config.os == 'ubuntu' && 'sudo' || '' }} meson install -C build
${{ matrix.config.os == 'ubuntu' && 'sudo ldconfig' || '' }}
- name: Copy shared libraries to the correct place
if: matrix.config.os == 'windows'
run: |
Copy-Item -Path ".\oopetris\build\src\libs\core\oopetris_core-0.dll" -Destination .
Copy-Item -Path ".\oopetris\build\src\libs\recordings\oopetris_recordings-0.dll" -Destination .
Copy-Item -Path ".\oopetris\build\subprojects\fmt-11.0.2\fmt.dll" -Destination .
Copy-Item -Path ".\oopetris_c_wrapper\build\oopetris_c_wrapper-0.dll" -Destination .
- uses: haskell-actions/setup@v2
with:
ghc-version: '9.6.6'
enable-stack: true
stack-version: 'latest'
- name: Build and Test Wrapper
run: |
stack build
stack test
stack run -- test/files/correct.rec
Copy-Item ./ooopetris/build/src/libs/recordings/oopetris_recordings-0.dll -Destination .