Skip to content

Commit

Permalink
Merge pull request #8 from axone-protocol/ci/setup
Browse files Browse the repository at this point in the history
Ci/setup
  • Loading branch information
amimart committed Aug 9, 2024
2 parents c177d58 + 0ffde7d commit f22c60b
Show file tree
Hide file tree
Showing 15 changed files with 692 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,17 @@ updates:
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 2
reviewers:
- "axone-protocol/maintainers"
assignees:
- "axone-protocol/maintainers"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
reviewers:
- "axone-protocol/maintainers"
assignees:
- "axone-protocol/maintainers"
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on:
workflow_call:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
build-go:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/setup-go@v5.0.2
with:
go-version: '1.21'

- name: Build go project
run: |
make build
94 changes: 94 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,100 @@ jobs:
- name: Lint yaml files
uses: ibiqlik/action-yamllint@v3.1.1

lint-go:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed go files
id: changed-go-files
uses: tj-actions/changed-files@v44.5.7
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/setup-go@v5.0.2
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
go-version: "1.21"
cache: false

- name: Lint go code (golangci-lint)
uses: golangci/golangci-lint-action@v6
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
version: v1.59

- name: Lint go code (gofumpt)
if: steps.changed-go-files.outputs.any_changed == 'true'
run: |
go install mvdan.cc/gofumpt@v0.6.0
if [ "$(gofumpt -l .)" != "" ]; then
echo "❌ Code is not gofumpt!"
exit 1
fi
echo "✅ Code is gofumpt!"
analyze-go:
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed go files
id: changed-go-files
uses: tj-actions/changed-files@v44.5.7
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/setup-go@v5.0.2
with:
go-version: "1.21"
cache: false

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "go"

- name: Autobuild project
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

lint-shell:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint shell scripts
uses: ludeeus/action-shellcheck@2.0.0
with:
scandir: .
version: "v0.9.0"
env:
SHELLCHECK_OPTS: -e SC2034

lint-branch-name:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
workflow_dispatch:

jobs:
lint:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/lint.yml

build:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/build.yml

test:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/test.yml

perfom-release:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
needs:
- lint
- build
- test
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.OPS_TOKEN }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Release project
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 22.0.5
branch: main
extra_plugins: |
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
semantic-release-replace-plugin@1.2.7
extends: |
conventional-changelog-conventionalcommits@7.0.1
env:
GITHUB_TOKEN: ${{ secrets.OPS_TOKEN }}
GIT_AUTHOR_NAME: ${{ vars.BOT_GIT_AUTHOR_NAME }}
GIT_AUTHOR_EMAIL: ${{ vars.BOT_GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ vars.BOT_GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.BOT_GIT_COMMITTER_EMAIL }}
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test

on:
workflow_call:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true

jobs:
check-tests:
runs-on: ubuntu-22.04
outputs:
status: ${{ steps.changed-files.outputs.any_changed == 'true' }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Search for all modified files that involve the execution of tests
id: changed-files
uses: tj-actions/changed-files@v44.5.7
with:
files: |
**/*.go
go.mod
go.sum
Makefile
test-go:
runs-on: ubuntu-22.04
needs: check-tests
if: needs.check-tests.outputs.status
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/setup-go@v5.0.2
with:
go-version: "1.21"

- name: Test go project
run: |
make test-go
- name: Upload coverage
uses: codecov/codecov-action@v4
if: github.actor != 'dependabot[bot]'
with:
files: ./target/coverage.txt
env_vars: OS,GOLANG
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
99 changes: 99 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
run:
timeout: 10m

linters:
disable-all: true
enable:
- asciicheck
- bidichk
- bodyclose
- cyclop
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- funlen
- gci
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- goimports
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- makezero
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- prealloc
- predeclared
- promlinter
- revive
- staticcheck
- stylecheck
- tagliatelle
- tenv
- tparallel
- typecheck
- unconvert
- unparam
- unused
- wastedassign
- whitespace

linters-settings:
cyclop:
max-complexity: 20
skip-tests: true
funlen:
statements: 65
godot:
scope: declarations # comments to be checked: `declarations` (default), `toplevel`, or `all`
lll:
line-length: 135
tagliatelle:
case:
use-field-name: true
rules:
json: snake
yaml: snake
output:
uniq-by-line: false

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- source: "^//\\s*go:generate\\s"
linters:
- lll
- source: "(noinspection|TODO)"
linters:
- godot
- source: "//noinspection"
linters:
- gocritic
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
linters:
- errorlint
- path: "_test\\.go"
linters:
- dupl
- funlen
- path: "_test\\.go"
linters:
- revive
text: "dot-imports:"
2 changes: 2 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
line-length: false
no-hard-tabs: false
first-line-h1: false
no-inline-html: false
Loading

0 comments on commit f22c60b

Please sign in to comment.