Files
owncast/.github/workflows/go-tests.yaml
T
renovate[bot]GitHubrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
4b72d9e8b5 chore(deps): update actions/cache action to v5 (#4728)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-12 12:48:40 -08:00

100 lines
2.6 KiB
YAML

# This workflow runs Go unit tests across multiple OS and Go versions
# Triggers:
# - Push/PR with Go file changes (*.go, go.mod, go.sum)
# - Skips when only web/ directory changes
# Test Matrix:
# - PRs: Latest Go on Ubuntu only (fast feedback)
# - Develop/Main: Full matrix (ensure cross-platform compatibility)
name: Go Tests
on:
push:
paths-ignore:
- 'web/**'
pull_request:
paths-ignore:
- 'web/**'
jobs:
test:
strategy:
matrix:
go-version: ${{ github.event_name == 'pull_request' && fromJSON('["1.24.x"]') || fromJSON('["1.23.x", "1.24.x"]') }}
os: ${{ github.event_name == 'pull_request' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest", "windows-latest", "ubuntu-24.04-arm"]') }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Get changed files
id: changed-files-yaml
uses: tj-actions/changed-files@v47
with:
files_yaml: |
src:
- '**/*.{go,mod,sum}'
- uses: actions/cache@v5
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-test-${{ github.sha }}
restore-keys: |
go-test-
- name: Install go
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
uses: actions/setup-go@v6
with:
go-version: '^1'
cache: true
- name: Run tests
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
run: go test ./...
test-bsds:
# Only run BSD tests on push events (not PRs) for efficiency
if: github.event_name == 'push'
runs-on: macos-latest
strategy:
matrix:
os:
- name: freebsd
version: 12.2
- name: openbsd
version: 6.8
steps:
- uses: actions/checkout@v6
- name: Get changed files
id: changed-files-yaml
uses: tj-actions/changed-files@v47
with:
files_yaml: |
src:
- '**/*.{go,mod,sum}'
- uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-test-${{ github.sha }}
restore-keys: |
go-test-
- name: Install go
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
uses: actions/setup-go@v6
with:
go-version: '^1'
cache: true
- name: Run tests
if: steps.changed-files-yaml.outputs.src_any_changed == 'true'
run: go test ./...