Skip to content

Commit

Permalink
Release pipeline with changelog.md only (#38)
Browse files Browse the repository at this point in the history
- also fixed golangci-lint hanging
  • Loading branch information
Jorres authored Oct 31, 2024
1 parent c8ce2f6 commit 930d5af
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 167 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/go.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: check-for-new-release

on:
push:
branches:
- 'master'

jobs:
tag:
runs-on: ubuntu-latest
outputs:
tagcreated: ${{steps.tag-step.outputs.tagcreated}}
tagname: ${{steps.tag-step.outputs.tagname}}
steps:
- uses: actions/checkout@v4
- id: extract-version-step
run: |
echo "version=$(./cicd/version.sh)" >> $GITHUB_ENV
- id: tag-step
uses: butlerlogic/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
with:
root: "./CHANGELOG.md"
tag_prefix: "v"
regex_pattern: '##[\s]*([0-9\.]{3,})'

publish-release:
runs-on: ubuntu-latest
needs: tag
if: ${{ needs.tag.outputs.tagcreated == 'yes' }}
steps:
- uses: actions/checkout@v4
- name: Build
run: |
make build-in-docker
- name: Generate Changelog
run: |
VERSION=$(cicd/version.sh)
cicd/changelog.sh $VERSION > bin/CHANGELOG.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body_path: bin/CHANGELOG.md
files: bin/ydbops*
tag_name: ${{ needs.tag.outputs.tagname }}
env:
GITHUB_TOKEN: ${{ github.token }}
13 changes: 10 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # because we use new-from-rev in golangci-lint
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
- name: golangci-lint-new-code-much-stricter
uses: golangci/golangci-lint-action@v6
with:
version: v1.58.1
version: v1.61.0
args: --verbose --disable-all --new-from-rev=origin/master --enable wrapcheck,stylecheck,funlen,mnd,cyclop
autoformatter:
name: autoformat check
concurrency:
Expand Down Expand Up @@ -63,6 +70,6 @@ jobs:
go mod download
echo "$HOME/go/bin" >> $GITHUB_PATH
- name: build ydbops
run: go build
run: make build
- name: run tests
run: go test -v -p 1 ./... -args -ginkgo.v
125 changes: 56 additions & 69 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 5m
timeout: 5m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1

# include test files or not, default is true
tests: false

# list of build tags, all linters use it. Default is empty list.
#build-tags:
# - mytag

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
Expand All @@ -36,7 +32,6 @@ output:
# print linter name in the end of issue text, default is true
print-linter-name: true


# all available settings of specific linters
linters-settings:
errcheck:
Expand All @@ -58,11 +53,11 @@ linters-settings:
# simplify code: gofmt with `-s` option, true by default
simplify: true
gofumpt:
module-path: github.com/ydb-platform/ydb-go-sdk/v3
module-path: github.com/ydb-platform/ydbops
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/ydb-platform/ydb-go-sdk/v3
local-prefixes: github.com/ydb-platform/ydbops
goconst:
# minimal length of string constant, 3 by default
min-len: 2
Expand Down Expand Up @@ -213,65 +208,62 @@ linters-settings:
# Whether to check exported functions.
# Default: false
checkExported: true

linters:
disable-all: true
enable:
# - cyclop
- dogsled
# - dupl
- errcheck
- errorlint
# - exhaustive
# - exhaustivestruct
# - forbidigo
# - funlen
# - gci
# - gocognit
- goconst
- gocritic
- gocyclo
# - godot
# - godox
- gofmt # On why gofmt when goimports is enabled - https://github.com/golang/go/issues/21476
- gofumpt
- goheader
# - goimports
# - gomnd
# - gomoddirectives
# - gomodguard
- gosec
- gosimple
- govet
# - depguard
# - ifshort
# - ireturn
# - lll
- makezero
- misspell
- ineffassign
- misspell
- nakedret
- nestif
# - nilnil
# - nlreturn
- nolintlint
- prealloc
- predeclared
- rowserrcheck
- revive
# - stylecheck
# - tagliatelle
# - testpackage
# - thelper
# - tenv
# - typecheck
- unconvert
- unparam
- unused
# - varnamelen
- whitespace
# - wrapcheck
# - wsl
- dogsled
- dupl
- errcheck
- errorlint
- exhaustive
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt # On why gofmt when goimports is enabled - https://github.com/golang/go/issues/21476
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- gosimple
- govet
- makezero
- misspell
- ineffassign
- misspell
- nakedret
- nestif
- nilnil
- nolintlint
- prealloc
- predeclared
- rowserrcheck
- revive
- tagliatelle
- testpackage
- thelper
- tenv
- typecheck
- unconvert
- unparam
- unused
- whitespace

# impossible to refactor now, these are launched on all new code:
# - wrapcheck - too many unwrapped errors
# - stylecheck - abbreviations capitalization
# - funlen
# - mnd
# - cyclop

# Disabled forever:
# - varnamelen - short variable names are more normal than this linter thinks
# - godox - TODOs in the code are normal
# - depguard - we don't really have a policy of forbidding stuff
# - lll - virtually impossible to create logs \ help otherwise
# - gosec G115, we use too many uint32 for Node identifiers and false positives are very common

issues:
# List of regexps of issue texts to exclude, empty list by default.
Expand Down Expand Up @@ -318,13 +310,8 @@ issues:
# Show only new issues created in git patch with set file path.
# new-from-patch: path/to/patch/file
exclude-rules:
- path: internal/xatomic/type.go
linters:
- predeclared
- path: _test\.go
linters:
- unused
- unparam
- gocritic
- path: _test\.go
text: "ydb.Connection is deprecated"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.0.10
+ `version` command
+ new release pipeline - modify CHANGELOG.md only, rest is automatic

## 0.0.9
+ Information about version in help output
+ Scripts for build release
22 changes: 13 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
APP_VERSION=$(shell cicd/version.sh)
BINARY_NAME=ydbops
BUILD_DIR=bin

APP_VERSION=$(shell cicd/version.sh)
TODAY=$(shell date --iso=minutes)
GIT_COMMIT=$(shell git rev-parse HEAD)

LDFLAGS="-X github.com/ydb-platform/ydbops/cmd/version.BuildVersion=${APP_VERSION} -X github.com/ydb-platform/ydbops/cmd/version.BuildTimestamp=${TODAY} -X github.com/ydb-platform/ydbops/cmd/version.BuildCommit=${GIT_COMMIT}"

all: build build-macos

Expand All @@ -13,11 +17,11 @@ pre-build:
@mkdir -p $(BUILD_DIR)

build-macos: lint pre-build
GOOS=darwin GOARCH=amd64 go build -ldflags='-X github.com/ydb-platform/ydbops/cmd.buildVersion=${APP_VERSION}' -o ${BUILD_DIR}/${BINARY_NAME}_darwin_amd64 main.go
GOOS=darwin GOARCH=arm64 go build -ldflags='-X github.com/ydb-platform/ydbops/cmd.buildVersion=${APP_VERSION}' -o ${BUILD_DIR}/${BINARY_NAME}_darwin_arm64 main.go
GOOS=darwin GOARCH=amd64 go build -ldflags=${LDFLAGS} -o ${BUILD_DIR}/${BINARY_NAME}_darwin_amd64 main.go
GOOS=darwin GOARCH=arm64 go build -ldflags=${LDFLAGS} -o ${BUILD_DIR}/${BINARY_NAME}_darwin_arm64 main.go

build: lint pre-build
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags='-X github.com/ydb-platform/ydbops/cmd.buildVersion=${APP_VERSION}' -o ${BUILD_DIR}/${BINARY_NAME} main.go
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=${LDFLAGS} -o ${BUILD_DIR}/${BINARY_NAME} main.go
strip bin/${BINARY_NAME}

clear:
Expand All @@ -29,12 +33,12 @@ dep:
docker:
docker build --force-rm -t $(BINARY_NAME) .

build-in-docker: docker
test:
if [ "$(shell uname)" = "Linux" ]; then make build; else make build-macos; fi
ginkgo test ./...

build-in-docker: clear docker
docker rm -f $(BINARY_NAME) || true
docker create --name $(BINARY_NAME) $(BINARY_NAME)
docker cp '$(BINARY_NAME):/app/bin/' $(BUILD_DIR)
docker rm -f $(BINARY_NAME)

clean:
@echo "Cleaning..."
@rm -Rf $(BUILD_DIR)
Loading

0 comments on commit 930d5af

Please sign in to comment.