Skip to content

Commit

Permalink
chore: make workflow execution more efficient (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code authored Dec 6, 2023
1 parent 740f2d7 commit ba06308
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cleanup_caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cleanup
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/lint.yml → .github/workflows/lint_golang.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: Lint Golang

on:
push:
Expand All @@ -7,6 +7,10 @@ on:
branches:
- main
pull_request:
paths:
- '**.go'
- 'go.md'
- 'go.sum'

permissions:
contents: read
Expand All @@ -16,23 +20,10 @@ concurrency:
cancel-in-progress: true

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
- uses: golangci/golangci-lint-action@v3
with:
version: v1.54.2
args: --timeout 10m

shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run shellcheck
run: make lint-shell
- name: Run shfmt
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/lint_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
main:
permissions:
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
runs-on: ubuntu-latest
steps:
- uses: amannn/[email protected]
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
28 changes: 28 additions & 0 deletions .github/workflows/lint_shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint Shell

on:
push:
tags:
- v*
branches:
- main
pull_request:
paths:
- '**.sh'

permissions:
contents: read

concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run shellcheck
run: make lint-shell
- name: Run shfmt
run: docker run --rm -v $(pwd):/mnt -w /mnt mvdan/shfmt:v3.6.0 -l -d -i 2 .
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get Diff
uses: technote-space/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/solhint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
name: runner solhint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
test-integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.21
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- main
pull_request:
paths:
- '**.go'
- 'go.md'
- 'go.sum'

permissions:
contents: read
Expand All @@ -19,7 +23,7 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.21
Expand Down

0 comments on commit ba06308

Please sign in to comment.