mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 00:22:42 +01:00
Merge pull request #434 from MaSzyna-EU07/build/ci-compiler-cache-master
ci: shorter CI runs on pull requests
This commit is contained in:
+17
-12
@@ -24,7 +24,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build under Build Wrapper
|
||||
name: Compilation database for SonarQube Cloud
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -73,22 +73,26 @@ jobs:
|
||||
ref/glm/glm/gtx/string_cast.inl
|
||||
grep -n "std::string format(const char\* message" ref/glm/glm/gtx/string_cast.inl
|
||||
|
||||
- name: Install SonarQube Cloud Build Wrapper
|
||||
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6.0.0
|
||||
|
||||
# The analyzer needs the compile command of every file and the headers they include, not the objects: the
|
||||
# compilation database CMake writes at configure time is enough, so nothing is compiled here. The headers the
|
||||
# project generates (version_info.h, the editor icons) are written by the configure step too.
|
||||
- name: Configure (CMake)
|
||||
run: |
|
||||
cmake -S . -B build \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DWITH_ZMQ=OFF -DWITH_OPENVR=OFF -DUSE_LTO=OFF \
|
||||
-DCMAKE_CXX_FLAGS="-Wno-attributes -fno-inline-functions-called-once" \
|
||||
-DPython3_EXECUTABLE="$(which python3)"
|
||||
|
||||
- name: Build under Build Wrapper
|
||||
# glslang writes its build_info.h at build time; its sources are excluded from the analysis, but the target
|
||||
# is cheap and makes the include available should a header of ours reach it
|
||||
- name: Compilation database
|
||||
run: |
|
||||
build-wrapper-linux-x86-64 \
|
||||
--out-dir "${BUILD_WRAPPER_OUT_DIR}" \
|
||||
cmake --build build --config Release -j"$(nproc)"
|
||||
cmake --build build --target glslang-build-info || echo "no glslang-build-info target, nothing generated"
|
||||
mkdir -p "${BUILD_WRAPPER_OUT_DIR}"
|
||||
cp build/compile_commands.json "${BUILD_WRAPPER_OUT_DIR}/compile_commands.json"
|
||||
echo "$(grep -c '"file"' "${BUILD_WRAPPER_OUT_DIR}/compile_commands.json") compile commands"
|
||||
|
||||
# Metadata the trusted workflow needs to identify the PR.
|
||||
# Treated as UNVERIFIED input there and re-checked against the API.
|
||||
@@ -105,13 +109,14 @@ jobs:
|
||||
printf '%s\n' "$PR_HEAD_SHA" > .sonar-meta/head_sha
|
||||
printf '%s\n' "$COMMIT_SHA" > .sonar-meta/sha
|
||||
|
||||
# The C/C++ analyzer needs the sources AND the build-wrapper output.
|
||||
# compile_commands.json holds absolute paths, so the trusted workflow must
|
||||
# unpack this at the same $GITHUB_WORKSPACE path — same repo, so it matches.
|
||||
# The C/C++ analyzer needs the sources AND the compilation database (kept in bw-output/, where the
|
||||
# trusted workflow reads it). compile_commands.json holds absolute paths, so the trusted workflow must
|
||||
# unpack this at the same $GITHUB_WORKSPACE path — same repo, so it matches. build/CMakeFiles stays in:
|
||||
# with nothing compiled it is small, and it holds cmake_pch.hxx, which every command of the targets with
|
||||
# the precompiled header includes (-include).
|
||||
- name: Pack analysis input
|
||||
run: |
|
||||
tar -czf /tmp/workspace.tar.gz \
|
||||
--exclude='./build/CMakeFiles' \
|
||||
--exclude='*.o' \
|
||||
--exclude='*.a' \
|
||||
--exclude='*.so' \
|
||||
|
||||
+219
-25
@@ -23,6 +23,101 @@ env:
|
||||
|
||||
jobs:
|
||||
|
||||
# ============================================================
|
||||
# Whether the binaries are built at all
|
||||
# ============================================================
|
||||
|
||||
# Every push to a branch of this repository runs this workflow, and a pull request from such a branch would run it
|
||||
# once more for the same commit. The push run builds and publishes the download of the branch, so the pull request
|
||||
# run of a branch of this repository builds nothing (the merge with the base is compiled by the Build and Coverage
|
||||
# workflows), except a pull request into master (staging into master): that is the check before a release, of the
|
||||
# merge, with both variants. A pull request from a fork has no push run here and builds as before. A push that changes only
|
||||
# documentation or the data of the scenario tests (which the binaries don't contain) builds nothing either: the
|
||||
# download of the branch stays at its last build, of the same binaries. Pushes to staging and master and manual runs
|
||||
# always build. The checks are job-level conditions, not `paths-ignore` or `branches-ignore` on the trigger: a skipped
|
||||
# job counts as passed, a workflow that doesn't start would leave a required check pending for ever (none is
|
||||
# required today; a skipped matrix job shows under its unexpanded name, `${{ matrix.variant.name }}`). Anything
|
||||
# this job can't decide builds.
|
||||
#
|
||||
# The variant without AVX2 (CPUs older than Haswell, 2013) is the same sources with one compiler switch: it is built
|
||||
# for master only (pushes to master, pull requests into master, so every staging into master) and by a manual run.
|
||||
# It builds no unit tests: they run in the AVX2 build of the same commit.
|
||||
changes:
|
||||
name: Whether to build
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
outputs:
|
||||
build: ${{ steps.decide.outputs.build }}
|
||||
variants: ${{ steps.decide.outputs.variants }}
|
||||
noavx2: ${{ steps.decide.outputs.noavx2 }}
|
||||
steps:
|
||||
- name: Decide from the event and the changed files
|
||||
id: decide
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
REPO: ${{ github.repository }}
|
||||
REF: ${{ github.ref }}
|
||||
SHA: ${{ github.sha }}
|
||||
BEFORE: ${{ github.event.before }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
BASE_REF: ${{ github.base_ref }}
|
||||
run: |
|
||||
avx2='{"name":"AVX2","suffix":"avx2","cmake_flags":"-DENABLE_AVX2=ON","tests":true}'
|
||||
noavx2='{"name":"No AVX2","suffix":"noavx2","cmake_flags":"-DENABLE_AVX2=OFF -DWITH_TESTS=OFF","tests":false}'
|
||||
if [ "$EVENT_NAME" = workflow_dispatch ] \
|
||||
|| { [ "$EVENT_NAME" = push ] && [ "$REF" = refs/heads/master ]; } \
|
||||
|| { [ "$EVENT_NAME" = pull_request ] && [ "$BASE_REF" = master ]; }; then
|
||||
echo "variants=[$avx2,$noavx2]" >> "$GITHUB_OUTPUT"
|
||||
echo "noavx2=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "variants=[$avx2]" >> "$GITHUB_OUTPUT"
|
||||
echo "noavx2=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
build() { echo "$1"; echo "build=true" >> "$GITHUB_OUTPUT"; exit 0; }
|
||||
case "$EVENT_NAME" in
|
||||
pull_request)
|
||||
[ "$BASE_REF" != master ] || build "A pull request into master, building the merge."
|
||||
if [ "$PR_HEAD_REPO" = "$REPO" ]; then
|
||||
echo "A branch of this repository: its push run builds this commit."
|
||||
echo "build=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
files="$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" --jq '.[] | .filename, (.previous_filename // empty)')" \
|
||||
|| build "The files of the pull request are not available, building." ;;
|
||||
push)
|
||||
case "$REF" in
|
||||
refs/heads/staging|refs/heads/master) build "A push to staging or master, building." ;;
|
||||
esac
|
||||
# a new branch (before = zeros) against staging, then master; a later push against the commit before it
|
||||
if [ -n "$BEFORE" ] && [ "$BEFORE" != 0000000000000000000000000000000000000000 ]; then
|
||||
bases="$BEFORE"
|
||||
else
|
||||
bases="staging master"
|
||||
fi
|
||||
files=""
|
||||
for base in $bases; do
|
||||
# the compare lists at most 300 files: more than that, or no list, builds
|
||||
if out="$(gh api "repos/$REPO/compare/$base...$SHA" --jq 'if (.files | length) < 300 then (.files[] | .filename, (.previous_filename // empty)) else error("too many files") end')"; then
|
||||
files="$out"
|
||||
break
|
||||
fi
|
||||
done ;;
|
||||
*) build "A manual run, building." ;;
|
||||
esac
|
||||
[ -n "$files" ] || build "The list of changed files is not available or empty, building."
|
||||
# what the binaries don't contain: *.md, docs/, LICENSE and the scenario tests (cases and their runner)
|
||||
# (not *.txt: CMakeLists.txt is code; tests/unit is built into the binaries' test run)
|
||||
if printf '%s\n' "$files" | grep -Evq '(\.md$|^docs/|^LICENSE|^tests/scenarios/)'; then
|
||||
build "Code changed, building."
|
||||
fi
|
||||
echo "Only documentation or scenario test data changed, the binaries are not built."
|
||||
echo "build=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# ============================================================
|
||||
# Windows / MSVC
|
||||
# ============================================================
|
||||
@@ -37,6 +132,8 @@ jobs:
|
||||
|
||||
windows:
|
||||
name: Windows x64 / MSVC / ${{ matrix.variant.name }}
|
||||
needs: changes
|
||||
if: needs.changes.outputs.build == 'true'
|
||||
runs-on: windows-2022
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-windows-${{ matrix.variant.suffix }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }}
|
||||
@@ -45,13 +142,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
variant:
|
||||
- name: "AVX2"
|
||||
suffix: "avx2"
|
||||
cmake_flags: "-DENABLE_AVX2=ON"
|
||||
- name: "No AVX2"
|
||||
suffix: "noavx2"
|
||||
cmake_flags: "-DENABLE_AVX2=OFF"
|
||||
# AVX2 always, without AVX2 for master only: see the job `changes`
|
||||
variant: ${{ fromJSON(needs.changes.outputs.variants) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -101,6 +193,7 @@ jobs:
|
||||
# the unit tests run at the end of the build and load lua51.dll (the Lua screens), but ref/luajit has only its import
|
||||
# library. LuaJIT of the same 2.0 line is built here and put on PATH for them; it doesn't go into the uploaded build
|
||||
- name: Build lua51.dll for the unit tests
|
||||
if: matrix.variant.tests
|
||||
shell: cmd
|
||||
run: |
|
||||
for /f "usebackq delims=" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSDIR=%%i"
|
||||
@@ -370,7 +463,14 @@ jobs:
|
||||
|
||||
linux:
|
||||
name: Linux x64 / GCC / ${{ matrix.variant.name }}
|
||||
needs: changes
|
||||
if: needs.changes.outputs.build == 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
# the key of a compiler cache saved here, one output per variant (a matrix job's outputs are shared by its legs):
|
||||
# the job linux-ccache-cleanup deletes the older ones, so this job needs no write access
|
||||
outputs:
|
||||
ccache-key-avx2: ${{ steps.ccache-saved.outputs.avx2 }}
|
||||
ccache-key-noavx2: ${{ steps.ccache-saved.outputs.noavx2 }}
|
||||
# see the notes above the windows job: two variants, each with a concurrency group of its own
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-linux-${{ matrix.variant.suffix }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }}
|
||||
@@ -379,13 +479,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
variant:
|
||||
- name: "AVX2"
|
||||
suffix: "avx2"
|
||||
cmake_flags: "-DENABLE_AVX2=ON"
|
||||
- name: "No AVX2"
|
||||
suffix: "noavx2"
|
||||
cmake_flags: "-DENABLE_AVX2=OFF"
|
||||
# AVX2 always, without AVX2 for master only: see the job `changes`
|
||||
variant: ${{ fromJSON(needs.changes.outputs.variants) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
@@ -412,6 +507,7 @@ jobs:
|
||||
with:
|
||||
packages: >-
|
||||
build-essential
|
||||
ccache
|
||||
pkg-config
|
||||
libasound2-dev
|
||||
libpulse-dev
|
||||
@@ -475,11 +571,39 @@ jobs:
|
||||
cmake --version
|
||||
python --version
|
||||
|
||||
# The compiler cache (ccache), one per variant. Only the runs on staging and master save it (the step after the
|
||||
# build) and delete their older ones; a pull request takes the newest one of its variant, and so recompiles just
|
||||
# what it changed. A pull request can read the caches of its base branch and of the default branch, not those of
|
||||
# other pull requests. A push of another branch can read only master's, so it hits only as far as the branch
|
||||
# still matches master.
|
||||
# The compiler version is in the key, so a new GCC of the runner image starts a cache of its own, with no
|
||||
# fallback to the cache of the old one, which ccache couldn't use (the compiler is part of its hash).
|
||||
- name: Compiler cache key
|
||||
id: ccache-key
|
||||
run: echo "gcc=$(g++ -dumpfullversion)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore the compiler cache
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}/ccache
|
||||
key: ccache-linux-${{ matrix.variant.suffix }}-gcc${{ steps.ccache-key.outputs.gcc }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
ccache-linux-${{ matrix.variant.suffix }}-gcc${{ steps.ccache-key.outputs.gcc }}-
|
||||
|
||||
- name: Configure
|
||||
env:
|
||||
CCACHE_DIR: ${{ runner.temp }}/ccache
|
||||
CCACHE_MAXSIZE: 500M
|
||||
# the game and eu07_core use a precompiled header (stdafx.h): ccache caches such compilations only with
|
||||
# this sloppiness, else it compiles every file in full
|
||||
CCACHE_SLOPPINESS: pch_defines,time_macros,include_file_mtime,include_file_ctime
|
||||
run: |
|
||||
ccache --zero-stats
|
||||
cmake \
|
||||
-S . \
|
||||
-B build \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_BUILD_TYPE="${CONFIG_LINUX}" \
|
||||
-DWITH_ZMQ=OFF \
|
||||
-DWITH_OPENVR=OFF \
|
||||
@@ -488,11 +612,36 @@ jobs:
|
||||
-DPython3_EXECUTABLE="${{ steps.python.outputs.python-path }}" \
|
||||
-DCMAKE_CXX_FLAGS="-Wno-attributes -fno-inline-functions-called-once"
|
||||
|
||||
# CCACHE_BASEDIR makes the paths relative, so a cache made on another checkout path still hits
|
||||
- name: Build
|
||||
env:
|
||||
CCACHE_DIR: ${{ runner.temp }}/ccache
|
||||
CCACHE_MAXSIZE: 500M
|
||||
CCACHE_BASEDIR: ${{ github.workspace }}
|
||||
# the game and eu07_core use a precompiled header (stdafx.h): ccache caches such compilations only with
|
||||
# this sloppiness, else it compiles every file in full
|
||||
CCACHE_SLOPPINESS: pch_defines,time_macros,include_file_mtime,include_file_ctime
|
||||
run: |
|
||||
cmake \
|
||||
--build build \
|
||||
--parallel "$(nproc)"
|
||||
ccache --show-stats
|
||||
|
||||
- name: Save the compiler cache
|
||||
id: ccache-save
|
||||
if: ${{ !cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master') }}
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: ${{ runner.temp }}/ccache
|
||||
key: ccache-linux-${{ matrix.variant.suffix }}-gcc${{ steps.ccache-key.outputs.gcc }}-${{ github.sha }}
|
||||
|
||||
# for the job linux-ccache-cleanup, which deletes the older caches of this branch and variant
|
||||
- name: Pass on the saved compiler cache key
|
||||
id: ccache-saved
|
||||
if: ${{ !cancelled() && steps.ccache-save.outcome == 'success' }}
|
||||
env:
|
||||
KEY: ccache-linux-${{ matrix.variant.suffix }}-gcc${{ steps.ccache-key.outputs.gcc }}-${{ github.sha }}
|
||||
run: echo "${{ matrix.variant.suffix }}=$KEY" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# the build copies the shared libraries next to the game (CMake_modules/bundle_runtime_libs.cmake) and the
|
||||
# game looks for them there first ($ORIGIN): each one it loads from outside build/bin has to be one of the system
|
||||
@@ -557,13 +706,49 @@ jobs:
|
||||
retention-days: 14
|
||||
|
||||
|
||||
# a cache can't be written over, so every save of the linux job is a new key of up to 0.5 GB. the older ones of the
|
||||
# branch and variant (of any GCC) go right after it, or they'd fill the 10 GB of the repository and push out the
|
||||
# small caches (audio-dlls-*, apt-*). only the caches created before the one saved go: when two runs of a branch end
|
||||
# together, the one which saved later keeps its cache. a failed delete only leaves the old cache to the eviction
|
||||
linux-ccache-cleanup:
|
||||
name: Linux / delete the older compiler caches
|
||||
needs: linux
|
||||
if: ${{ !cancelled() && (needs.linux.outputs.ccache-key-avx2 != '' || needs.linux.outputs.ccache-key-noavx2 != '') }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
actions: write
|
||||
|
||||
steps:
|
||||
- name: Delete the older compiler caches
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
SAVED: ${{ needs.linux.outputs.ccache-key-avx2 }} ${{ needs.linux.outputs.ccache-key-noavx2 }}
|
||||
run: |
|
||||
# the ids of the caches created before the one saved (env.KEEP); none when it isn't listed. the times are
|
||||
# compared as numbers, as their fractions of a second can have any number of digits
|
||||
older='
|
||||
def t: capture("^(?<s>[^.Z]+)(?<f>[.][0-9]+)?Z$") | ((.s + "Z") | fromdateiso8601) + (("0" + (.f // "")) | tonumber);
|
||||
(map(select(.key == env.KEEP)) | first | .createdAt) as $saved
|
||||
| if $saved == null then empty else ($saved | t) as $at | .[] | select((.createdAt | t) < $at) | .id end'
|
||||
for KEEP in $SAVED; do
|
||||
export KEEP
|
||||
# the key without its GCC version and commit: ccache-linux-<variant>-
|
||||
prefix="${KEEP%%-gcc*}-"
|
||||
gh cache list --repo "$GITHUB_REPOSITORY" --ref "$GITHUB_REF" --key "$prefix" --limit 100 \
|
||||
--json id,key,createdAt --jq "$older" |
|
||||
while read -r id; do
|
||||
gh cache delete "$id" --repo "$GITHUB_REPOSITORY" || echo "::warning::cache $id not deleted"
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Public download: release assets need no GitHub account
|
||||
# ============================================================
|
||||
|
||||
publish:
|
||||
name: Publish public download
|
||||
needs: [windows, linux]
|
||||
needs: [changes, windows, linux]
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
@@ -581,6 +766,7 @@ jobs:
|
||||
path: dist/maszyna-windows-x64
|
||||
|
||||
- name: Download Windows build (no AVX2)
|
||||
if: needs.changes.outputs.noavx2 == 'true'
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: maszyna-windows-x64-noavx2-${{ env.CONFIG_WIN }}
|
||||
@@ -593,6 +779,7 @@ jobs:
|
||||
path: dist/maszyna-linux-x64
|
||||
|
||||
- name: Download Linux build (no AVX2)
|
||||
if: needs.changes.outputs.noavx2 == 'true'
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: maszyna-linux-x64-noavx2-${{ env.CONFIG_LINUX }}
|
||||
@@ -604,6 +791,7 @@ jobs:
|
||||
|
||||
# the artifacts lose the executable bit
|
||||
for dir in maszyna-linux-x64 maszyna-linux-x64-noavx2; do
|
||||
[ -d "$dir" ] || continue
|
||||
find "$dir" -type f -exec sh -c 'file -b "$1" | grep -q "^ELF" && chmod +x "$1"' _ {} \;
|
||||
if [ -d "$dir/linuxpython64/bin" ]; then
|
||||
chmod +x "$dir"/linuxpython64/bin/*
|
||||
@@ -611,9 +799,12 @@ jobs:
|
||||
done
|
||||
|
||||
(cd maszyna-windows-x64 && zip -qr9 ../maszyna-windows-x64.zip .)
|
||||
(cd maszyna-windows-x64-noavx2 && zip -qr9 ../maszyna-windows-x64-noavx2.zip .)
|
||||
tar -czf maszyna-linux-x64.tar.gz -C maszyna-linux-x64 .
|
||||
tar -czf maszyna-linux-x64-noavx2.tar.gz -C maszyna-linux-x64-noavx2 .
|
||||
# without AVX2: master only
|
||||
if [ -d maszyna-windows-x64-noavx2 ]; then
|
||||
(cd maszyna-windows-x64-noavx2 && zip -qr9 ../maszyna-windows-x64-noavx2.zip .)
|
||||
tar -czf maszyna-linux-x64-noavx2.tar.gz -C maszyna-linux-x64-noavx2 .
|
||||
fi
|
||||
ls -la
|
||||
|
||||
- name: Publish rolling release of the branch
|
||||
@@ -628,23 +819,26 @@ jobs:
|
||||
tag="build-$slug"
|
||||
base="${{ github.server_url }}/${{ github.repository }}/releases/download/$tag"
|
||||
|
||||
assets=(dist/maszyna-windows-x64.zip dist/maszyna-linux-x64.tar.gz)
|
||||
links=("- Windows: $base/maszyna-windows-x64.zip" "- Linux: $base/maszyna-linux-x64.tar.gz")
|
||||
if [ -f dist/maszyna-windows-x64-noavx2.zip ]; then
|
||||
assets+=(dist/maszyna-windows-x64-noavx2.zip dist/maszyna-linux-x64-noavx2.tar.gz)
|
||||
links+=("- Windows, CPUs without AVX2 (older than Haswell, 2013): $base/maszyna-windows-x64-noavx2.zip"
|
||||
"- Linux, CPUs without AVX2: $base/maszyna-linux-x64-noavx2.tar.gz")
|
||||
else
|
||||
links+=("- CPUs without AVX2 (older than Haswell, 2013): built for master only, see the release build-master")
|
||||
fi
|
||||
notes="$(printf '%s\n' \
|
||||
"Automatic build of branch \`$BRANCH\`, commit $SHA, replaced by every push to the branch." \
|
||||
"" \
|
||||
"Download without a GitHub account:" \
|
||||
"- Windows: $base/maszyna-windows-x64.zip" \
|
||||
"- Windows, CPUs without AVX2 (older than Haswell, 2013): $base/maszyna-windows-x64-noavx2.zip" \
|
||||
"- Linux: $base/maszyna-linux-x64.tar.gz" \
|
||||
"- Linux, CPUs without AVX2: $base/maszyna-linux-x64-noavx2.tar.gz" \
|
||||
"${links[@]}" \
|
||||
"" \
|
||||
"Unpack over a MaSzyna installation (the game data isn't included). Build log: $RUN_URL")"
|
||||
|
||||
gh release delete "$tag" --yes --cleanup-tag || true
|
||||
gh release create "$tag" \
|
||||
dist/maszyna-windows-x64.zip \
|
||||
dist/maszyna-windows-x64-noavx2.zip \
|
||||
dist/maszyna-linux-x64.tar.gz \
|
||||
dist/maszyna-linux-x64-noavx2.tar.gz \
|
||||
"${assets[@]}" \
|
||||
--target "$SHA" \
|
||||
--prerelease \
|
||||
--latest=false \
|
||||
|
||||
@@ -28,8 +28,49 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# A pull request that changes only documentation or the scenario tests (cases and their runner, which aren't built)
|
||||
# doesn't need the coverage build. The check is a job-level
|
||||
# condition, not `paths-ignore` on the trigger: a workflow that doesn't start leaves a required check "pending"
|
||||
# for ever, while a skipped job (its name is fixed) counts as passed. A push, and anything this step can't
|
||||
# decide, runs the build.
|
||||
changes:
|
||||
name: Which files changed
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
pull-requests: read
|
||||
outputs:
|
||||
code: ${{ steps.files.outputs.code }}
|
||||
steps:
|
||||
- name: List the changed files
|
||||
id: files
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
REPO: ${{ github.repository }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: |
|
||||
if [ "$EVENT_NAME" != pull_request ]; then
|
||||
echo "code=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
if ! files="$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" --jq '.[] | .filename, (.previous_filename // empty)')" || [ -z "$files" ]; then
|
||||
echo "The list of changed files is not available, building."
|
||||
echo "code=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
# what is not built: *.md, docs/, LICENSE and tests/scenarios/ (not *.txt: CMakeLists.txt is code)
|
||||
if printf '%s\n' "$files" | grep -Evq '(\.md$|^docs/|^LICENSE|^tests/scenarios/)'; then
|
||||
echo "code=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Only documentation or scenario tests changed, the coverage build is skipped."
|
||||
echo "code=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
coverage:
|
||||
name: Unit test coverage (GCC)
|
||||
needs: changes
|
||||
if: needs.changes.outputs.code == 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 60
|
||||
permissions:
|
||||
|
||||
Reference in New Issue
Block a user