Skip to content

Bundle required shared libraries with Linux client #195

Bundle required shared libraries with Linux client

Bundle required shared libraries with Linux client #195

name: Build-and-Quality
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-sdl3-linux:
name: Build SDL3 for Linux
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Cache SDL3 libraries
id: cache-sdl3
uses: actions/cache@v4
with:
path: /tmp/sdl3-install
key: sdl3-linux-${{ steps.week.outputs.week }}
- name: Install build dependencies
if: steps.cache-sdl3.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y \
cmake \
ninja-build \
libasound2-dev \
libpulse-dev \
libaudio-dev \
libfribidi-dev \
libjack-dev \
libsndio-dev \
libusb-1.0-0-dev \
libx11-dev \
libxext-dev \
libxrandr-dev \
libxcursor-dev \
libxfixes-dev \
libxi-dev \
libxss-dev \
libxtst-dev \
libwayland-dev \
libxkbcommon-dev \
libdrm-dev \
libgbm-dev \
libgl1-mesa-dev \
libgles2-mesa-dev \
libegl1-mesa-dev \
libdbus-1-dev \
libibus-1.0-dev \
libudev-dev \
libthai-dev
- name: Build SDL3 from source
if: steps.cache-sdl3.outputs.cache-hit != 'true'
run: |
cd /tmp
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git
cmake -S SDL -B SDL-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/tmp/sdl3-install \
-DSDL_STATIC=OFF
cmake --build SDL-build
cmake --install SDL-build
rm -rf SDL SDL-build
- name: Build SDL3_mixer from source
if: steps.cache-sdl3.outputs.cache-hit != 'true'
env:
SDL3_MIXER_VERSION: prerelease-3.1.2
run: |
cd /tmp
curl -sL https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/${SDL3_MIXER_VERSION}.tar.gz | tar xz
cmake -S SDL_mixer-${SDL3_MIXER_VERSION} -B SDL_mixer-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/tmp/sdl3-install \
-DCMAKE_PREFIX_PATH=/tmp/sdl3-install \
-DSDL3MIXER_VENDORED=ON
cmake --build SDL_mixer-build
cmake --install SDL_mixer-build
rm -rf SDL_mixer-${SDL3_MIXER_VERSION} SDL_mixer-build
build-sdl3-windows:
name: Build SDL3 for Windows
runs-on: windows-latest
timeout-minutes: 15
defaults:
run:
shell: msys2 {0}
steps:
- name: Setup MSYS2 (clang64)
uses: msys2/setup-msys2@v2
with:
msystem: clang64
path-type: inherit
update: true
install: >
mingw-w64-clang-x86_64-cmake
mingw-w64-clang-x86_64-ninja
git
- name: Get week of year
shell: bash
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
id: week
- name: Cache SDL3 libraries
id: cache-sdl3
uses: actions/cache@v4
with:
path: D:\a\_temp\msys64\sdl3-tmp
key: sdl3-windows-${{ steps.week.outputs.week }}
- name: Create SDL3 install directory
if: steps.cache-sdl3.outputs.cache-hit != 'true'
run: mkdir -p /sdl3-tmp
- name: Build SDL3 from source
if: steps.cache-sdl3.outputs.cache-hit != 'true'
run: |
cd /tmp
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git
cmake -S SDL -B SDL-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/sdl3-tmp \
-DSDL_STATIC=OFF
cmake --build SDL-build
cmake --install SDL-build
rm -rf SDL SDL-build
- name: Build SDL3_mixer from source
if: steps.cache-sdl3.outputs.cache-hit != 'true'
env:
SDL3_MIXER_VERSION: prerelease-3.1.2
run: |
cd /tmp
curl -sL https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/${SDL3_MIXER_VERSION}.tar.gz | tar xz --exclude='*/Xcode'
cmake -S SDL_mixer-${SDL3_MIXER_VERSION} -B SDL_mixer-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/sdl3-tmp \
-DCMAKE_PREFIX_PATH=/sdl3-tmp \
-DSDL3MIXER_VENDORED=ON
cmake --build SDL_mixer-build
cmake --install SDL_mixer-build
rm -rf SDL_mixer-${SDL3_MIXER_VERSION} SDL_mixer-build
build-sdl3-macos:
name: Build SDL3 for macOS
runs-on: macos-latest
timeout-minutes: 15
steps:
- name: Install build dependencies
run: brew install cmake ninja
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Cache SDL3 libraries
id: cache-sdl3
uses: actions/cache@v4
with:
path: |
/opt/homebrew/lib/libSDL3*
/opt/homebrew/lib/pkgconfig/sdl3.pc
/opt/homebrew/lib/pkgconfig/sdl3-mixer.pc
/opt/homebrew/include/SDL3
/opt/homebrew/include/SDL3_mixer
/opt/homebrew/lib/cmake/SDL3
/opt/homebrew/lib/cmake/SDL3_mixer
/opt/homebrew/share/licenses/SDL3
/opt/homebrew/share/licenses/SDL3_mixer
key: sdl3-macos-${{ steps.week.outputs.week }}
- name: Build SDL3 from source
if: steps.cache-sdl3.outputs.cache-hit != 'true'
run: |
cd /tmp
git clone --depth 1 --branch main https://github.com/libsdl-org/SDL.git
cmake -S SDL -B SDL-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/homebrew \
-DCMAKE_INSTALL_NAME_DIR=/opt/homebrew/lib \
-DSDL_STATIC=OFF \
-DSDL_RPATH=OFF
cmake --build SDL-build
sudo cmake --install SDL-build
rm -rf SDL SDL-build
- name: Build SDL3_mixer from source
if: steps.cache-sdl3.outputs.cache-hit != 'true'
env:
SDL3_MIXER_VERSION: prerelease-3.1.2
run: |
cd /tmp
curl -sL https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/${SDL3_MIXER_VERSION}.tar.gz | tar xz
cmake -S SDL_mixer-${SDL3_MIXER_VERSION} -B SDL_mixer-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/homebrew \
-DCMAKE_INSTALL_NAME_DIR=/opt/homebrew/lib \
-DCMAKE_PREFIX_PATH=/opt/homebrew \
-DSDL3MIXER_VENDORED=ON
cmake --build SDL_mixer-build
sudo cmake --install SDL_mixer-build
rm -rf SDL_mixer-${SDL3_MIXER_VERSION} SDL_mixer-build
build-linux:
needs: build-sdl3-linux
name: Build Linux
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Restore SDL3 libraries from cache
uses: actions/cache/restore@v4
with:
path: /tmp/sdl3-install
key: sdl3-linux-${{ steps.week.outputs.week }}
fail-on-cache-miss: true
- name: Install SDL3 libraries
run: |
sudo cp -r /tmp/sdl3-install/* /usr/local/
sudo ldconfig
- name: Install LLVM/Clang 21
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-21 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-21 100
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libpng-dev \
libzip-dev \
zlib1g-dev \
libmimalloc-dev
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
cache-workspaces: astonia_net
- name: Build
run: make linux
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-build
path: |
bin/moac
bin/libastonia_net.so
retention-days: 30
if-no-files-found: error
- name: Upload Mod SDK (Linux headers)
uses: actions/upload-artifact@v4
with:
name: mod-sdk-linux
path: |
src/amod/amod.h
src/amod/amod_structs.h
src/dll.h
src/astonia.h
retention-days: 30
if-no-files-found: error
build-windows:
needs: build-sdl3-windows
name: Build Windows
runs-on: windows-latest
timeout-minutes: 10
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install Rust toolchain (LLVM variant)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable-x86_64-pc-windows-gnullvm
cache: true
cache-workspaces: astonia_net
- name: Setup MSYS2 (clang64)
uses: msys2/setup-msys2@v2
with:
msystem: clang64
path-type: inherit
update: true
install: >
mingw-w64-clang-x86_64-clang
mingw-w64-clang-x86_64-libpng
mingw-w64-clang-x86_64-libzip
mingw-w64-clang-x86_64-dwarfstack
mingw-w64-clang-x86_64-mimalloc
make
git
- name: Get week of year
shell: bash
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
id: week
- name: Restore SDL3 libraries from cache
uses: actions/cache/restore@v4
with:
path: D:\a\_temp\msys64\sdl3-tmp
key: sdl3-windows-${{ steps.week.outputs.week }}
fail-on-cache-miss: true
- name: Install SDL3 libraries
run: cp -r /sdl3-tmp/* /clang64/
- name: Build
run: make CC=clang windows
- name: Copy DLL to bin
run: cp astonia_net/target/x86_64-pc-windows-gnullvm/release/astonia_net.dll bin/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-build
path: |
bin/moac.exe
bin/astonia_net.dll
retention-days: 30
if-no-files-found: error
- name: Upload Mod SDK (Windows)
uses: actions/upload-artifact@v4
with:
name: mod-sdk-windows
path: |
lib/moac.a
lib/moac.lib
src/amod/amod.h
src/amod/amod_structs.h
src/dll.h
src/astonia.h
retention-days: 30
if-no-files-found: error
build-macos-arm:
needs: build-sdl3-macos
name: Build macOS (Apple Silicon)
runs-on: macos-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install LLVM/Clang 21
run: |
brew install llvm@21
echo "/opt/homebrew/opt/llvm@21/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
brew install libzip zlib mimalloc imagemagick
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Restore SDL3 libraries from cache
uses: actions/cache/restore@v4
with:
path: |
/opt/homebrew/lib/libSDL3*
/opt/homebrew/lib/pkgconfig/sdl3.pc
/opt/homebrew/lib/pkgconfig/sdl3-mixer.pc
/opt/homebrew/include/SDL3
/opt/homebrew/include/SDL3_mixer
/opt/homebrew/lib/cmake/SDL3
/opt/homebrew/lib/cmake/SDL3_mixer
/opt/homebrew/share/licenses/SDL3
/opt/homebrew/share/licenses/SDL3_mixer
key: sdl3-macos-${{ steps.week.outputs.week }}
fail-on-cache-miss: true
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: aarch64-apple-darwin
cache: true
cache-workspaces: astonia_net
- name: Build
run: make macos
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-arm-build
path: |
bin/moac
bin/libastonia_net.dylib
retention-days: 30
if-no-files-found: error
build-docker-linux:
name: Build Linux (Docker/Zig)
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Build with Docker (Zig)
run: make docker-linux
- name: Verify artifacts
run: |
test -f bin/moac
test -f bin/libastonia_net.so
file bin/moac
- name: Upload Docker build artifacts
uses: actions/upload-artifact@v4
with:
name: docker-linux-build
path: |
bin/moac
bin/libastonia_net.so
retention-days: 30
if-no-files-found: error
test:
name: Run Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [build-sdl3-linux]
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
lfs: true
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Restore SDL3 libraries from cache
uses: actions/cache/restore@v4
with:
path: /tmp/sdl3-install
key: sdl3-linux-${{ steps.week.outputs.week }}
fail-on-cache-miss: true
- name: Install SDL3 libraries
run: |
sudo cp -r /tmp/sdl3-install/* /usr/local/
sudo ldconfig
- name: Install LLVM/Clang 21
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-21 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-21 100
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libpng-dev \
libzip-dev \
zlib1g-dev \
libmimalloc-dev
- name: Run tests
run: make test
# Format checking for C code only
format-check:
name: C Format Check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install clang-format-21
uses: ./.github/actions/setup-llvm-toolchain
with:
llvm-version: "21"
packages: clang-format-21
- name: Run C format check script
run: scripts/check-format-c.sh
# Static analysis for C code
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [build-sdl3-linux]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Restore SDL3 libraries from cache
uses: actions/cache/restore@v4
with:
path: /tmp/sdl3-install
key: sdl3-linux-${{ steps.week.outputs.week }}
fail-on-cache-miss: true
- name: Install SDL3 libraries
run: |
sudo cp -r /tmp/sdl3-install/* /usr/local/
sudo ldconfig
- name: Install LLVM toolchain
uses: ./.github/actions/setup-llvm-toolchain
with:
llvm-version: "21"
packages: clang-21 clang-tidy-21 clang-format-21
create-alternatives: "true"
- name: Install additional dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
bear \
cppcheck \
libpng-dev \
libzip-dev \
zlib1g-dev \
libmimalloc-dev
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
cache-workspaces: astonia_net
- name: Run static analysis script
run: scripts/check-static-analysis.sh
- name: Upload analysis reports
uses: actions/upload-artifact@v4
if: always()
with:
name: static-analysis-reports
path: build/logs/*.log
retention-days: 90
# Rust formatting check
rust-format-check:
name: Rust Format Check
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
cache: true
cache-workspaces: astonia_net
- name: Run Rust format check script
run: scripts/check-format-rust.sh
# Rust linting (clippy)
rust-lint-check:
name: Rust Linting (clippy)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy
cache: true
cache-workspaces: astonia_net
- name: Run Rust linting script
run: scripts/check-clippy.sh
# File consistency checks
file-checks:
name: File Consistency
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Run file consistency script
run: scripts/check-files.sh
# Sanitizer build test
sanitizer:
name: AddressSanitizer/UBSan Build
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build-sdl3-linux]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get week of year
id: week
run: echo "week=$(date +%Y-W%U)" >> $GITHUB_OUTPUT
- name: Restore SDL3 libraries from cache
uses: actions/cache/restore@v4
with:
path: /tmp/sdl3-install
key: sdl3-linux-${{ steps.week.outputs.week }}
fail-on-cache-miss: true
- name: Install SDL3 libraries
run: |
sudo cp -r /tmp/sdl3-install/* /usr/local/
sudo ldconfig
- name: Install LLVM toolchain
uses: ./.github/actions/setup-llvm-toolchain
with:
llvm-version: "21"
packages: clang-21
create-alternatives: "true"
- name: Install additional dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libpng-dev \
libzip-dev \
zlib1g-dev \
libmimalloc-dev
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
cache-workspaces: astonia_net
- name: Build with sanitizers
run: make sanitizer
env:
CC: clang
- name: Check sanitizer binary
run: |
echo "Sanitizer build successful!"
ls -lh bin/moac-sanitizer
file bin/moac-sanitizer