Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
jobs:
test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Install dependencies
run: |
Expand All @@ -27,15 +27,15 @@

lint:
name: Lint
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v5
with:
go-version: 1.20.x
go-version: 1.22.x

- name: Install dependencies
run: go mod download
Expand All @@ -50,20 +50,20 @@
config: revive.toml

commit_lint:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: '${{ secrets.ACCESS_TOKEN }}'
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Install Commitizen
run: pip install -U commitizen

- name: Check commits
Expand Down
66 changes: 14 additions & 52 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permissions:
jobs:
bump_version:
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
name: "Bump version"
steps:
- name: Check out
Expand All @@ -25,59 +25,21 @@ jobs:
token: "${{ secrets.ACCESS_TOKEN }}"
ref: "main"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Config Git User
run: |
git config --local user.email "$GIT_USER_EMAIL"
git config --local user.name "$GIT_USER_NAME"
git config --local pull.ff only

- id: cz
name: Create bump and changelog
run: |
python -m pip install -U commitizen
cz bump --changelog --yes
export REV=`cz version --project`
echo "version=$REV" >> $GITHUB_OUTPUT

- name: Push changes
uses: Woile/github-push-action@master
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
tags: "true"
branch: "main"

- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"

release:
runs-on: ubuntu-latest
name: "Release service"
needs:
- bump_version
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.ACCESS_TOKEN }}"
ref: "main"
changelog_increment_filename: body.md
git_name: ${{ secrets.GIT_NAME }}
git_email: ${{ secrets.GIT_EMAIL }}

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v5
- name: Release
uses: softprops/action-gh-release@v2
with:
go-version: 1.20.x

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --rm-dist
body_path: "body.md"
tag_name: "v${{ env.REVISION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_WEBHOOK }}
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

- name: Print Version
run: echo "Bumped to version v${{ env.REVISION }}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ node_modules/
config.yml
go.work.sum
dist/

flake.lock
88 changes: 88 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
version: "2"

run:
timeout: 2m
allow-parallel-runners: true
go: '1.24'
# build-tags:
# - local

formatters:
exclusions:
paths:
- '\\.data/.*'
- 'node_modules/.*'
- 'vendor/.*'
- '.git/.*'
- '.husky/.*'
- '.github/.*'
- '.idea/.*'
- '.vscode/.*'
- '\\.bin/.*'
enable:
- gci
settings:
golines:
max-len: 120
tab-len: 4
gci:
sections:
- standard
- default
- blank
- dot
- alias
- localmodule
- prefix(github.com/Drafteame/docker-api)
no-inline-comments: true
no-prefix-comments: true
custom-order: true
no-lex-order: true

linters:
exclusions:
paths:
- '\\.data/.*'
- 'node_modules/.*'
- 'vendor/.*'
- '.git/.*'
- '.husky/.*'
- '.github/.*'
- '.idea/.*'
- '.vscode/.*'
- '\\.bin/.*'
rules:
- path: _test\.go$
linters:
- gocognit
- errcheck
- path: .*/test/.*
linters:
- gocognit
- errcheck
enable:
- exptostd
- errcheck
- govet
- gocognit
- goconst
settings:
errcheck:
check-blank: true
govet:
disable-all: true
enable:
- buildtag
- copylocks
- defers
- loopclosure
- lostcancel
- slog
- tests
gocognit:
min-complexity: 15
goconst:
min-len: 2
min-occurrences: 2


47 changes: 0 additions & 47 deletions .goreleaser.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

. "$(dirname "$0")/_/husky.sh"

# check if the env variable GIT_NV is equal to 1, if so, skipp the script
if [ "$GIT_NV" = "1" ]; then
echo "[husky] skipping commit-msg hooks"
exit 0
fi


sh ./.husky/commit-msg-scripts/commitizen.sh

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "[husky] commit validation error"
exit 1
fi
13 changes: 13 additions & 0 deletions .husky/commit-msg-scripts/commitizen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

echo "[commitizen] checking commit message with commitizen"

cz check --commit-msg-file .git/COMMIT_EDITMSG

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "[commitizen] found issues in commit message"
exit 1
fi

exit 0
30 changes: 30 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env sh

. "$(dirname "$0")/_/husky.sh"

if [ "$GIT_NV" = "1" ]; then
echo "[husky] skipping pre-commit hooks"
exit 0
fi

STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR)
GO_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep -E "\.go$|go\.(mod|sum|work|work\.sum)$" || true)

if [ -n "$GO_FILES" ]; then
sh ./.husky/pre-commit-scripts/golangci-lint.sh || exit 1
echo "Running task format..."
task format
if [ $? -ne 0 ]; then
echo "Error: task format failed"
exit 1
fi
fi

sh ./.husky/pre-commit-scripts/goimports-reviser.sh && \
sh ./.husky/pre-commit-scripts/golangci-lint.sh

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "[husky] commit validation error"
exit 1
fi
44 changes: 44 additions & 0 deletions .husky/pre-commit-scripts/go-mod-tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

echo "[go-mod-tidy] checking go.mod files"

function get_base_dir() {
local dir

local file="$1"
dir=$(dirname "$file")

echo "$dir"
}

# Find and process go.mod files
go_mod_files=$(fd 'go.mod' --glob)
go_sum_files=$(fd 'go.sum' --glob)

if [ -n "$go_mod_files" ]; then
for file in $go_mod_files; do
echo "[go-mod-tidy] tidying $file"

cd "$(get_base_dir "$file")" && go mod tidy -v

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
exit 2
fi

# shellcheck disable=SC2164
cd - > /dev/null
done
fi

# add files to git
if [ -n "$go_mod_files" ]; then
git add $go_mod_files
fi

if [ -n "$go_sum_files" ]; then
git add $go_sum_files
fi

git commit -m "deps: tidy go.mod files"
exit 0
Loading