From 69bde9b17f25b7212270817d7e6b7e6d5c82fcc2 Mon Sep 17 00:00:00 2001 From: penguin Date: Sat, 27 Dec 2025 11:12:50 -0600 Subject: [PATCH 1/3] ci: image: use gentoo repo with EGIT_OVERRIDE_REPO_MESONBUILD_MESON for meson --- .docker/Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 7e6eb09..09f2faf 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -6,22 +6,19 @@ RUN getuto RUN emerge-webrsync +RUN mkdir -p /var/cache/distfiles/git3-src && chown portage:portage /var/cache/distfiles/git3-src + +ENV EGIT_OVERRIDE_REPO_MESONBUILD_MESON=https://jturnerusa.dev/cgit/meson + RUN emerge \ =dev-lang/rust-bin-9999 \ + =dev-build/meson-9999::gentoo \ llvm-core/clang \ llvm-core/lld \ dev-vcs/git \ sys-process/parallel \ net-libs/nodejs -RUN git clone https://jturnerusa.dev/cgit/ebuilds/ /var/db/repos/spawns - -COPY etc/portage/repos.conf /etc/portage/ - -RUN mkdir -p /var/cache/distfiles/git3-src && chown portage:portage /var/cache/distfiles/git3-src - -RUN emerge =dev-build/meson-9999::spawns - RUN useradd -m gentooligan USER gentooligan -- 2.49.1 From 7683a94b5932a132eb3e0d1986190cd913dea1cb Mon Sep 17 00:00:00 2001 From: penguin Date: Sat, 27 Dec 2025 11:32:01 -0600 Subject: [PATCH 2/3] ci: redo docker build logic --- .gitea/workflows/gentoo-utils.yml | 80 +++++++++++++++++-------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/.gitea/workflows/gentoo-utils.yml b/.gitea/workflows/gentoo-utils.yml index 9888141..5d944d7 100644 --- a/.gitea/workflows/gentoo-utils.yml +++ b/.gitea/workflows/gentoo-utils.yml @@ -26,50 +26,44 @@ jobs: with: fetch-depth: 0 - - name: Check for changes before building + - name: Detect Changes + uses: dorny/paths-filter@v3 id: image-changes - # build image only if 1. changes are detected or 2. an image for the working branch doesnt exist + with: + filters: | + docker: + - ".docker/**" + + - name: Metadata + id: metadata run: | branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" default_branch_name="${{ gitea.event.repository.default_branch }}" image_tag=latest - comparison_hash="${{ gitea.event.before }}" - - if [[ "$branch_name" != "$default_branch_name" ]]; then - image_tag=$branch_name - fi - # slugify - image_tag="$(echo "$image_tag" | sed -E 's/[^a-zA-Z0-9]/-/g')" - - # rebase breaks gitea.event.before, so check to make sure the hash provided exists - if ! git merge-base --is-ancestor $comparison_hash $branch_name >/dev/null 2>&1; then - comparison_hash=$(git merge-base origin/$default_branch_name $branch_name) - fi - - if ! git diff $comparison_hash ${{ gitea.sha }} --no-patch --exit-code .docker; then - build_image=true - else - if ! docker manifest inspect ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${image_tag} >/dev/null 2>&1; then - build_image=true - else - build_image=false + if [[ $default_branch_name != $branch_name ]]; then + this_image_tag="$(echo "$branch_name" | sed -E 's/[^a-zA-Z0-9]/-/g')" + echo "steps... ${{ steps.image-changes.outputs.docker }}" + if [[ ${{ steps.image-changes.outputs.docker }} == true ]] || docker manifest inspect ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${this_image_tag} >/dev/null 2>&1; then + image_tag=$this_image_tag fi + else + build_image=true fi echo "default_branch_name=$default_branch_name" >> $GITEA_OUTPUT echo "branch_name=$branch_name" >> $GITEA_OUTPUT echo "image_tag=$image_tag" >> $GITEA_OUTPUT - echo "comparison_hash=$comparison_hash" >> $GITEA_OUTPUT - echo "build_image=$build_image" >> $GITEA_OUTPUT + echo "build_image=${build_image:-${{ steps.image-changes.outputs.docker }}}" >> $GITEA_OUTPUT cat $GITEA_OUTPUT + - name: Set up Docker buildx - if: steps.image-changes.outputs.build_image == 'true' + if: steps.metadata.outputs.build_image == 'true' uses: docker/setup-buildx-action@v3 with: driver-opts: network=runners-net - name: Log in to Github Container Registry - if: steps.image-changes.outputs.build_image == 'true' + if: steps.metadata.outputs.build_image == 'true' uses: docker/login-action@v3 with: registry: ${{ vars.REGISTRY_URL }} @@ -77,26 +71,32 @@ jobs: password: ${{ secrets.CI_BOT_TOKEN }} - name: Build and push - if: steps.image-changes.outputs.build_image == 'true' + if: steps.metadata.outputs.build_image == 'true' uses: docker/build-push-action@v6 with: push: true - tags: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ steps.image-changes.outputs.image_tag }} + tags: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ steps.metadata.outputs.image_tag }} context: "{{defaultContext}}:.docker" cache-from: type=gha cache-to: type=gha,mode=max outputs: - image_tag: ${{ steps.image-changes.outputs.image_tag }} + image_tag: ${{ steps.metadata.outputs.image_tag }} build: runs-on: gentoo env: - CC: 'clang' - CXX: 'clang++' + CC: "clang" + CXX: "clang++" needs: build-oci-image container: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: + - name: Restore git cache + uses: actions/cache@v4 + with: + path: .git + key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} + - name: Checkout repo uses: actions/checkout@v5 @@ -110,12 +110,17 @@ jobs: test: runs-on: gentoo env: - CC: 'clang' - CXX: 'clang++' + CC: "clang" + CXX: "clang++" needs: [build-oci-image, build] container: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: + - name: Restore git cache + uses: actions/cache@v4 + with: + path: .git + key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} - name: Checkout repo uses: actions/checkout@v5 @@ -128,13 +133,18 @@ jobs: fuzz: runs-on: gentoo env: - CC: 'clang' - CXX: 'clang++' + CC: "clang" + CXX: "clang++" FUZZER_TIMEOUT_S: 300 needs: [build-oci-image, build] container: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: + - name: Restore git cache + uses: actions/cache@v4 + with: + path: .git + key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} - name: Checkout repo uses: actions/checkout@v5 -- 2.49.1 From 1db4ecb1bb39e918c2fc1c3d13fd1807f0070ebc Mon Sep 17 00:00:00 2001 From: penguin Date: Sat, 27 Dec 2025 12:27:26 -0600 Subject: [PATCH 3/3] ci: fix build cache path --- .gitea/workflows/gentoo-utils.yml | 47 ++++++++++++++----------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/.gitea/workflows/gentoo-utils.yml b/.gitea/workflows/gentoo-utils.yml index 5d944d7..8f2049e 100644 --- a/.gitea/workflows/gentoo-utils.yml +++ b/.gitea/workflows/gentoo-utils.yml @@ -22,7 +22,7 @@ jobs: key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 @@ -91,20 +91,25 @@ jobs: container: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: - - name: Restore git cache - uses: actions/cache@v4 - with: - path: .git - key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} - - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - name: build and check + # TODO: This is currently unused by other jobs. I couldn't make meson not regenerate things regardless of + # the build dir already existing. + - name: Build Cache Setup + uses: actions/cache@v5 + with: + path: | + subprojects + build + key: build-${{ gitea.repository }}-${{ gitea.sha }} + + - name: Build run: | meson setup -Dfuzz=enabled -Dtests=enabled -Dbuildtype=debugoptimized -Ddocs=enabled build meson compile -C build + # FIXME: Currently this rebuilds everything. Instead we should bring over the build dir from the build job. This will come in handy # when we have multiple build targets and configs. What we have currently is fine until we get lots of builds going test: @@ -112,17 +117,12 @@ jobs: env: CC: "clang" CXX: "clang++" - needs: [build-oci-image, build] + needs: [build-oci-image] container: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: - - name: Restore git cache - uses: actions/cache@v4 - with: - path: .git - key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: test run: | @@ -136,17 +136,12 @@ jobs: CC: "clang" CXX: "clang++" FUZZER_TIMEOUT_S: 300 - needs: [build-oci-image, build] + needs: [build-oci-image] container: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: - - name: Restore git cache - uses: actions/cache@v4 - with: - path: .git - key: gitea-repo-${{ gitea.repository }}-${{ gitea.ref }} - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 # FIXME: Get rid of this step when portage has fixes merged? # needed because portage has fixes upstream we need that arent stable yet @@ -174,7 +169,7 @@ jobs: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Check Formatting run: | @@ -189,7 +184,7 @@ jobs: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Build Documentation run: | @@ -203,7 +198,7 @@ jobs: image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }} steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: grep for patterns # negate git grep ret code because 1 means no findings -- 2.49.1