Files
gentoo-utils-gitea/.gitea/workflows/gentoo-utils.yml
penguin 86b6150afd
Some checks failed
Gentoo Utils / build-oci-image (push) Successful in 5m22s
Gentoo Utils / check-format (push) Failing after 1m43s
Gentoo Utils / build (push) Failing after 1m56s
Gentoo Utils / test (push) Has been skipped
infra: actions: add check-format job
2025-12-12 13:51:43 -06:00

110 lines
3.7 KiB
YAML

name: Gentoo Utils
on: [push]
jobs:
build-oci-image:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check for changes before building
id: image-changes
# build image only if 1. changes are detected or 2. an image for the working branch doesnt exist
run: |
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
if [[ "$branch_name" == "${{ gitea.event.repository.default_branch }}" ]]; then
image_tag=latest
else
image_tag=$branch_name
fi
echo "branch_name=$branch_name" >> $GITEA_OUTPUT
# slugify
image_tag="$(echo "$image_tag" | sed -E 's/[^a-zA-Z0-9]/-/g')"
echo "image_tag=$image_tag" >> $GITEA_OUTPUT
if ! git diff ${{ gitea.event.before }} ${{ 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
fi
fi
echo "build_image=$build_image" >> $GITEA_OUTPUT
cat $GITEA_OUTPUT
- name: Set up Docker buildx
if: steps.image-changes.outputs.build_image == 'true'
uses: docker/setup-buildx-action@v3
- name: Log in to Github Container Registry
if: steps.image-changes.outputs.build_image == 'true'
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ vars.CI_BOT_USERNAME }}
password: ${{ secrets.CI_BOT_TOKEN }}
- name: Build and push
if: steps.image-changes.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 }}
context: "{{defaultContext}}:.docker"
outputs:
image_tag: ${{ steps.image-changes.outputs.image_tag }}
build:
runs-on: brutalisk
needs: build-oci-image
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: build and check
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:
runs-on: brutalisk
needs: [build-oci-image, build]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: test
run: |
meson setup -Dfuzz=enabled -Dtests=enabled -Dbuildtype=debugoptimized -Ddocs=enabled build
meson compile -C build
ninja test -C build
check-format:
runs-on: brutalisk
needs: [build-oci-image]
container:
image: ${{ vars.REGISTRY_URL }}/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps:
- name: Checkout repo
uses: actions/checkout@v5
- name: Check Formatting
run: |
meson setup -Dfuzz=enabled -Dtests=enabled -Dbuildtype=debugoptimized -Ddocs=enabled build
ninja rustfmt -C build