ci: cache and narrow foundation builds
This commit is contained in:
+58
-22
@@ -6,11 +6,20 @@ on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
# Do not spend a full build on obsolete commits when pushes arrive quickly.
|
||||
concurrency:
|
||||
group: foundation-${{ gitea.ref || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
code: read
|
||||
|
||||
env:
|
||||
UBUNTU_IMAGE: ${{ vars.UBUNTU_IMAGE || 'ubuntu:24.04' }}
|
||||
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT || 'aeternalis' }}
|
||||
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
|
||||
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
|
||||
CACHE_WRITE: '0'
|
||||
|
||||
jobs:
|
||||
checks:
|
||||
@@ -30,11 +39,16 @@ jobs:
|
||||
CHECK_SUITE: ${{ matrix.suite }}
|
||||
run: |
|
||||
set -eu
|
||||
if ! bash tools/ci/ci-paths.sh "$CHECK_SUITE"; then
|
||||
echo "No files relevant to $CHECK_SUITE changed; gate skipped."
|
||||
exit 0
|
||||
fi
|
||||
docker version
|
||||
ci_image="aevolution-ci:${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-$CHECK_SUITE"
|
||||
docker build --progress=plain --file deploy/docker/Dockerfile \
|
||||
--build-arg "UBUNTU_IMAGE=$UBUNTU_IMAGE" \
|
||||
--target "ci-$CHECK_SUITE" --tag "$ci_image" .
|
||||
if [[ "${GITHUB_REF:-}" == refs/heads/main && "${GITHUB_EVENT_NAME:-}" != pull_request && -n "${HARBOR_USERNAME:-}" ]]; then
|
||||
export CACHE_WRITE=1
|
||||
fi
|
||||
bash tools/ci/docker-build.sh "ci-$CHECK_SUITE" "$ci_image" aevolution-ci-cache
|
||||
if [ "$CHECK_SUITE" = tsan ]; then
|
||||
profile="$RUNNER_TEMP/aevolution-tsan-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}.json"
|
||||
node tools/ci/tsan-profile.mjs "$profile"
|
||||
@@ -59,21 +73,27 @@ jobs:
|
||||
- name: Build and smoke-test migration tooling
|
||||
run: |
|
||||
set -eu
|
||||
docker build --file deploy/docker/Dockerfile --target postgres-tools \
|
||||
--build-arg "UBUNTU_IMAGE=$UBUNTU_IMAGE" \
|
||||
--tag "aevolution-postgres-tools:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" .
|
||||
if ! bash tools/ci/ci-paths.sh postgres-tools; then
|
||||
echo 'No migration-tool files changed; gate skipped.'
|
||||
exit 0
|
||||
fi
|
||||
image="aevolution-postgres-tools:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
if [[ "${GITHUB_REF:-}" == refs/heads/main && "${GITHUB_EVENT_NAME:-}" != pull_request && -n "${HARBOR_USERNAME:-}" ]]; then
|
||||
export CACHE_WRITE=1
|
||||
fi
|
||||
bash tools/ci/docker-build.sh postgres-tools "$image" aevolution-postgres-cache
|
||||
docker run --rm --network none --read-only --cap-drop ALL \
|
||||
--entrypoint /opt/postgres/bin/psql \
|
||||
"aevolution-postgres-tools:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" --version
|
||||
--entrypoint /opt/postgres/bin/psql "$image" --version
|
||||
- name: Publish configured migration tools
|
||||
if: ${{ gitea.ref == 'refs/heads/main' && gitea.event_name != 'pull_request' && vars.HARBOR_POSTGRES_REPOSITORY != '' }}
|
||||
env:
|
||||
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT }}
|
||||
HARBOR_REPOSITORY: ${{ vars.HARBOR_POSTGRES_REPOSITORY }}
|
||||
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
|
||||
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
|
||||
run: |
|
||||
export SOURCE_IMAGE="aevolution-postgres-tools:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
if ! docker image inspect "$SOURCE_IMAGE" >/dev/null 2>&1; then
|
||||
echo 'Migration-tools build was skipped; nothing to publish.'
|
||||
exit 0
|
||||
fi
|
||||
bash tools/ci/publish-image.sh
|
||||
|
||||
server-image:
|
||||
@@ -88,18 +108,26 @@ jobs:
|
||||
- name: Build and smoke-test the region server image
|
||||
run: |
|
||||
set -eu
|
||||
if ! bash tools/ci/ci-paths.sh server-image; then
|
||||
echo 'No server-image files changed; gate skipped.'
|
||||
exit 0
|
||||
fi
|
||||
image="aevolution-server:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
docker build --file deploy/docker/Dockerfile --target server-runtime --build-arg "UBUNTU_IMAGE=$UBUNTU_IMAGE" --tag "$image" .
|
||||
if [[ "${GITHUB_REF:-}" == refs/heads/main && "${GITHUB_EVENT_NAME:-}" != pull_request && -n "${HARBOR_USERNAME:-}" ]]; then
|
||||
export CACHE_WRITE=1
|
||||
fi
|
||||
bash tools/ci/docker-build.sh server-runtime "$image" aevolution-server-cache
|
||||
bash tools/ci/server-image-smoke.sh "$image"
|
||||
- name: Publish configured region server image
|
||||
if: ${{ gitea.ref == 'refs/heads/main' && gitea.event_name != 'pull_request' && vars.HARBOR_SERVER_REPOSITORY != '' }}
|
||||
env:
|
||||
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT }}
|
||||
HARBOR_REPOSITORY: ${{ vars.HARBOR_SERVER_REPOSITORY }}
|
||||
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
|
||||
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
|
||||
run: |
|
||||
export SOURCE_IMAGE="aevolution-server:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
if ! docker image inspect "$SOURCE_IMAGE" >/dev/null 2>&1; then
|
||||
echo 'Server-image build was skipped; nothing to publish.'
|
||||
exit 0
|
||||
fi
|
||||
bash tools/ci/publish-image.sh
|
||||
|
||||
image:
|
||||
@@ -114,23 +142,31 @@ jobs:
|
||||
- name: Build and smoke-test runtime
|
||||
run: |
|
||||
set -eu
|
||||
if ! bash tools/ci/ci-paths.sh image; then
|
||||
echo 'No runtime-image files changed; gate skipped.'
|
||||
exit 0
|
||||
fi
|
||||
image="aevolution-proof:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
docker build --progress=plain --file deploy/docker/Dockerfile \
|
||||
if [[ "${GITHUB_REF:-}" == refs/heads/main && "${GITHUB_EVENT_NAME:-}" != pull_request && -n "${HARBOR_USERNAME:-}" ]]; then
|
||||
export CACHE_WRITE=1
|
||||
fi
|
||||
bash tools/ci/docker-build.sh runtime "$image" aevolution-image-cache \
|
||||
--build-arg "UBUNTU_IMAGE=$UBUNTU_IMAGE" \
|
||||
--label "org.opencontainers.image.revision=$GITHUB_SHA" \
|
||||
--label "org.opencontainers.image.source=https://git.aeternalisgames.com/dingo/AEvolution" \
|
||||
--tag "$image" .
|
||||
--label "org.opencontainers.image.source=https://git.aeternalisgames.com/dingo/AEvolution"
|
||||
docker run --rm --network none --read-only --cap-drop ALL \
|
||||
--security-opt no-new-privileges "$image" \
|
||||
--seed 123456 --entities 8 --ticks 1000 --verify-replay
|
||||
- name: Publish configured main build to Harbor
|
||||
if: ${{ gitea.ref == 'refs/heads/main' && gitea.event_name != 'pull_request' && vars.HARBOR_PROJECT != '' }}
|
||||
env:
|
||||
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT }}
|
||||
HARBOR_REPOSITORY: ${{ vars.HARBOR_REPOSITORY || 'aevolution' }}
|
||||
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
|
||||
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
|
||||
run: bash tools/ci/publish-image.sh
|
||||
run: |
|
||||
if ! docker image inspect "aevolution-proof:${GITHUB_SHA}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" >/dev/null 2>&1; then
|
||||
echo 'Runtime-image build was skipped; nothing to publish.'
|
||||
exit 0
|
||||
fi
|
||||
bash tools/ci/publish-image.sh
|
||||
- name: Explain unconfigured publishing
|
||||
if: ${{ vars.HARBOR_PROJECT == '' }}
|
||||
run: echo 'Image build/smoke only. Set HARBOR_PROJECT and Harbor robot secrets to enable main publishing. See deploy/README.md.'
|
||||
|
||||
Reference in New Issue
Block a user