ci: migrate push/pr pipeline to GHA #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push/PR | |
on: | |
pull_request: {} | |
push: | |
branches: | |
- main | |
jobs: | |
deps: | |
name: Check dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Ensure deps are clean | |
run: | | |
make deps | |
./scripts/enforce-clean | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Needed for version script to work. | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build | |
run: | | |
make build | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Build container | |
uses: docker/build-push-action@v6 | |
with: | |
push: false | |
# Needed for this action to use local context incl. binaries built in the previous step. | |
# https://github.com/docker/build-push-action?tab=readme-ov-file#path-context | |
# TODO: Make docker build self-contained. | |
context: . | |
tags: ci.local/${{ github.repository }} | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Test | |
run: | | |
make test | |
golangci: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Get golangci-lint version that `make lint` uses. | |
- id: version | |
run: |- | |
echo "golangci=$(make golangci-lint-version)" >> $GITHUB_OUTPUT | |
# rm cache, as make golangci-lint-version will create it as a different user and cause the action below | |
# to fail. | |
rm -r "$HOME/.cache/golangci-lint" | |
# Use the golangci-lint action, which provides Github-specific features such as diff annotations. | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
version: ${{ steps.version.outputs.golangci }} | |
args: --timeout=5m # 1m is not enough, experimentally. | |
only-new-issues: true |