mirror of
https://github.com/decompals/wibo.git
synced 2025-10-15 14:45:12 +00:00
Rework CI into a build matrix; update Dockerfiles
This commit is contained in:
parent
8cac50e50e
commit
fd47411fff
125
.github/workflows/ci.yml
vendored
125
.github/workflows/ci.yml
vendored
@ -11,65 +11,94 @@ env:
|
||||
DOCKER_BUILDKIT: 1
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
name: Build and test
|
||||
build:
|
||||
name: Build (${{ matrix.display }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- id: ubuntu-debug
|
||||
display: Debug
|
||||
dockerfile: Dockerfile.ubuntu
|
||||
build_type: Debug
|
||||
image: wibo-host-debug
|
||||
- id: ubuntu-release
|
||||
display: Release
|
||||
dockerfile: Dockerfile.ubuntu
|
||||
build_type: Release
|
||||
image: wibo-host-release
|
||||
- id: static-debug
|
||||
display: Static, Debug
|
||||
dockerfile: Dockerfile
|
||||
build_type: Debug
|
||||
image: wibo-static-debug
|
||||
- id: static-release
|
||||
display: Static, Release
|
||||
dockerfile: Dockerfile
|
||||
build_type: Release
|
||||
image: wibo-static-release
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Build
|
||||
run: >-
|
||||
docker build
|
||||
-f ${{ matrix.dockerfile }}
|
||||
--build-arg build_type=${{ matrix.build_type }}
|
||||
--target build
|
||||
-t ${{ matrix.image }}
|
||||
.
|
||||
|
||||
- name: Tests
|
||||
run: docker run --rm ${{ matrix.image }} ctest --test-dir /wibo/build --output-on-failure
|
||||
|
||||
- name: Export binary
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
file \
|
||||
unzip \
|
||||
wget \
|
||||
cmake \
|
||||
ninja-build \
|
||||
g++-multilib \
|
||||
gcc-mingw-w64-i686 \
|
||||
binutils-mingw-w64-i686
|
||||
rm -rf dist
|
||||
docker build \
|
||||
-f ${{ matrix.dockerfile }} \
|
||||
--build-arg build_type=${{ matrix.build_type }} \
|
||||
--target export \
|
||||
--output dist \
|
||||
.
|
||||
|
||||
- name: Build debug
|
||||
run: docker build --build-arg build_type=Debug --target export --output build_debug .
|
||||
|
||||
- name: Build release
|
||||
run: docker build --build-arg build_type=Release --target export --output build .
|
||||
|
||||
- name: Test
|
||||
shell: bash
|
||||
run: |
|
||||
mv build_debug/wibo build/wibo_debug
|
||||
wget -q https://files.decomp.dev/compilers_latest.zip
|
||||
unzip -q compilers_latest.zip
|
||||
set -x
|
||||
build/wibo_debug Wii/1.7/mwcceppc.exe -nodefaults -c test/test.c -Itest -o test_debug.o
|
||||
file test_debug.o
|
||||
build/wibo Wii/1.7/mwcceppc.exe -nodefaults -c test/test.c -Itest -o test.o
|
||||
file test.o
|
||||
|
||||
- name: Fixture tests
|
||||
run: |
|
||||
cmake -S . -B build_ctest -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DWIBO_ENABLE_FIXTURE_TESTS=ON
|
||||
cmake --build build_ctest
|
||||
ctest --test-dir build_ctest --output-on-failure
|
||||
|
||||
- name: Upload release
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: wibo
|
||||
path: build/wibo
|
||||
name: ${{ matrix.id }}
|
||||
path: dist/wibo
|
||||
|
||||
- name: Upload debug
|
||||
uses: actions/upload-artifact@v4
|
||||
release:
|
||||
name: Publish Release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Download static debug
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: wibo_debug
|
||||
path: build/wibo_debug
|
||||
name: static-debug
|
||||
path: artifacts/static-debug
|
||||
|
||||
- name: Download static release
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: static-release
|
||||
path: artifacts/static-release
|
||||
|
||||
- name: Prepare assets
|
||||
run: |
|
||||
mkdir -p artifacts/out
|
||||
cp artifacts/static-debug/wibo artifacts/out/wibo_debug
|
||||
cp artifacts/static-release/wibo artifacts/out/wibo
|
||||
|
||||
- name: Publish release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: |
|
||||
build/wibo
|
||||
build/wibo_debug
|
||||
artifacts/out/wibo
|
||||
artifacts/out/wibo_debug
|
||||
|
17
Dockerfile
17
Dockerfile
@ -2,16 +2,29 @@
|
||||
FROM --platform=linux/i386 alpine:latest AS build
|
||||
|
||||
# Install dependencies
|
||||
RUN apk add --no-cache cmake ninja g++ linux-headers binutils
|
||||
RUN apk add --no-cache \
|
||||
bash \
|
||||
cmake \
|
||||
ninja \
|
||||
g++ \
|
||||
linux-headers \
|
||||
binutils \
|
||||
mingw-w64-binutils \
|
||||
mingw-w64-gcc
|
||||
|
||||
# Copy source files
|
||||
WORKDIR /wibo
|
||||
COPY . /wibo
|
||||
|
||||
# Build type (Release, Debug, RelWithDebInfo, MinSizeRel)
|
||||
ARG build_type=Release
|
||||
|
||||
# Build static binary
|
||||
RUN cmake -S /wibo -B /wibo/build -G Ninja -DCMAKE_BUILD_TYPE="$build_type" -DCMAKE_CXX_FLAGS="-static" \
|
||||
RUN cmake -S /wibo -B /wibo/build -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="$build_type" \
|
||||
-DCMAKE_CXX_FLAGS="-static" \
|
||||
-DBUILD_TESTING=ON \
|
||||
-DWIBO_ENABLE_FIXTURE_TESTS=ON \
|
||||
&& cmake --build /wibo/build \
|
||||
&& ( [ "$build_type" != "Release" ] || strip -g /wibo/build/wibo )
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Ubuntu 24.04 environment that matches CI toolchain and fixture tests.
|
||||
FROM ubuntu:24.04 AS deps
|
||||
# Build stage
|
||||
FROM ubuntu:24.04 AS build
|
||||
|
||||
# Install dependencies
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
@ -15,14 +17,25 @@ RUN apt-get update \
|
||||
wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy source files
|
||||
WORKDIR /wibo
|
||||
|
||||
FROM deps AS dev
|
||||
COPY . /wibo
|
||||
|
||||
ARG BUILD_TYPE=Debug
|
||||
# Configure default build folders so docker build can cache compilation layers if desired.
|
||||
RUN cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_TESTING=ON -DWIBO_ENABLE_FIXTURE_TESTS=ON \
|
||||
&& cmake --build build
|
||||
# Build type (Release, Debug, RelWithDebInfo, MinSizeRel)
|
||||
ARG build_type=Release
|
||||
|
||||
ENTRYPOINT ["/bin/bash"]
|
||||
RUN cmake -S /wibo -B /wibo/build -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="$build_type" \
|
||||
-DBUILD_TESTING=ON \
|
||||
-DWIBO_ENABLE_FIXTURE_TESTS=ON \
|
||||
&& cmake --build /wibo/build \
|
||||
&& ( [ "$build_type" != "Release" ] || strip -g /wibo/build/wibo )
|
||||
|
||||
# Export binary (usage: docker build -f Dockerfile.ubuntu --target export --output dist .)
|
||||
FROM scratch AS export
|
||||
COPY --from=build /wibo/build/wibo .
|
||||
|
||||
# Runnable container
|
||||
FROM ubuntu:24.04
|
||||
COPY --from=build /wibo/build/wibo /usr/local/sbin/wibo
|
||||
CMD ["/usr/local/sbin/wibo"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user