Skip to content

Commit

Permalink
Revise GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmateusz committed Jan 20, 2024
1 parent 40a2993 commit cd497d8
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 51 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/build-master-branch.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/build-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build Master Branch
on:
push:
branches:
- master
concurrency:
group: ci-master
env:
go-version: "1.21"
jobs:
lint-branch:
uses: ./.github/workflows/lint-branch.yaml
with:
go-version: ${{ env.go-version }}
test-branch:
uses: ./.github/workflows/test-branch.yaml
with:
go-version: ${{ env.go-version }}
26 changes: 0 additions & 26 deletions .github/workflows/check-branch.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Check a Pull Request
on: pull_request
env:
go-version: "1.21"
jobs:
lint-branch:
uses: ./.github/workflows/lint-branch.yaml
with:
go-version: ${{ env.go-version }}
test-branch:
uses: ./.github/workflows/test-branch.yaml
with:
go-version: ${{ env.go-version }}
36 changes: 36 additions & 0 deletions .github/workflows/lint-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run Linter
env:
shell-scheck-version: "2023.1.6"
on:
workflow_dispatch:
inputs:
go-version:
type: string
description: 'Go version'
required: true
workflow_call:
inputs:
go-version:
type: string
description: 'Go version'
required: true
jobs:
lint:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Setup Go
id: setup-go
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}
- name: Run vet
run: "go vet ./..."
- name: Run shellcheck
uses: dominikh/staticcheck-action@v1.3.0
with:
install-go: false
version: ${{ env.shell-scheck-version }}
cache-key: "${{ var.job_id }}/go/${{ inputs.go-version }}/shellcheck/${{ env.shell-scheck-version }}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish a docker image
name: Release a Docker Image
on: [ workflow_dispatch ]
env:
REGISTRY: ghcr.io
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
name: Release a git tag
name: Release a Git Tag
on:
workflow_dispatch:
inputs:
git_tag:
description: 'the git tag to publish'
description: "Git tag"
type: string
required: true
env:
go-version: "1.21"
jobs:
check-branch:
uses: ./.github/workflows/check-branch.yaml
secrets: inherit
publish-tag:
needs: [ check-branch ]
lint-branch:
uses: ./.github/workflows/lint-branch.yaml
with:
go-version: ${{ env.go-version }}
test-branch:
uses: ./.github/workflows/test-branch.yaml
with:
go-version: ${{ env.go-version }}
release-tag:
needs: [ lint-branch, test-branch ]
timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Create the git tag
run: |
git config --global user.name "Glove CI"
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/test-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Tests
on:
workflow_dispatch:
inputs:
go-version:
type: string
description: 'Go version'
required: true
workflow_call:
inputs:
go-version:
type: string
description: 'Go version'
required: true
jobs:
branch:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ inputs.go-version }}
- name: Run tests
run: "go test ./..."
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Upload a code coverage report
on: [workflow_dispatch]
name: Upload a Code Cover Report
on: [ workflow_dispatch ]
jobs:
lint-and-test:
upload-code-cover:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
- run: "go test ./... -coverpkg=glove/internal/...,glove/pkg/... -coverprofile=coverage.out"
- name: Upload coverage reports to Codecov
- run: "go test ./... -coverpkg=github.com/pmateusz/glove/internal/...,github.com/pmateusz/glove/pkg/... -coverprofile=coverage.out"
- name: Upload the cover report to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test:
go test ./...

test-cover:
go test ./... -coverpkg=glove/internal/...,glove/pkg/... -coverprofile=coverage.out
go test ./... -coverpkg=github.com/pmateusz/glove/internal/...,github.com/pmateusz/glove/pkg/... -coverprofile=coverage.out

deps-install:
go get ./...
Expand Down

0 comments on commit cd497d8

Please sign in to comment.