mirror of
https://github.com/Lifailon/lazyjournal.git
synced 2026-11-11 01:09:46 +01:00
add go ver update workflow and update install dependencies step
This commit is contained in:
@@ -52,14 +52,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Get app version in env
|
||||
run: |
|
||||
|
||||
@@ -93,14 +93,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Start docker containers using compose
|
||||
run: |
|
||||
|
||||
@@ -63,14 +63,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Get build information
|
||||
shell: bash
|
||||
@@ -384,14 +380,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Get app version for build
|
||||
run: |
|
||||
|
||||
@@ -112,15 +112,11 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
if: ${{ github.event.inputs.Push == 'true' && github.event.inputs.Tag == '' }}
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Get tag from app version for build
|
||||
if: ${{ github.event.inputs.Push == 'true' }}
|
||||
|
||||
@@ -40,14 +40,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Start docker containers using compose
|
||||
run: |
|
||||
@@ -141,14 +137,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Start docker containers using compose
|
||||
run: |
|
||||
@@ -186,14 +178,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Run unit test in macOS
|
||||
run: sudo go test -v --run "TestUnixFiles|TestFlags|TestCommandColor|TestCommandFuzzyFilter|TestCommandRegexFilter|TestMainInterface" -cover -coverprofile macos-coverage.out
|
||||
@@ -231,14 +219,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Create log file for Windows
|
||||
run: |
|
||||
@@ -296,14 +280,10 @@ jobs:
|
||||
with:
|
||||
go-version: 1.26
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Download coverage report for Linux (with root)
|
||||
uses: actions/download-artifact@v8
|
||||
|
||||
@@ -7,30 +7,10 @@ on:
|
||||
description: 'Branch for checkout'
|
||||
required: true
|
||||
default: 'main'
|
||||
Update:
|
||||
description: 'Update go version'
|
||||
default: false
|
||||
type: boolean
|
||||
Version:
|
||||
description: 'Version for Go'
|
||||
required: false
|
||||
default: '1.25'
|
||||
Modules:
|
||||
description: 'Update dependencies in modules'
|
||||
default: false
|
||||
type: boolean
|
||||
Golangci:
|
||||
description: 'Golangci linters check'
|
||||
default: false
|
||||
type: boolean
|
||||
Fix:
|
||||
description: 'Golangci linters auto-fix'
|
||||
default: false
|
||||
type: boolean
|
||||
PR:
|
||||
description: 'Create Pull Request'
|
||||
default: false
|
||||
type: boolean
|
||||
Gocrit:
|
||||
description: 'Go critical linters check'
|
||||
default: false
|
||||
@@ -39,6 +19,14 @@ on:
|
||||
description: 'Go security linters check'
|
||||
default: false
|
||||
type: boolean
|
||||
Fix:
|
||||
description: 'Golangci linters auto-fix'
|
||||
default: false
|
||||
type: boolean
|
||||
PR:
|
||||
description: 'Create Pull Request'
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -47,7 +35,6 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
models: read
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -66,64 +53,27 @@ jobs:
|
||||
with:
|
||||
go-version: 1.26
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Code verify and check build
|
||||
run: |
|
||||
go fmt ./...
|
||||
go vet ./...
|
||||
go get ./...
|
||||
go mod tidy
|
||||
go mod verify
|
||||
go build -v ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Get build parameters to summary
|
||||
shell: bash
|
||||
run: |
|
||||
echo "### Parameters" >> $GITHUB_STEP_SUMMARY
|
||||
echo "## Parameters" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Branch for checkout**: ${{ github.event.inputs.Branch }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Update go version**: ${{ github.event.inputs.Update == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Update dependencies in** `go.mod`: ${{ github.event.inputs.Modules == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Golangci linters check**: ${{ github.event.inputs.Golangci == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Golangci linters auto-fix in** `./...`: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Go critical linters check**: ${{ github.event.inputs.Gocrit == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Go security linters check**: ${{ github.event.inputs.Gosec == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Golangci linters auto-fix**: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Get app version in env
|
||||
run: |
|
||||
APP_VERSION=$(go run main.go -v)
|
||||
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Update Go version
|
||||
if: ${{ github.event.inputs.Update == 'true' && github.event.inputs.Version != '' }}
|
||||
run: |
|
||||
go mod edit -go=${{ github.event.inputs.Version }}
|
||||
# go mod edit -toolchain=go${{ github.event.inputs.Version }}
|
||||
go mod tidy
|
||||
|
||||
- name: Reinstall Go on new version
|
||||
if: ${{ github.event.inputs.Update == 'true' && github.event.inputs.Version != '' }}
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: ${{ github.event.inputs.Version }}
|
||||
cache: true
|
||||
|
||||
- name: Update dependencies in modules
|
||||
if: ${{ github.event.inputs.Modules == 'true' }}
|
||||
run: go get -u ./...
|
||||
|
||||
- name: Create Pull Request for update go version amd dependencies
|
||||
if: ${{ github.event.inputs.Modules == 'true' && github.event.inputs.PR == 'true' }}
|
||||
uses: peter-evans/create-pull-request@v8
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "update go version and package dependencies"
|
||||
branch: "fix/${{ env.APP_VERSION }}-update"
|
||||
title: "Updated dependencies"
|
||||
body: "Updated go version and modules in `go.mod` and `go.sum` files."
|
||||
add-paths: |
|
||||
go.mod
|
||||
go.sum
|
||||
|
||||
- name: Install golangci
|
||||
if: ${{ github.event.inputs.golangci == 'true' || github.event.inputs.Fix == 'true' }}
|
||||
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
|
||||
@@ -239,13 +189,12 @@ jobs:
|
||||
👤 **User**: ${{ github.actor }}
|
||||
|
||||
Parameters:
|
||||
**Update go version**: ${{ github.event.inputs.Update == 'true' && '✅' || '❌' }}
|
||||
**Update dependencies in** `go.mod`: ${{ github.event.inputs.Modules == 'true' && '✅' || '❌' }}
|
||||
**Branch for checkout**: ${{ github.event.inputs.Branch }}
|
||||
**Golangci linters check**: ${{ github.event.inputs.Golangci == 'true' && '✅' || '❌' }}
|
||||
**Golangci linters fix in** `./...`: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }}
|
||||
**Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }}
|
||||
**Go critical linters check**: ${{ github.event.inputs.Gocrit == 'true' && '✅' || '❌' }}
|
||||
**Go security linters check**: ${{ github.event.inputs.Gosec == 'true' && '✅' || '❌' }}
|
||||
**Golangci linters auto-fix** `./...`: ${{ github.event.inputs.Fix == 'true' && '✅' || '❌' }}
|
||||
**Create Pull Request**: ${{ github.event.inputs.PR == 'true' && '✅' || '❌' }}
|
||||
|
||||
Results:
|
||||
${{ steps.golangci.outcome == 'failure' && '❌' || '✅' }} **Golangci linters check**: ${{ steps.golangci.outcome }}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
name: "[GO] Go version and modules update"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
Version:
|
||||
description: 'Version for Go'
|
||||
required: true
|
||||
default: '1.26'
|
||||
Modules:
|
||||
description: 'Update dependencies in modules'
|
||||
default: false
|
||||
type: boolean
|
||||
PR:
|
||||
description: 'Create Pull Request'
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Linters check
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository (main branch and last commits)
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: 1.25
|
||||
|
||||
- name: Code verify and check build before updates
|
||||
run: |
|
||||
go vet ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Get app version in env
|
||||
run: |
|
||||
APP_VERSION=$(go run main.go -v)
|
||||
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: Update Go version
|
||||
if: ${{ github.event.inputs.Version != '' }}
|
||||
run: |
|
||||
go mod edit -go=${{ github.event.inputs.Version }}
|
||||
# go mod edit -toolchain=go${{ github.event.inputs.Version }}
|
||||
go mod tidy
|
||||
|
||||
- name: Reinstall Go on new version
|
||||
if: ${{ github.event.inputs.Version != '' }}
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: ${{ github.event.inputs.Version }}
|
||||
cache: true
|
||||
|
||||
- name: Update dependencies in modules
|
||||
if: ${{ github.event.inputs.Modules == 'true' }}
|
||||
run: go get -u ./...
|
||||
|
||||
- name: Code verify and check build after updates
|
||||
run: |
|
||||
go vet ./...
|
||||
go build -v -o /dev/null ./...
|
||||
|
||||
- name: Create Pull Request for update go version and modules
|
||||
if: ${{ github.event.inputs.Modules == 'true' && github.event.inputs.PR == 'true' }}
|
||||
uses: peter-evans/create-pull-request@v8
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "update go version and modules"
|
||||
branch: "ops/go-${{ github.event.inputs.Version }}"
|
||||
title: "Updated Go version and modules"
|
||||
body: "Updated Go version to **${{ github.event.inputs.Version }}** as well as the module dependencies in `go.mod` and `go.sum`."
|
||||
add-paths: |
|
||||
go.mod
|
||||
go.sum
|
||||
Reference in New Issue
Block a user