Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 #20

Merged
merged 24 commits into from
Nov 5, 2022
Merged

V1 #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
60 changes: 0 additions & 60 deletions .github/workflows/all.yaml

This file was deleted.

109 changes: 109 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
on:
push:
branches:
- main
- v1
pull_request:
branches:
- main
- v1
name: Test
env:
GO_TARGET_VERSION: 1.19
OS_TARGET: ubuntu-latest
jobs:
tests:
strategy:
matrix:
go-version:
# - '1.10' doesn't have go module
# - 1.11
# - 1.12 doesn't have errors pkg
- 1.13
- 1.14
- 1.15
- 1.16
- 1.17
- 1.18
- 1.19
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
mongodb-version:
- '6.0'
runs-on: ${{ matrix.os }}
steps:
- name: Set environment by expression
run: |
echo "NEED_CODECOVERAGE=${{ matrix.go-version == env.GO_TARGET_VERSION && matrix.os == env.OS_TARGET }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
~/Library/Caches/go-build # Build cache (Mac)
'%LocalAppData%\go-build' # Build cache (Windows)
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Start MongoDB
if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
uses: supercharge/mongodb-github-action@1.8.0
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs

- name: Tests
if: ${{ matrix.go-version != env.GO_TARGET_VERSION || matrix.os != env.OS_TARGET }}
run: make test

- name: Tests with real databases
if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
run: make test.coverage.with_real_db

- name: Code coverage data
if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
run: |
set -x
COVERAGE_TOTAL=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "COVERAGE_TOTAL=$COVERAGE_TOTAL" >> $GITHUB_ENV
- name: CodeCoverage the Badge
if: ${{ fromJSON(env.NEED_CODECOVERAGE) && github.ref == 'refs/heads/main' }}
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: ${{ secrets.GIST_FILENAME }}
label: coverage
message: ${{ env.COVERAGE_TOTAL }}%
valColorRange: ${{ env.COVERAGE_TOTAL }}
maxColorRange: 100
minColorRange: 0
# TODO turn on when repository will be published
# - uses: jandelgado/gcov2lcov-action@v1
# if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
# with:
# outfile: ./coverage.lcov
# - uses: romeovs/lcov-reporter-action@v0.2.16
# if: ${{ fromJSON(env.NEED_CODECOVERAGE) }}
# with:
# github-token: ${{ secrets.POST_COMMENT_TOKEN }}
# lcov-file: ./coverage.lcov
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_TARGET_VERSION }}
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
.idea
.vscode/*

# OS
.DS_Store

# Binaries for programs and plugins
*.exe
*.exe~
Expand Down
11 changes: 11 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,24 @@ issues:
- linters:
- lll
source: "^//go:generate "
- linters:
- lll
source: "(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+"
- linters:
- lll
source: "// ?TODO "
- path: _test\.go
linters:
- wsl
text: "only cuddled expressions if assigning variable or using from line above"
- path: _test\.go
linters:
- revive
text: "context-keys-type: should not use basic type string as key in context.WithValue"
- path: _test\.go
linters:
- staticcheck
text: "SA1029: should not use built-in type string as key for value; define your own type to avoid collisions"
- &internal_text
path: ^internal
text: "var-naming: don't use an underscore in package name"
Expand Down
33 changes: 30 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,39 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0-beta] - 2022-11-05

### Added

- badges.
- examples.
- test with real mongo db.

## [1.0.0-beta] - 2022-10-24

### Added

- timeout and canceling of transaction.

## [1.0.0-beta] - 2022-10-20

### Added

- chained transaction.

## [1.0.0-beta] - 2022-10-17

### Added

- propagation.
- settings.

## [0.0.0] - 2022-09-08

### Added

- Manager interface.
- Transaction interface.
- sqlx implementation.
- manager interface.
- transaction interface.
- mongo, sql implementations.

[0.0.0]: https://github.com/avito-tech/go-transaction-manager/
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
CVPKG=go list ./... | grep -v mocks | grep -v /internal/
CVPKG=go list ./... | grep -v mocks | grep -v internal/
GO_TEST=go test `$(CVPKG)` -race
GO_TEST_WITH_REAL_DB=$(GO_TEST) --tags=with_real_db
COVERAGE_FILE="coverage.out"
COVERAGE_TMP_FILE="coverage.out.tmp"

test:
$(GO_TEST)

test.with_real_db:
$(GO_TEST_WITH_REAL_DB)

test.coverage:
$(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_TMP_FILE)
$(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_FILE)

test.coverage.with_real_db:
$(GO_TEST_WITH_REAL_DB) -covermode=atomic -coverprofile=$(COVERAGE_FILE)

fmt:
go fmt ./...

lint:
golangci-lint run -v
golangci-lint run -v --timeout=2m

generate:
go generate ./...
Loading