Skip to content

Merge pull request #1563 from element-hq/bbz/rename-external-redis-pr… #5485

Merge pull request #1563 from element-hq/bbz/rename-external-redis-pr…

Merge pull request #1563 from element-hq/bbz/rename-external-redis-pr… #5485

Workflow file for this run

# 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.26"
jobs:
gofmt:
permissions:
contents: read
packages: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "${{ env.GO_VERSION }}"
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # 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@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Login to GHCR
if: ${{ github.ref_type == 'tag' }}
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
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@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
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@d3418bd7d0e9324001bca92fa8ba175ea7e6dc9b # v7.3.0
with:
push: ${{ github.ref_type == 'tag' }}
files: |
docker-bake.hcl
cwd://${{ steps.meta.outputs.bake-file }}
targets: matrix-tools
set: |
*.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' }}