Skip to content

Commit 23fa7cb

Browse files
committed
Add ci
1 parent 50fb2ae commit 23fa7cb

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

.github/workflows/ci.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Build CI
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: ${{ matrix.config.name }}
12+
runs-on: ${{ matrix.config.os }}-${{ matrix.config.os-version }}
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
config:
18+
- name: Windows
19+
os: windows
20+
os-version: 2022
21+
22+
- name: Linux
23+
os: ubuntu
24+
os-version: 24.04
25+
26+
- name: MacOS
27+
os: macos
28+
os-version: 13
29+
30+
- name: MacOS (Arm64)
31+
os: macos
32+
os-version: 14
33+
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
with:
38+
fetch-depth: "0"
39+
40+
- uses: actions/checkout@v4
41+
name: Checout OOPetris main repo
42+
with:
43+
fetch-depth: "0"
44+
repository: OpenBrickProtocolFoundation/oopetris
45+
ref: main
46+
path: ./oopetris
47+
48+
49+
- name: Setup MSVC (Windows)
50+
if: matrix.config.os == 'windows'
51+
uses: TheMrMilchmann/setup-msvc-dev@v3
52+
with:
53+
arch: x64
54+
toolset: 14.40
55+
56+
- name: Setup GCC (Linux)
57+
if: matrix.config.os == 'ubuntu'
58+
uses: egor-tensin/setup-gcc@v1
59+
with:
60+
version: 14
61+
platform: x64
62+
63+
- name: Setup Clang (MacOS)
64+
if: matrix.config.os == 'macos'
65+
run: |
66+
brew update
67+
brew install llvm@18
68+
echo "$(brew --prefix)/opt/llvm/bin" >> $GITHUB_PATH
69+
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"
70+
echo "CPPFLAGS=-I$(brew --prefix)/opt/llvm/include" >> "$GITHUB_ENV"
71+
echo "CC=clang" >> "$GITHUB_ENV"
72+
echo "CXX=clang++" >> "$GITHUB_ENV"
73+
echo "OBJC=clang" >> "$GITHUB_ENV"
74+
echo "CC_LD=lld" >> "$GITHUB_ENV"
75+
echo "CXX_LD=lld" >> "$GITHUB_ENV"
76+
echo "OBJC_LD=lld" >> "$GITHUB_ENV"
77+
78+
- name: Setup meson (MacOS)
79+
if: matrix.config.os == 'macos'
80+
run: |
81+
brew update
82+
brew install meson
83+
84+
# NOTE: meson has no dependencies, so --break-system-packages doesn't really break anything!
85+
- name: Setup meson
86+
if: matrix.config.os != 'macos'
87+
run: |
88+
pip install meson --break-system-packages
89+
90+
- name: Install dependencies (Linux)
91+
if: matrix.config.os == 'ubuntu'
92+
run: |
93+
sudo apt-get update
94+
sudo apt-get install ninja-build -y
95+
sudo pip install meson --break-system-packages
96+
97+
- name: Fix pkg-config (Windows)
98+
if: matrix.config.os == 'windows'
99+
run: |
100+
Remove-Item -Path C:\Strawberry\ -Recurse
101+
choco install pkgconfiglite
102+
echo "PKG_CONFIG_PATH=C:/lib/pkgconfig" | Out-File -FilePath $env:GITHUB_ENV -Append
103+
104+
- name: Configure
105+
run: |
106+
cd oopetris
107+
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' || '' }}
108+
109+
- name: Build and install Libs
110+
if: matrix.config.os != 'ubuntu'
111+
run: |
112+
cd oopetris
113+
meson install -C build
114+
115+
- name: Build and install Libs (Linux)
116+
if: matrix.config.os == 'ubuntu'
117+
run: |
118+
cd oopetris
119+
sudo meson install -C build
120+
121+
- name: Install Node.js
122+
uses: actions/setup-node@v4
123+
with:
124+
node-version: 20
125+
126+
- name: Build package
127+
run: |
128+
npm install -D
129+
npm run build --verbose
130+
npm run test
131+
npm pack
132+
133+
- name: Upload artifacts
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: ${{ matrix.config.name }} Node.js Wrapper
137+
path: oopetris*.tgz
138+

0 commit comments

Comments
 (0)