Files
ess-helm/.github/workflows/matrix-tools.yml
T

135 lines
4.0 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Copyright 2025 New Vector Ltd
# Copyright 2025-2026 Element Creations Ltd
#
# SPDX-License-Identifier: AGPL-3.0-only
name: matrix-tools linting and building
on:
pull_request:
push:
branches:
- main
- 'maintenance/*'
tags:
- 'matrix-tools-*'
workflow_dispatch:
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/matrix-tools
GO_VERSION: "1.25"
jobs:
gofmt:
permissions:
contents: read
packages: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: "${{ env.GO_VERSION }}"
- name: gofmt check
run: |
unformatted_files="$(gofmt -l matrix-tools)"
if [ "$unformatted_files" != "" ]; then
echo "There are .go files that aren't formatted correctly:"
echo "$unformatted_files"
exit 1
fi
tests:
permissions:
contents: read
packages: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6
with:
go-version: "${{ env.GO_VERSION }}"
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9
with:
working-directory: matrix-tools
args: -v --show-stats --no-config --modules-download-mode readonly
- uses: GoTestTools/gotestfmt-action@7dd37bbcc925453b6d7465164cf3bcbd87bc691d # v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: cd matrix-tools && go test -v -json ./... 2>&1 | gotestfmt
# Build our application docker images in parallel.
docker-build-and-push:
permissions:
contents: read
packages: write
name: Build matrix-tools container image
needs:
- tests
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Checkout Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Login to GHCR
if: ${{ github.ref_type == 'tag' }}
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get Release Tag
if: github.ref_type == 'tag' # Only for GitHub releases
run: |
echo "Converting $GITHUB_REF to tags"
echo "VERSION=${GITHUB_REF#refs\/tags\/matrix-tools-}" >> "$GITHUB_ENV"
- name: Docker meta
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: |
${{ env.REGISTRY_IMAGE }}
flavor: |
latest=false
tags: |
type=raw,value=${{ env.VERSION }},enable=${{ github.ref_type == 'tag' }}
type=sha,prefix=sha-,format=short
labels: |
org.opencontainers.image.licenses=AGPL-3.0-only
annotations: |
org.opencontainers.image.licenses=AGPL-3.0-only
- name: Build and Push Image
uses: docker/bake-action@5be5f02ff8819ecd3092ea6b2e6261c31774f2b4 # v6
with:
push: ${{ github.ref_type == 'tag' }}
files: |
docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
targets: matrix-tools
set: |
*.output=type=image
*.platform=linux/amd64,linux/arm64
# https://docs.zizmor.sh/audits/#cache-poisoning
# This is not catched by zizmor but arguably we need to disable cache for docker builds
# See related issue https://github.com/zizmorcore/zizmor/issues/774
no-cache: ${{ github.ref_type == 'tag' }}