add caching

This commit is contained in:
Denis Angell
2025-03-29 03:08:58 +01:00
parent 95ab35a185
commit f8d22bbc24
2 changed files with 17 additions and 51 deletions

View File

@@ -2,9 +2,9 @@ name: Release - SH Runner
on:
push:
branches: ["dev", "candidate", "release"]
branches: ["dev", "candidate", "release", "jshooks"]
pull_request:
branches: ["dev", "candidate", "release"]
branches: ["dev", "candidate", "release", "jshooks"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -17,17 +17,6 @@ jobs:
build-and-test:
runs-on: [self-hosted, vanity]
steps:
- name: Clean up any leftover containers from previous runs
run: |
BUILD_CONTAINERS=$(docker ps -q --filter "name=xahaud_cached_builder") || true
if [[ -n "$BUILD_CONTAINERS" ]]; then
echo "Found leftover containers from previous runs, stopping them"
docker stop $BUILD_CONTAINERS || echo "Failed to stop some containers"
docker rm -f $BUILD_CONTAINERS || echo "Failed to remove some containers"
else
echo "No leftover containers found"
fi
- name: Prepare workspace
run: |
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | sed -e 's/[^a-zA-Z0-9._-]/-/g')

View File

@@ -5,42 +5,6 @@
# debugging.
set -ex
which docker 2> /dev/null 2> /dev/null
if [ "$?" -eq "1" ]
then
echo 'Docker not found. Install it first.'
exit 1
fi
stat .git 2> /dev/null 2> /dev/null
if [ "$?" -eq "1" ]
then
echo 'Run this inside the source directory. (.git dir not found).'
exit 1
fi
# Add trap to handle termination
cleanup() {
echo "Script received termination signal - cleaning up containers"
# Get container ID if it exists
if [[ -n "${CONTAINER_NAME:-}" ]]; then
docker stop "${CONTAINER_NAME}" || echo "Failed to stop container (may not exist)"
docker rm -f "${CONTAINER_NAME}" 2>/dev/null || echo "Failed to remove container (may not exist)"
fi
# Find and stop any other build containers that might be running
BUILD_CONTAINERS=$(docker ps -q --filter "name=xahaud_cached_builder")
if [[ -n "$BUILD_CONTAINERS" ]]; then
echo "Stopping other build containers: $BUILD_CONTAINERS"
docker stop $BUILD_CONTAINERS || echo "Failed to stop some containers"
fi
exit 0
}
# Set trap for common termination signals
trap cleanup SIGINT SIGTERM INT TERM
echo "START BUILDING (HOST)"
echo "Cleaning previously built binary"
@@ -66,10 +30,23 @@ echo "-- GITHUB_SHA: $GITHUB_SHA"
echo "-- GITHUB_RUN_NUMBER: $GITHUB_RUN_NUMBER"
echo "-- CONTAINER_NAME: $CONTAINER_NAME"
which docker 2> /dev/null 2> /dev/null
if [ "$?" -eq "1" ]
then
echo 'Docker not found. Install it first.'
exit 1
fi
stat .git 2> /dev/null 2> /dev/null
if [ "$?" -eq "1" ]
then
echo 'Run this inside the source directory. (.git dir not found).'
exit 1
fi
STATIC_CONTAINER=$(docker ps -a | grep $CONTAINER_NAME |wc -l)
#if [[ "$STATIC_CONTAINER" -gt "0" && "$GITHUB_REPOSITORY" != "" ]]; then
if false; then
if [[ "$STATIC_CONTAINER" -gt "0" && "$GITHUB_REPOSITORY" != "" ]]; then
echo "Static container, execute in static container to have max. cache"
docker start $CONTAINER_NAME
docker exec -i $CONTAINER_NAME /hbb_exe/activate-exec bash -x /io/build-core.sh "$GITHUB_REPOSITORY" "$GITHUB_SHA" "$BUILD_CORES" "$GITHUB_RUN_NUMBER"