From ee4f4808edc84c34193573710e37d3ea5852d2c1 Mon Sep 17 00:00:00 2001 From: Trym Bremnes Date: Thu, 29 Feb 2024 14:09:44 +0100 Subject: [PATCH] refactor: consolidate workflows # Motivation To the workflows easier to work with, we should use the `jobs` parameter more often. Especially when the triggers are the same. This makes it easier to inspect the various jobs as they are now mostly in the same workflows. In addition, there should be dependencies between the various jobs, for example, so that the tests run on the actual release. Or not to automatically release if the `lint` job fails. # Changes * `release.yml` is renamed to `main.yml` * The jobs of `test.yml`, and `lint.yml` have now also moved to `main.yml`. * The job `goreleaser` has now been renamed to `Build`, as it reflects what it does better (nothing is actually released, and `goreleaser` is just an implementation detail). # Future work `github-pages` could also potentially be moved to `main.yml`, but because the triggers are different it has been left out for now. --- .github/workflows/lint.yml | 20 ------------- .github/workflows/{release.yml => main.yml} | 33 +++++++++++++++++++-- .github/workflows/test.yml | 18 ----------- 3 files changed, 31 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/lint.yml rename .github/workflows/{release.yml => main.yml} (51%) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 18f02617..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: golangci-lint - -on: - push: - -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: Checkout - uses: actions/checkout@v4 - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 - with: - version: v1.56.1 diff --git a/.github/workflows/release.yml b/.github/workflows/main.yml similarity index 51% rename from .github/workflows/release.yml rename to .github/workflows/main.yml index 889333c1..adf869f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: goreleaser +name: Main on: push: @@ -7,8 +7,37 @@ permissions: contents: write jobs: - goreleaser: + lint: + name: lint runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + - name: Checkout + uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56.1 + + test: + name: go test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21' + - name: Test + run: go test ./... + + build: + runs-on: ubuntu-latest + name: Build steps: - name: Detect snapshot if: ${{ !startsWith(github.ref, 'refs/tags/v') }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 27dfedc8..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: test - -on: - push: - -jobs: - test: - name: go test - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: '1.21' - - name: Test - run: go test ./...