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 8b4f36e
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 53 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/build-master-branch.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/build-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on:
push:
branches:
- master
concurrency:
group: ci-master
jobs:
lint-branch:
uses: ./.github/workflows/lint-branch.yaml
with:
go-version: 1.21
test-branch:
uses: ./.github/workflows/test-branch.yaml
with:
go-version: 1.21
26 changes: 0 additions & 26 deletions .github/workflows/check-branch.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/check-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check a Pull Request
on: pull_request
jobs:
lint-branch:
uses: ./.github/workflows/lint-branch.yaml
with:
go-version: 1.21
test-branch:
uses: ./.github/workflows/test-branch.yaml
with:
go-version: 1.21
38 changes: 38 additions & 0 deletions .github/workflows/lint-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run Linter
env:
shellcheck-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
with:
fetch-depth: 2
- 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.shellcheck-version }}
cache-key: "${{ vars.GITHUB_JOB }}/go/${{ inputs.go-version }}/shellcheck/$shellcheck-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 All @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Export environment variables
run: |
echo BUILD_TIME=$(date --utc --iso-8601=seconds) >> $GITHUB_ENV
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
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
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: 1.21
test-branch:
uses: ./.github/workflows/test-branch.yaml
with:
go-version: 1.21
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
go-version: 1.21
- 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ for processing HTTP/HTTPS traffic that is passing through the proxy.

[![GitHub Test Badge][1]][2] [![codecov.io][3]][4] [![Goreport][5]][6] [![License][7]][8]

[1]: https://github.com/pmateusz/glove/actions/workflows/build-master-branch.yaml/badge.svg "GitHub Test Badge"
[1]: https://github.com/pmateusz/glove/actions/workflows/build-master.yaml/badge.svg "GitHub Test Badge"

[2]: https://github.com/pmateusz/glove/actions "GitHub Actions Page"

Expand Down

0 comments on commit 8b4f36e

Please sign in to comment.