Skip to content

Commit

Permalink
ci(*): refactor to use workflow calls (#197)
Browse files Browse the repository at this point in the history
Adds:
- `ci-main.yml`: runs specific jobs on merge to `main`
- `ci-pr.yml`: runs specific jobs on pr to `main`

If we like this setup, we can also:
- add a `ci-release.yml`, which would run on each release
- parameterize `goreleaser.yml`. on merge to `main`, we'd push the
`main` image, and on releases we'd push `latest`

task: none

---------

Co-authored-by: Pavel Nikolov <pavelnikolov@users.noreply.github.com>
  • Loading branch information
ttarsi and pavelnikolov authored Jan 30, 2024
1 parent 70b086c commit d047da5
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 30 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ci main
# continuous integration on push to main

on:
push:
branches:
- main

permissions:
contents: read
pull-requests: read

jobs:
pre-commit:
uses: ./.github/workflows/pre-commit.yml
go-tests:
uses: ./.github/workflows/gotest.yml
go-lint:
uses: ./.github/workflows/golangci-lint.yml
go-releaser:
uses: ./.github/workflows/goreleaser.yml
needs: [pre-commit, go-tests, go-lint]
secrets: inherit
e2e:
uses: ./.github/workflows/e2etest.yml
needs: [go-releaser]
File renamed without changes.
19 changes: 19 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ci pr
# continuous integration on pull requests to main

on:
pull_request:
branches:
- main

permissions:
contents: read
pull-requests: read

jobs:
pre-commit:
uses: ./.github/workflows/pre-commit.yml
go-tests:
uses: ./.github/workflows/gotest.yml
go-lint:
uses: ./.github/workflows/golangci-lint.yml
File renamed without changes.
6 changes: 1 addition & 5 deletions .github/workflows/e2etest.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: e2e tests

# Run on main after building docker images
on:
workflow_run:
workflows: ["go releaser"]
branches: [main]
types: [completed]
workflow_call:

jobs:
e2e_tests:
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
name: go lint
# Run this separately from pre-commit since then we get nice inline messages in PRs.

# Run on pull requests and commits to main
on:
pull_request:
push:
branches:
- main

permissions:
contents: read
pull-requests: read
workflow_call:

jobs:
golangci:
Expand All @@ -28,5 +20,3 @@ jobs:
version: v1.55.2
# Verbose with color. Just fail, don't fix issues. Use both annotations and normal output.
args: -v --color=always --fix=false --out-format=colored-line-number,github-actions

# TODO(corver): Notify slack on failure on main
5 changes: 1 addition & 4 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: go releaser

# Run on all commits to main
on:
push:
branches:
- main
workflow_call:

# TODO(corver): Figure out which images to publish and how to do this via goreleaser.

Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: go tests
# Run this separately from pre-commit for nice visual coverage.

# Run on pull requests and commits to main
on:
pull_request:
push:
branches:
- main
workflow_call:

jobs:
unit_tests:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: pre-commit hooks

# Run on pull requests and commits to main
on:
pull_request:
push:
branches:
- main
workflow_call:

jobs:
pre-commit:
Expand Down

0 comments on commit d047da5

Please sign in to comment.