From 94121b166bd1d2da9438a5d7ddccbd173236b6fd Mon Sep 17 00:00:00 2001 From: Corey Sotiropoulos Date: Fri, 19 Dec 2025 00:39:21 -0500 Subject: [PATCH 1/3] [ci] Clean up some formatting Set default values to env vars to clear warnings. Use env var to clean up conditional build logic. --- .github/workflows/docker_build.yml | 2 ++ .github/workflows/docker_test.yml | 2 ++ .github/workflows/publish_meshes.yml | 2 ++ .github/workflows/runner_build.yml | 39 ++++++++++++++-------------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 68ec1031a70..a880cc7935d 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -58,6 +58,8 @@ jobs: BUILDX_NO_DEFAULT_ATTESTATIONS: 1 # https://github.com/orgs/community/discussions/45969 build_id: ${{ format('build-{0}-{1}-{2}-tracy{3}-pch{4}', inputs.os, inputs.compiler, inputs.build_type, inputs.tracy && 'ON' || 'OFF', inputs.build_type == 'Debug' && 'OFF' || 'ON') }} ccache_id: ${{ format('ccache-{0}-{1}-{2}-tracy{3}-pch{4}', inputs.os, inputs.compiler, inputs.build_type, inputs.tracy && 'ON' || 'OFF', inputs.build_type == 'Debug' && 'OFF' || 'ON') }} + REPO_OWNER: 'landsandboat' + REPO: 'landsandboat/server' steps: - name: Lowercase repository owner run: | diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml index 2584005d418..c6c2f78ca5f 100644 --- a/.github/workflows/docker_test.yml +++ b/.github/workflows/docker_test.yml @@ -33,6 +33,8 @@ jobs: XI_NETWORK_SQL_DATABASE: xidb XI_NETWORK_SQL_LOGIN: xiadmin XI_NETWORK_SQL_PASSWORD: 'password' + REPO_OWNER: 'landsandboat' + REPO: 'landsandboat/server' services: database: image: mariadb:lts diff --git a/.github/workflows/publish_meshes.yml b/.github/workflows/publish_meshes.yml index a9fc52c1c57..745e9618a93 100644 --- a/.github/workflows/publish_meshes.yml +++ b/.github/workflows/publish_meshes.yml @@ -14,6 +14,8 @@ jobs: Meshes_Build: name: Build and Publish ximeshes Docker Image runs-on: ubuntu-latest + env: + REPO_OWNER: 'landsandboat' steps: - name: Lowercase repository owner run: | diff --git a/.github/workflows/runner_build.yml b/.github/workflows/runner_build.yml index 5c775420822..d9b5fd85845 100644 --- a/.github/workflows/runner_build.yml +++ b/.github/workflows/runner_build.yml @@ -60,6 +60,7 @@ jobs: env: SCCACHE_DIR: ${{ format('{0}/build/sccache', github.workspace) }} SCCACHE_CACHE_SIZE: "1G" + SKIP_BUILD: false steps: - name: Download changed files artifact if: ${{ inputs.optional_build }} @@ -87,16 +88,16 @@ jobs: break fi done - echo "source_changes=$source_changes" >> $GITHUB_OUTPUT + echo "SKIP_BUILD=$([[ $source_changes == false && ${{ inputs.optional_build }} == true ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV - name: Checkout - if: ${{ !inputs.optional_build || steps.check-changes.outputs.source_changes == 'true' }} + if: ${{ env.SKIP_BUILD != 'true' }} uses: actions/checkout@v4 with: fetch-depth: 1 - name: Install dependencies (macOS) - if: ${{ runner.os == 'macOS' && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ runner.os == 'macOS' && env.SKIP_BUILD != 'true' }} run: | brew update && brew install --quiet \ mariadb \ @@ -105,7 +106,7 @@ jobs: ninja - name: Setup LLVM Clang (macOS) - if: ${{ runner.os == 'macOS' && startsWith(inputs.compiler, 'clang') && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ runner.os == 'macOS' && startsWith(inputs.compiler, 'clang') && env.SKIP_BUILD != 'true' }} run: | brew update && brew install --quiet \ llvm@${{ inputs.compiler_version }} \ @@ -125,7 +126,7 @@ jobs: echo "LDFLAGS=-fuse-ld=lld -flto=thin" >> $GITHUB_ENV - name: Setup GCC (macOS) - if: ${{ runner.os == 'macOS' && startsWith(inputs.compiler, 'gcc') && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ runner.os == 'macOS' && startsWith(inputs.compiler, 'gcc') && env.SKIP_BUILD != 'true' }} run: | brew update && brew install --quiet gcc@${{ inputs.compiler_version }} GCC_PREFIX=$(brew --prefix gcc@${{ inputs.compiler_version }}) @@ -134,7 +135,7 @@ jobs: echo "CXX=$GCC_PREFIX/bin/g++-${{ inputs.compiler_version }}" >> $GITHUB_ENV - name: Install dependencies (Linux) - if: ${{ runner.os == 'Linux' && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ runner.os == 'Linux' && env.SKIP_BUILD != 'true' }} run: | sudo apt-get update && sudo apt-get install --assume-yes --no-install-recommends --quiet \ binutils-dev \ @@ -148,7 +149,7 @@ jobs: zlib1g-dev - name: Setup GCC (Linux) - if: ${{ runner.os == 'Linux' && startsWith(inputs.compiler, 'gcc') && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ runner.os == 'Linux' && startsWith(inputs.compiler, 'gcc') && env.SKIP_BUILD != 'true' }} env: gcc_version: ${{ inputs.compiler_version && format('-{0}', inputs.compiler_version) || '' }} run: | @@ -157,9 +158,7 @@ jobs: echo "CXX=/usr/bin/g++${{ env.gcc_version }}" >> $GITHUB_ENV - name: Setup Clang (Linux) - if: ${{ runner.os == 'Linux' && startsWith(inputs.compiler, 'clang') && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} - env: - llvm_version: ${{ inputs.compiler_version && format('-{0}', inputs.compiler_version) || '' }} + if: ${{ runner.os == 'Linux' && startsWith(inputs.compiler, 'clang') && env.SKIP_BUILD != 'true' }} run: | sudo apt-get update && sudo apt-get install --assume-yes --no-install-recommends --quiet g++-14 wget https://apt.llvm.org/llvm.sh @@ -171,25 +170,25 @@ jobs: echo "LDFLAGS=-fuse-ld=lld" >> $GITHUB_ENV - name: Setup MSVC - if: ${{ runner.os == 'Windows' && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ runner.os == 'Windows' && env.SKIP_BUILD != 'true' }} uses: TheMrMilchmann/setup-msvc-dev@v3 with: arch: x64 - name: Setup sccache - if: ${{ !inputs.optional_build || steps.check-changes.outputs.source_changes == 'true' }} + if: ${{ env.SKIP_BUILD != 'true' }} uses: mozilla-actions/sccache-action@v0.0.9 with: disable_annotations: ${{ !inputs.save_cache }} - name: Setup Python - if: ${{ !inputs.optional_build || steps.check-changes.outputs.source_changes == 'true' }} + if: ${{ env.SKIP_BUILD != 'true' }} uses: actions/setup-python@v5 with: python-version: '3.12' - name: Enable modules - if: ${{ inputs.build_modules && (!inputs.optional_build || steps.check-changes.outputs.source_changes == 'true') }} + if: ${{ inputs.build_modules && env.SKIP_BUILD != 'true' }} run: | python3 <> $GITHUB_STEP_SUMMARY if [[ -f "build.log" && -s "build.log" ]]; then From 3a77447bbbc134cba66cae13cfec4b3ee0cf2482 Mon Sep 17 00:00:00 2001 From: Corey Sotiropoulos Date: Thu, 11 Dec 2025 06:21:17 +0000 Subject: [PATCH 2/3] [ci] Add repo vars to control Docker publish DOCKER_PUBLISH needs to be set to a non-empty string to enable docker image publishing. GHCR packages may need to be enabled for your repo before being able to successfully publish. DEVTOOLS_IMAGE allows overriding the devtools image used in tests. --- .github/workflows/docker_build.yml | 4 ++-- .github/workflows/pr_checks.yml | 4 ++-- .github/workflows/test.yml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index a880cc7935d..c1cd2a434dc 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -159,7 +159,7 @@ jobs: flavor: ${{ inputs.os != 'ubuntu' && format('suffix=-{0},onlatest=true', inputs.os) || '' }} - name: Build devtools image - if: ${{ inputs.publish }} + if: ${{ vars.PUBLISH_DOCKER == 'true' && inputs.publish }} uses: docker/build-push-action@v6 with: context: . @@ -176,7 +176,7 @@ jobs: with: context: . file: ${{ format('./docker/{0}.Dockerfile', inputs.os) }} - push: ${{ inputs.publish }} + push: ${{ vars.PUBLISH_DOCKER == 'true' && inputs.publish }} tags: ${{ steps.docker-meta.outputs.tags }} labels: ${{ steps.docker-meta.outputs.labels }} annotations: ${{ steps.docker-meta.outputs.annotations }} diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index 9cf97e0036c..815ecb61a1a 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -18,7 +18,7 @@ jobs: name: Sanity Checks runs-on: ubuntu-latest container: - image: ghcr.io/landsandboat/devtools:ubuntu + image: ${{ vars.DEVTOOLS_IMAGE || 'ghcr.io/landsandboat/devtools:ubuntu' }} defaults: run: shell: bash @@ -55,7 +55,7 @@ jobs: needs: Sanity_Checks runs-on: ubuntu-latest container: - image: ghcr.io/landsandboat/devtools:ubuntu + image: ${{ vars.DEVTOOLS_IMAGE || 'ghcr.io/landsandboat/devtools:ubuntu' }} defaults: run: shell: bash diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index caaf737741b..38715616841 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest container: - image: ghcr.io/landsandboat/devtools:ubuntu + image: ${{ vars.DEVTOOLS_IMAGE || 'ghcr.io/landsandboat/devtools:ubuntu' }} defaults: run: shell: bash @@ -39,7 +39,7 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest container: - image: ghcr.io/landsandboat/devtools:ubuntu + image: ${{ vars.DEVTOOLS_IMAGE || 'ghcr.io/landsandboat/devtools:ubuntu' }} defaults: run: shell: bash @@ -101,7 +101,7 @@ jobs: Docker_Test: name: ${{ matrix.os && 'Test' || '' }} # GitHub Actions hack to hide matrix args - if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + if: ${{ vars.PUBLISH_DOCKER == 'true' && github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} strategy: fail-fast: false matrix: From d141dbdc750e202746267e5c66212a662357bb4d Mon Sep 17 00:00:00 2001 From: Corey Sotiropoulos Date: Thu, 11 Dec 2025 07:52:46 +0000 Subject: [PATCH 3/3] [ci] Upload and test Docker image as artifact if not publishing --- .github/workflows/docker_build.yml | 10 +++++----- .github/workflows/docker_test.yml | 10 +++++++++- .github/workflows/test.yml | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index c1cd2a434dc..6dba166646c 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -159,7 +159,7 @@ jobs: flavor: ${{ inputs.os != 'ubuntu' && format('suffix=-{0},onlatest=true', inputs.os) || '' }} - name: Build devtools image - if: ${{ vars.PUBLISH_DOCKER == 'true' && inputs.publish }} + if: ${{ inputs.publish && vars.PUBLISH_DOCKER != '' }} uses: docker/build-push-action@v6 with: context: . @@ -176,11 +176,11 @@ jobs: with: context: . file: ${{ format('./docker/{0}.Dockerfile', inputs.os) }} - push: ${{ vars.PUBLISH_DOCKER == 'true' && inputs.publish }} + push: ${{ inputs.publish && vars.PUBLISH_DOCKER != '' }} tags: ${{ steps.docker-meta.outputs.tags }} labels: ${{ steps.docker-meta.outputs.labels }} annotations: ${{ steps.docker-meta.outputs.annotations }} - platforms: linux/amd64${{ inputs.publish && ',linux/arm64,linux/arm/v7' || '' }} + platforms: linux/amd64${{ (inputs.publish && vars.PUBLISH_DOCKER != '') && ',linux/arm64,linux/arm/v7' || '' }} build-args: | COMPILER=${{ inputs.compiler }} ${{ format('{0}={1}', startsWith(inputs.compiler, 'gcc') && 'GCC_VERSION' || 'LLVM_VERSION', inputs.compiler_version) }} @@ -189,10 +189,10 @@ jobs: PCH_ENABLE=${{ inputs.build_type == 'Debug' && 'OFF' || 'ON' }} REPO_URL=${{ github.server_url }}/${{ github.repository }}.git COMMIT_SHA=${{ github.sha }} - outputs: ${{ inputs.upload_artifact && format('type=docker,dest={0}/LSB_{1}_image_{2}.tar', runner.temp, inputs.os, github.sha) }} + outputs: ${{ (inputs.upload_artifact || (inputs.publish && vars.PUBLISH_DOCKER == '')) && format('type=docker,dest={0}/LSB_{1}_image_{2}.tar', runner.temp, inputs.os, github.sha) }} - name: Archive image - if: ${{ inputs.upload_artifact }} + if: ${{ inputs.upload_artifact || (inputs.publish && vars.PUBLISH_DOCKER == '') }} uses: actions/upload-artifact@v4 with: name: ${{ format('LSB_{0}_image_{1}', inputs.os, github.sha) }} diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml index c6c2f78ca5f..edba29e8c7e 100644 --- a/.github/workflows/docker_test.yml +++ b/.github/workflows/docker_test.yml @@ -68,8 +68,16 @@ jobs: name: ${{ env.artifact_name }} path: ${{ runner.temp }} + - name: Download previous artifact + if: ${{ (github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch') && vars.PUBLISH_DOCKER == ''}} + uses: dawidd6/action-download-artifact@v3 + with: + run_id: ${{ github.event.workflow_run.id }} + name: ${{ env.artifact_name }} + path: ${{ runner.temp }} + - name: Load artifact - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' || vars.PUBLISH_DOCKER == '' }} run: | docker load --input ${{ runner.temp }}/${{ env.artifact_name }}.tar diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 38715616841..98728c80a15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,7 +101,7 @@ jobs: Docker_Test: name: ${{ matrix.os && 'Test' || '' }} # GitHub Actions hack to hide matrix args - if: ${{ vars.PUBLISH_DOCKER == 'true' && github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} strategy: fail-fast: false matrix: