Skip to content

Commit

Permalink
chore: Update go version to 1.20; Refactor scripts (#238)
Browse files Browse the repository at this point in the history
* chore: Bump go version to 1.20

* refactor: Scripts and makefile

* style: Format code

* chore: Refactor makefile

* chore: Bump github.com/obalunenko/getenv to v1.3.0

* ci: Fix pipeline
  • Loading branch information
obalunenko authored Feb 3, 2023
1 parent 3412750 commit a8c6062
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 224 deletions.
3 changes: 1 addition & 2 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
Expand Down Expand Up @@ -105,7 +104,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
3 changes: 2 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contributing

By participating to this project, you agree to abide [code of conduct](https://github.com/obalunenko/advent-of-code/blob/master/.github/CODE_OF_CONDUCT.md).
By participating to this project, you agree to
abide [code of conduct](https://github.com/obalunenko/advent-of-code/blob/master/.github/CODE_OF_CONDUCT.md).

Please note that I'll not accept any PR with new puzzle solutions - I don't like spoilers.

Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ updates:
commit-message:
prefix: "chore"
include: "scope"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
19 changes: 7 additions & 12 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
max-parallel: 3
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Build
steps:
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Run Tests
steps:
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Run linters
steps:
Expand Down Expand Up @@ -186,13 +186,13 @@ jobs:
shell: bash

reports:
needs: [testing, linting, build]
needs: [ testing, linting, build ]
strategy:
fail-fast: true
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Quality reports
steps:
Expand Down Expand Up @@ -227,14 +227,9 @@ jobs:
make install-tools
shell: bash

- name: Prepare test coverage
- name: Prepare test coverage and reports
run: |
make test-cover
shell: bash

- name: Tests report
run: |
make test-sonar-report
make prepare-cover-report
shell: bash

- name: Prepare lint report
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Build
steps:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Regression tests
steps:
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Lint
steps:
Expand Down Expand Up @@ -156,13 +156,13 @@ jobs:
shell: bash

release:
needs: [build, regression_test, linting]
needs: [ build, regression_test, linting ]
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.19' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Release
steps:
Expand Down
46 changes: 23 additions & 23 deletions .golangci.pipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,29 @@ issues:
fix: false

severity:
# Default value is empty string.
# Set the default severity for issues. If severity rules are defined and the issues
# do not match or no severity is provided to the rule this will be the default
# severity applied. Severities should match the supported severity names of the
# selected out format.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error

# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false

# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- dupl
severity: warning
# Default value is empty string.
# Set the default severity for issues. If severity rules are defined and the issues
# do not match or no severity is provided to the rule this will be the default
# severity applied. Severities should match the supported severity names of the
# selected out format.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error

# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false

# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- dupl
severity: warning

run:
issues-exit-code: 1
Expand Down
42 changes: 21 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,29 +153,29 @@ issues:
fix: false

severity:
# Default value is empty string.
# Set the default severity for issues. If severity rules are defined and the issues
# do not match or no severity is provided to the rule this will be the default
# severity applied. Severities should match the supported severity names of the
# selected out format.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error
# Default value is empty string.
# Set the default severity for issues. If severity rules are defined and the issues
# do not match or no severity is provided to the rule this will be the default
# severity applied. Severities should match the supported severity names of the
# selected out format.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error

# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false
# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false

# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- dupl
severity: warning
# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- dupl
severity: warning

run:
issues-exit-code: 0
Expand Down
5 changes: 2 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ release:
gomod:
proxy: true
# If proxy is true, use these environment variables when running `go mod` commands (namely, `go mod tidy`).
# If proxy is true, use these environment variables when running `go mod` commands (namely, `go mod tidy`).
# Defaults to `os.Environ()`.
env:
- GOPROXY=https://proxy.golang.org,direct
Expand Down Expand Up @@ -44,8 +44,7 @@ builds:
- "{{ .Env.GO_BUILD_LDFLAGS }}"
-
universal_binaries:
-
# ID of the source build
- # ID of the source build
#
# Defaults to the project name.
id: cli
Expand Down
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ VERSION ?= $(shell git describe --tags $(git rev-list --tags --max-count=1))
APP_NAME?=aoc-cli
SHELL := env APP_NAME=$(APP_NAME) $(SHELL)

GOTOOLS_IMAGE_TAG?=v0.0.2
GOTOOLS_IMAGE_TAG?=v0.2.1
SHELL := env GOTOOLS_IMAGE_TAG=$(GOTOOLS_IMAGE_TAG) $(SHELL)

COMPOSE_TOOLS_FILE=deployments/docker-compose/go-tools-docker-compose.yml
Expand Down Expand Up @@ -46,18 +46,17 @@ test-cover:
$(COMPOSE_TOOLS_CMD_UP) run-tests-coverage run-tests-coverage
.PHONY: test-cover

## Tests sonar report generate.
test-sonar-report:
./scripts/tests/sonar-report.sh
.PHONY: test-sonar-report
prepare-cover-report: test-cover
$(COMPOSE_TOOLS_CMD_UP) prepare-cover-report prepare-cover-report
.PHONY: prepare-cover-report

## Open coverage report.
open-cover-report: test-cover
open-cover-report: prepare-cover-report
./scripts/open-coverage-report.sh
.PHONY: open-cover-report

## Update readme coverage.
update-readme-cover: build test-cover
update-readme-cover: build prepare-cover-report
$(COMPOSE_TOOLS_CMD_UP) update-readme-coverage update-readme-coverage
.PHONY: update-readme-cover

Expand Down
10 changes: 8 additions & 2 deletions deployments/docker-compose/go-tools-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
working_dir: /app/
volumes:
- ../../:/app/
command: /bin/sh -c ''

fix-imports:
extends:
Expand Down Expand Up @@ -34,6 +35,11 @@ services:
service: tools
entrypoint: /bin/sh -c './scripts/tests/coverage.sh'

prepare-cover-report:
extends:
service: tools
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/tests/prepare-cover-report.sh'

update-readme-coverage:
extends:
service: tools
Expand All @@ -47,12 +53,12 @@ services:
lint-pipeline:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/linting/golangci-pipeline.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/linting/golangci-pipeline.sh'

lint-sonar:
extends:
service: tools
entrypoint: /bin/sh -c './scripts/linting/golangci-sonar.sh'
entrypoint: /bin/sh -c 'git config --global --add safe.directory /app && ./scripts/linting/golangci-sonar.sh'

go-generate:
extends:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/obalunenko/advent-of-code

go 1.19
go 1.20

require (
github.com/briandowns/spinner v1.20.0
github.com/manifoldco/promptui v0.9.0
github.com/obalunenko/getenv v1.2.1
github.com/obalunenko/getenv v1.3.0
github.com/obalunenko/logger v0.5.1
github.com/obalunenko/version v1.1.0
github.com/stretchr/testify v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/obalunenko/getenv v1.2.1 h1:K7kcPZ+E4CxfJDI4JyiQyIzxEFPqYwmfxAZqmzPOIUc=
github.com/obalunenko/getenv v1.2.1/go.mod h1:rQSU30CHN52CamPdfTjUF4dk0oaoTo03kjxw2Yx3s2Y=
github.com/obalunenko/getenv v1.3.0 h1:gBH8OYI2fw+Rfyd8aywMnqRLRNxhI4bLztAZLuOjMVU=
github.com/obalunenko/getenv v1.3.0/go.mod h1:trfsd8x+Ulqtw8DHKTmL1DdM9wgUd8IvOUgo22GLn3U=
github.com/obalunenko/logger v0.5.1 h1:49DIEwy4sBvRzM/OtD/m7zITi5L3S5DtSYZ/WoUrnno=
github.com/obalunenko/logger v0.5.1/go.mod h1:/GnmNcmEV7tAL9StHrs3nDkXAK+TEvChoNY+YYRZww4=
github.com/obalunenko/version v1.1.0 h1:yVua7OHnK3+MJpendeMmAlfzVmq7R1h8MO3Ufz7HEec=
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ GO_BUILD_PACKAGE="${REPO_ROOT}/cmd/${APP}"

rm -rf "${BIN_OUT}"

go build -o "${BIN_OUT}" -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}"
go build -trimpath -o "${BIN_OUT}" -a -ldflags "${GO_BUILD_LDFLAGS}" "${GO_BUILD_PACKAGE}"

echo "Binary compiled at ${BIN_OUT}"
2 changes: 1 addition & 1 deletion scripts/linting/golangci-sonar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ checkInstalled golangci-lint

echo "Linting..."

golangci-lint run --config .golangci.yml > linters.out
golangci-lint run --config .golangci.yml >linters.out

echo "${SCRIPT_NAME} done."
15 changes: 2 additions & 13 deletions scripts/tests/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,11 @@ source "${SCRIPTS_DIR}/helpers-source.sh"

echo "${SCRIPT_NAME} is running... "

checkInstalled gocov

export GO111MODULE=on

rm -rf "${COVER_DIR}"
mkdir -p "${COVER_DIR}"

go test --count=1 -coverprofile "${COVER_DIR}/unit.cov" -covermode=atomic ./...

{
echo "mode: atomic"
tail -q -n +2 "${COVER_DIR}"/*.cov
} >>"${COVER_DIR}/full.cov"

gocov convert "${COVER_DIR}/full.cov" >"${COVER_DIR}/full.json"

checkInstalled 'gocov-html'
go test --count=1 -coverprofile "${COVER_DIR}/unit.cov" -covermode=atomic -json ./... >tests-report.json

gocov-html "${COVER_DIR}/full.json" >"${COVER_DIR}/full.html"
echo "${SCRIPT_NAME} is done... "
Loading

0 comments on commit a8c6062

Please sign in to comment.