mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-14 10:04:46 -07:00
add ccache eviction for files older than 7 days
also clean up some of the scripts to be more internally consistent
This commit is contained in:
parent
d2732ac742
commit
a7c3e41d9b
3 changed files with 65 additions and 16 deletions
|
|
@ -10,9 +10,11 @@
|
||||||
# --test runs tests
|
# --test runs tests
|
||||||
# --debug or --release sets the build type ie CMAKE_BUILD_TYPE
|
# --debug or --release sets the build type ie CMAKE_BUILD_TYPE
|
||||||
# --ccache [<size>] uses ccache and shows stats, optionally provide size
|
# --ccache [<size>] uses ccache and shows stats, optionally provide size
|
||||||
|
# --evict-ccache <age> runs ccache eviction based on given age after build
|
||||||
# --dir <dir> sets the name of the build dir, default is "build"
|
# --dir <dir> sets the name of the build dir, default is "build"
|
||||||
|
# --cmake-generator <generator> sets CMAKE_GENERATOR as used by cmake
|
||||||
# --target-macos-version <version> sets the min os version - only used for macOS builds
|
# --target-macos-version <version> sets the min os version - only used for macOS builds
|
||||||
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_NO_CLIENT MAKE_TEST USE_CCACHE CCACHE_SIZE BUILD_DIR CMAKE_GENERATOR TARGET_MACOS_VERSION
|
# uses env: BUILDTYPE MAKE_INSTALL MAKE_PACKAGE PACKAGE_TYPE PACKAGE_SUFFIX MAKE_SERVER MAKE_NO_CLIENT MAKE_TEST USE_CCACHE CCACHE_SIZE CCACHE_EVICTION_AGE BUILD_DIR CMAKE_GENERATOR TARGET_MACOS_VERSION
|
||||||
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir>)
|
# (correspond to args: --debug/--release --install --package <package type> --suffix <suffix> --server --test --ccache <ccache_size> --dir <dir>)
|
||||||
# exitcode: 1 for failure, 3 for invalid arguments
|
# exitcode: 1 for failure, 3 for invalid arguments
|
||||||
|
|
||||||
|
|
@ -71,6 +73,15 @@ while [[ $# != 0 ]]; do
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
'--evict-ccache')
|
||||||
|
shift
|
||||||
|
if [[ $# == 0 ]]; then
|
||||||
|
echo "::error file=$0::--evict-ccache expects an argument"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
CCACHE_EVICTION_AGE=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
'--vcpkg')
|
'--vcpkg')
|
||||||
USE_VCPKG=1
|
USE_VCPKG=1
|
||||||
shift
|
shift
|
||||||
|
|
@ -84,6 +95,15 @@ while [[ $# != 0 ]]; do
|
||||||
BUILD_DIR="$1"
|
BUILD_DIR="$1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
'--cmake-generator')
|
||||||
|
shift
|
||||||
|
if [[ $# == 0 ]]; then
|
||||||
|
echo "::error file=$0::--cmake-generator expects an argument"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
export CMAKE_GENERATOR=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
'--target-macos-version')
|
'--target-macos-version')
|
||||||
shift
|
shift
|
||||||
if [[ $# == 0 ]]; then
|
if [[ $# == 0 ]]; then
|
||||||
|
|
@ -251,11 +271,19 @@ cmake --build . "${buildflags[@]}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
if [[ $USE_CCACHE ]]; then
|
if [[ $USE_CCACHE ]]; then
|
||||||
|
if [[ $CCACHE_EVICTION_AGE ]]; then
|
||||||
|
echo "::group::evict ccache files older than $CCACHE_EVICTION_AGE"
|
||||||
|
ccache --evict-older-than "$CCACHE_EVICTION_AGE"
|
||||||
|
echo "::endgroup::"
|
||||||
|
fi
|
||||||
echo "::group::Show ccache stats again"
|
echo "::group::Show ccache stats again"
|
||||||
ccachestatsverbose
|
ccachestatsverbose
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
elif [[ $CCACHE_EVICTION_AGE ]]; then
|
||||||
|
echo "::error file=$0::ccache eviction is enabled while ccache is disabled!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ $RUNNER_OS == macOS ]]; then
|
if [[ $RUNNER_OS == macOS ]]; then
|
||||||
echo "::group::Inspect Mach-O binaries"
|
echo "::group::Inspect Mach-O binaries"
|
||||||
for app in cockatrice oracle servatrice; do
|
for app in cockatrice oracle servatrice; do
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,28 @@
|
||||||
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
|
# This script is to be used by the ci environment from the project root directory, do not use it from somewhere else.
|
||||||
|
|
||||||
# Creates or loads docker images to use in compilation, creates RUN function to start compilation on the docker image.
|
# Creates or loads docker images to use in compilation, creates RUN function to start compilation on the docker image.
|
||||||
# <arg> sets the name of the docker image, these correspond to directories in .ci
|
#
|
||||||
|
# usage: source <script> <name> [--get] [--build] [--save] [--interactive] [--set-cache <location>]
|
||||||
|
# <name> sets the name of the docker image, these correspond to directories in .ci
|
||||||
# --get loads the image from a previously saved image cache, will build if no image is found
|
# --get loads the image from a previously saved image cache, will build if no image is found
|
||||||
# --build builds the image from the Dockerfile in .ci/$NAME
|
# --build builds the image from the Dockerfile in .ci/$NAME
|
||||||
# --save stores the image, if an image was loaded it will not be stored
|
# --save stores the image, if an image was loaded it will not be stored
|
||||||
# --interactive immediately starts the image interactively for debugging
|
# --interactive immediately starts the image interactively for debugging
|
||||||
# --set-cache <location> sets the location to cache the image or for ccache
|
# --set-cache <location> sets the location to cache the image or for ccache
|
||||||
|
#
|
||||||
# requires: docker
|
# requires: docker
|
||||||
# uses env: NAME CACHE BUILD GET SAVE INTERACTIVE
|
# uses env: NAME CACHE BUILD GET SAVE INTERACTIVE
|
||||||
# (correspond to args: <name> --set-cache <cache> --build --get --save --interactive)
|
# (correspond to args: <name> --set-cache <cache> --build --get --save --interactive)
|
||||||
# sets env: RUN CCACHE_DIR IMAGE_NAME RUN_ARGS RUN_OPTS BUILD_SCRIPT
|
# sets env: RUN CCACHE_DIR IMAGE_NAME RUN_ARGS RUN_OPTS BUILD_SCRIPT
|
||||||
# exitcode: 1 for failure, 2 for missing dockerfile, 3 for invalid arguments
|
# exitcode: 1 for failure, 2 for missing dockerfile, 3 for invalid arguments
|
||||||
|
#
|
||||||
|
# exported RUN function will run the BUILD_SCRIPT inside of the docker container.
|
||||||
|
# note that the docker container will not inherit any environment variables!
|
||||||
|
#
|
||||||
|
# usage: RUN [arguments for build script]
|
||||||
|
# roughly equivalent to `docker run $IMAGE_NAME bash $BUILD_SCRIPT $@`
|
||||||
|
# uses env: CCACHE_DIR IMAGE_NAME RUN_ARGS RUN_OPTS BUILD_SCRIPT
|
||||||
|
# exitcode: 3 for invalid arguments, returns the returncode of docker run
|
||||||
export BUILD_SCRIPT=".ci/compile.sh"
|
export BUILD_SCRIPT=".ci/compile.sh"
|
||||||
|
|
||||||
project_name="cockatrice"
|
project_name="cockatrice"
|
||||||
|
|
@ -41,12 +52,17 @@ while [[ $# != 0 ]]; do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
'--set-cache')
|
'--set-cache')
|
||||||
CACHE=$2
|
shift
|
||||||
|
if [[ $# == 0 ]]; then
|
||||||
|
echo "--set-cache expects an argument" >&2
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
CACHE=$1
|
||||||
|
shift
|
||||||
if ! [[ -d $CACHE ]]; then
|
if ! [[ -d $CACHE ]]; then
|
||||||
echo "could not find cache path: $CACHE" >&2
|
echo "could not find cache path: $CACHE" >&2
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
shift 2
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ ${1:0:1} == - ]]; then
|
if [[ ${1:0:1} == - ]]; then
|
||||||
|
|
@ -149,10 +165,7 @@ function RUN ()
|
||||||
args+=(--mount "type=bind,source=$CCACHE_DIR,target=/.ccache")
|
args+=(--mount "type=bind,source=$CCACHE_DIR,target=/.ccache")
|
||||||
args+=(--env "CCACHE_DIR=/.ccache")
|
args+=(--env "CCACHE_DIR=/.ccache")
|
||||||
fi
|
fi
|
||||||
if [[ -n "$CMAKE_GENERATOR" ]]; then
|
# shellcheck disable=2086
|
||||||
args+=(--env "CMAKE_GENERATOR=$CMAKE_GENERATOR")
|
|
||||||
fi
|
|
||||||
# shellcheck disable=2086
|
|
||||||
docker run "${args[@]}" $RUN_ARGS "$IMAGE_NAME" bash "$BUILD_SCRIPT" $RUN_OPTS "$@"
|
docker run "${args[@]}" $RUN_ARGS "$IMAGE_NAME" bash "$BUILD_SCRIPT" $RUN_OPTS "$@"
|
||||||
return $?
|
return $?
|
||||||
else
|
else
|
||||||
|
|
|
||||||
24
.github/workflows/desktop-build.yml
vendored
24
.github/workflows/desktop-build.yml
vendored
|
|
@ -162,6 +162,7 @@ jobs:
|
||||||
# Cache size over the entire repo is 10Gi:
|
# Cache size over the entire repo is 10Gi:
|
||||||
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
|
||||||
CCACHE_SIZE: 550M
|
CCACHE_SIZE: 550M
|
||||||
|
CCACHE_EVICTION_AGE: 7d
|
||||||
CMAKE_GENERATOR: 'Ninja'
|
CMAKE_GENERATOR: 'Ninja'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -185,26 +186,33 @@ jobs:
|
||||||
- name: Build debug and test
|
- name: Build debug and test
|
||||||
if: matrix.test != 'skip'
|
if: matrix.test != 'skip'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
|
||||||
CMAKE_GENERATOR: '${{env.CMAKE_GENERATOR}}'
|
|
||||||
run: |
|
run: |
|
||||||
source .ci/docker.sh
|
source .ci/docker.sh
|
||||||
RUN --server --debug --test --ccache "$CCACHE_SIZE"
|
RUN --server --debug --test --ccache "$CCACHE_SIZE" \
|
||||||
|
--cmake-generator "$CMAKE_GENERATOR"
|
||||||
|
|
||||||
- name: Build release package
|
- name: Build release package
|
||||||
id: build
|
id: build
|
||||||
if: matrix.package != 'skip'
|
if: matrix.package != 'skip'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
BUILD_DIR: build
|
BUILD_DIR: '${{github.workspace}}/build'
|
||||||
SUFFIX: '-${{matrix.distro}}${{matrix.version}}'
|
SUFFIX: '-${{matrix.distro}}${{matrix.version}}'
|
||||||
package: '${{matrix.package}}'
|
package: '${{matrix.package}}'
|
||||||
CMAKE_GENERATOR: '${{env.CMAKE_GENERATOR}}'
|
server_only: '${{matrix.server_only}}'
|
||||||
NO_CLIENT: ${{matrix.server_only == 'yes' && '--no-client' || '' }}
|
|
||||||
run: |
|
run: |
|
||||||
source .ci/docker.sh
|
source .ci/docker.sh
|
||||||
RUN --server --release --package "$package" --dir "$BUILD_DIR" \
|
args=()
|
||||||
--ccache "$CCACHE_SIZE" $NO_CLIENT
|
if [[ $server_only == yes ]]; then
|
||||||
|
args+=(--no-client)
|
||||||
|
fi
|
||||||
|
if [[ $GITHUB_REF == "refs/heads/master" ]]; then
|
||||||
|
args+=(--evict-ccache "$CCACHE_EVICTION_AGE")
|
||||||
|
fi
|
||||||
|
args+=(--ccache "$CCACHE_SIZE")
|
||||||
|
args+=(--cmake-generator "$CMAKE_GENERATOR")
|
||||||
|
args+=(--dir "$BUILD_DIR")
|
||||||
|
RUN --server --release --package "$package" "${args[@]}"
|
||||||
.ci/name_build.sh
|
.ci/name_build.sh
|
||||||
|
|
||||||
# Delete used cache to emulate a ccache update. See https://github.com/actions/cache/issues/342.
|
# Delete used cache to emulate a ccache update. See https://github.com/actions/cache/issues/342.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue