From 23fa7cb3a118d22f1c6db0f2df04a2ca1689a8d7 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Fri, 21 Jun 2024 22:07:07 +0200 Subject: [PATCH] Add ci --- .github/workflows/ci.yml | 138 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c467584 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,138 @@ +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: Checout OOPetris main repo + with: + fetch-depth: "0" + repository: OpenBrickProtocolFoundation/oopetris + ref: main + path: ./oopetris + + + - name: Setup MSVC (Windows) + if: matrix.config.os == 'windows' + uses: TheMrMilchmann/setup-msvc-dev@v3 + with: + arch: x64 + toolset: 14.40 + + - name: Setup GCC (Linux) + if: matrix.config.os == 'ubuntu' + uses: egor-tensin/setup-gcc@v1 + with: + version: 14 + platform: x64 + + - name: Setup Clang (MacOS) + if: matrix.config.os == 'macos' + run: | + brew update + brew install llvm@18 + 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 -y + 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: Configure + run: | + cd oopetris + meson setup build -Dbuildtype=release -Ddefault_library=static -Dclang_libcpp=${{ matrix.config.os == 'macos' && 'enabled' || 'disabled' }} -Donly_build_libs=true ${{ matrix.config.os == 'windows' && '-Db_vscrt=static_from_buildtype' || '' }} + + - name: Build and install Libs + if: matrix.config.os != 'ubuntu' + run: | + cd oopetris + meson install -C build + + - name: Build and install Libs (Linux) + if: matrix.config.os == 'ubuntu' + run: | + cd oopetris + sudo meson install -C build + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Build package + run: | + npm install -D + npm run build --verbose + npm run test + npm pack + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.config.name }} Node.js Wrapper + path: oopetris*.tgz + \ No newline at end of file