Skip to content

Commit

Permalink
Improve pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec committed Feb 8, 2024
1 parent 8e8e540 commit 365e214
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions .github/workflows/branch-pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,63 @@ on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || 'branch' }} # scope to for the current workflow
cancel-in-progress: ${{ github.event_name == 'pull_request' }} # cancel only PR related jobs

env:
GOLANGCI_LINT_TIMEOUT: 5m
GORELEASER_CURRENT_TAG: "v0.0.0-latest"
BUCKET_NAME: botkube-cloud-plugins-latest

jobs:
cancel-previous-workflows:
name: Cancel previous workflows
lint:
name: Lint code
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
# https://github.com/styfle/cancel-workflow-action#advanced-token-permissions
permissions:
actions: write

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5
with:
access_token: ${{ github.token }}

lint-test:
name: Lint and test
runs-on: ubuntu-latest

steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
# When the files to be extracted are already present,
# tar extraction in Golangci Lint fails with the "File exists"
# errors. These files appear to be present because of
# cache in setup-go, on disabling the cache we are no more seeing
# such error. Cache is to be enabled once the fix is available for
# this issue:
# https://github.com/golangci/golangci-lint-action/issues/807
cache: false

- name: "Check code quality"
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=${{ env.GOLANGCI_LINT_TIMEOUT }}

test:
name: Test code
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4

- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: 'true'

- name: "Run tests"
run: make test

build-plugins:
if: github.event_name == 'pull_request'
name: Build plugins without publish
runs-on: ubuntu-latest
needs: lint-test
if: github.event_name == 'pull_request'
needs: [lint, test]
steps:
- name: "Checkout code"
uses: actions/checkout@v4
Expand Down

0 comments on commit 365e214

Please sign in to comment.