Files
fejkdata/.github/workflows/test.yml
T
lilleman 1cf8ed502a
Tests / vet + fmt + tests (pull_request) Successful in 1m7s
Tests / Gitea release from CHANGELOG.md (pull_request) Has been skipped
Cut the release from the changelog heading on a green main instead of a hand-pushed tag
2026-09-16 20:09:38 +02:00

70 lines
2.3 KiB
YAML

name: Tests
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
test:
name: vet + fmt + tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 0
- name: Relevant changes
id: changes
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
git fetch --no-tags origin "$GITHUB_BASE_REF"
base="origin/$GITHUB_BASE_REF"
else
base='${{ github.event.before }}'
fi
if git diff --quiet "$base"...HEAD -- '*.go' go.mod go.sum Dockerfile .dockerignore .github data testdata README.md; then
echo "code=false" >> "$GITHUB_OUTPUT"
else
echo "code=true" >> "$GITHUB_OUTPUT"
fi
echo "base=$base" >> "$GITHUB_OUTPUT"
- name: CHANGELOG entry for data changes
run: |
base='${{ steps.changes.outputs.base }}'
if ! git diff --quiet "$base"...HEAD -- data testdata/shipped_shape.txt && git diff --quiet "$base"...HEAD -- CHANGELOG.md; then
echo "::error::the shipped data changed without a CHANGELOG.md entry (see the README's Versioning)"
exit 1
fi
# `docker build` streams the context to the daemon. A compose bind-mount of
# `.` mounts an empty host dir instead, because the job is itself a container.
- name: Latest supported Go
if: ${{ steps.changes.outputs.code == 'true' }}
run: docker build .
# Runs even when the step above failed, so a red build says whether the
# failure is version-specific.
- name: Lowest supported Go
if: ${{ !cancelled() && steps.changes.outputs.code == 'true' }}
run: docker build --build-arg GO_VERSION=1.22.12 .
release:
name: Gitea release from CHANGELOG.md
needs: test
if: github.event_name == 'push'
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- run: python3 release-tooling/publish_release.py
env:
GITEA_API_URL: ${{ github.api_url }}
GITEA_REPOSITORY: ${{ github.repository }}
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ github.sha }}