Skip to content

Commit

Permalink
fix(gha): only push images on merge/release
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-chaffee committed Dec 31, 2024
1 parent 43a7a51 commit c70a266
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint and run tests

description: Lints and runs tests on the codebase, used before builds and on every PR

runs:
using: composite
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.23
- name: Lint the codebase
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: -E goimports -E godot --timeout 10m
- name: Run tests
shell: bash
run: |
PICO_SECRET="danger" go test -v ./... -cover -race -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
18 changes: 2 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
- main
tags:
- v*
pull_request:
branches:
- main

env:
REGISTRY: ghcr.io
Expand All @@ -21,21 +18,10 @@ jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.23
- name: Checkout repo
uses: actions/checkout@v3
- name: Lint the codebase
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: -E goimports -E godot --timeout 10m
- name: Run tests
run: |
PICO_SECRET="danger" go test -v ./... -cover -race -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
- name: Run tests and lint
uses: ./.github/actions/test
build-main:
runs-on: ubuntu-22.04
needs: test
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test PRs

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Run tests and lint
uses: ./.github/actions/test

0 comments on commit c70a266

Please sign in to comment.