Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: migrate push/pr pipeline to GHA #842

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/push-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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
platforms: linux/amd64,linux/arm64
# 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 build-xk6-linux-amd64 # Tests require a valid k6 binary in dist/k6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is needed, it means there's a missing dependency in the makefile.

I vaguely remember adding that...

Copy link
Collaborator Author

@roobre roobre Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is there on another repo (perhaps the runner)? But yep, one test failed cryptically without this (and I am running legit make test this time, not go test).

make test

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Get golangci-lint version that `make lint` uses.
- name: Retrieve golangci-lint version
id: version
run: |-
echo "golangci=$(make golangci-lint-version)" >> $GITHUB_OUTPUT
# Use the golangci-lint action, which provides Github-specific features such as diff annotations.
- name: Run golangi-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
- name: Run the rest of the linters
run: |-
make lint GOLANGCI_LINT=/bin/true
File renamed without changes.
6 changes: 5 additions & 1 deletion scripts/make/linters.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ golangci-lint: $(if $(filter $(LOCAL_GOLANGCI_LINT),yes),$(GOLANGCI_LINT))
$(S) echo "lint via golangci-lint"
$(S) $(GOLANGCI_LINT) run \
$(GOLANGCI_LINT_MOD_FLAGS) \
--config ./scripts/configs/golangci.yml \
--config ./.golangci.yaml \
--verbose \
--verbose \
$(GO_PKGS)

.PHONY: golangci-lint-version
golangci-lint-version:
$(S) $(GOLANGCI_LINT) version --format short

.PHONY: go-vet
go-vet:
$(S) echo "lint via go vet"
Expand Down
Loading