mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 21:02:41 +00:00
Add skip-duplicate-actions to avoid rebuilding on push to master when the same code already built successfully on the PR. This saves CI time and resources by detecting when file content (tree hash) matches a previous successful run. - Add pre_job that checks for duplicate runs using fkirc/skip-duplicate-actions - PR builds always run (never skipped) to ensure status before merge - Push builds to master skip if identical code already built successfully - Both linux and windows jobs depend on pre_job skip check
112 lines
3.3 KiB
YAML
112 lines
3.3 KiB
YAML
name: Build
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
|
|
jobs:
|
|
# Check if we should skip this workflow run (e.g., if the same code already built successfully)
|
|
pre_job:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
steps:
|
|
- id: skip_check
|
|
uses: fkirc/skip-duplicate-actions@v5
|
|
with:
|
|
# Skip if a successful run exists for the same tree hash (same file content)
|
|
skip_after_successful_duplicate: 'true'
|
|
# Never skip PR builds - we always want to see status before merge
|
|
do_not_skip: '["pull_request"]'
|
|
|
|
linux:
|
|
needs: pre_job
|
|
if: needs.pre_job.outputs.should_skip != 'true'
|
|
name: Linux
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: akkadius/eqemu-server:v16
|
|
# Run as root to avoid EACCES on GitHub Actions runner file command writes in the container.
|
|
options: --user 0
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v5
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup ccache
|
|
uses: hendrikmuhs/ccache-action@v1.2
|
|
with:
|
|
key: ${{ runner.os }}-ccache-${{ hashFiles('CMakeLists.txt', '.github/workflows/build.yaml') }}
|
|
|
|
- name: Ensure ccache installed
|
|
run: |
|
|
if ! command -v ccache >/dev/null 2>&1; then
|
|
echo "ccache not found in container; installing."
|
|
apt-get update -qq
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ccache
|
|
command -v ccache >/dev/null 2>&1 || { echo "ccache install failed"; exit 1; }
|
|
fi
|
|
|
|
- name: Mark workspace safe
|
|
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
|
|
|
- name: Build
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
mkdir -p build && cd build
|
|
cmake \
|
|
-DEQEMU_BUILD_TESTS=ON \
|
|
-DEQEMU_BUILD_LOGIN=ON \
|
|
-DEQEMU_BUILD_LUA=ON \
|
|
-DEQEMU_BUILD_PERL=ON \
|
|
-DEQEMU_BUILD_CLIENT_FILES=ON \
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
..
|
|
make -j"$(nproc)"
|
|
|
|
- name: Test
|
|
working-directory: ${{ github.workspace }}/build
|
|
run: ./bin/tests
|
|
|
|
windows:
|
|
needs: pre_job
|
|
if: needs.pre_job.outputs.should_skip != 'true'
|
|
name: Windows
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v5
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Enable long paths
|
|
run: git config --global core.longpaths true
|
|
|
|
- name: Setup MSVC environment
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
with:
|
|
arch: x64
|
|
|
|
- name: Configure
|
|
shell: pwsh
|
|
run: |
|
|
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
|
-DEQEMU_BUILD_TESTS=ON `
|
|
-DEQEMU_BUILD_LOGIN=ON `
|
|
-DEQEMU_BUILD_LUA=ON `
|
|
-DEQEMU_BUILD_ZLIB=ON `
|
|
-DEQEMU_BUILD_CLIENT_FILES=ON
|
|
|
|
- name: Build
|
|
shell: pwsh
|
|
run: cmake --build build --config RelWithDebInfo --target ALL_BUILD -- /m
|
|
|
|
- name: Test
|
|
working-directory: build
|
|
run: ./bin/RelWithDebInfo/tests.exe
|