Files

88 lines
2.6 KiB
YAML

# 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:
# renovate: datasource=golang-version depName=golang
GO_VERSION: 1.26.11
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 }}"
cache-dependency-path: 'matrix-tools/go.sum'
- 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 }}"
cache-dependency-path: 'matrix-tools/go.sum'
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
working-directory: matrix-tools
args: -v --show-stats --no-config --modules-download-mode readonly
- uses: GoTestTools/gotestfmt-action@eba2ac97f623e866e7b1b117c99f18b43cd36d18 # v2.3.0
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
# The build lives in a reusable workflow. The pytest workflow builds the same image and
# publishes it, so the integration tests can deploy it.
uses: ./.github/workflows/matrix-tools-build.yml # zizmor: ignore[self-repository] The $/ form is better, but actionlint rejects it for now. https://github.com/rhysd/actionlint/issues/760
with:
# The image is only published for releases
push: ${{ github.ref_type == 'tag' }}