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

Technical/Increase project code quality #59

Merged
merged 1 commit into from
Dec 26, 2022
Merged
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
48 changes: 41 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
---

version: 2.1

defaults: &defaults
working_directory: ~/truemail-go
docker:
- image: cimg/go:1.19

jobs:
linters:
docker:
- image: golangci/golangci-lint:v1.50.1-alpine

steps:
- checkout
- run: golangci-lint run

test:
docker:
- image: cimg/go:1.19.3
working_directory: ~/truemail-go
- run:
name: Installing linters
command: |
apk add --update npm shellcheck yamllint
npm install --global --save-dev git+https://github.com/streetsidesoftware/cspell-cli markdownlint-cli lefthook
cp .circleci/linter_configs/.lefthook.yml lefthook.yml

- run:
name: Running linters
command: lefthook run linters

tests:
<<: *defaults

steps:
- checkout

- run:
name: Running tests with Gotestsum
name: Running tests
command: gotestsum --format standard-verbose -- -coverprofile=coverage_report ./...

- run:
Expand All @@ -41,8 +58,25 @@ jobs:
command: |
bash <(curl -s https://codecov.io/bash) -f coverage_report

release:
<<: *defaults

steps:
- checkout

- run:
name: Publishing new release to Go Packages
command: |
./.circleci/scripts/release.sh

workflows:
build:
jobs:
- linters
- test
- tests
- release:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
33 changes: 33 additions & 0 deletions .circleci/linter_configs/.cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---

enableGlobDot: true

patterns:
- name: GithubUser
pattern: /\[@.+\]/gmx
- name: MarkdownCode
pattern: /`{1,3}.+`{1,3}/gmx
- name: MarkdownCodeBlock
pattern: /^\s*```[\s\S]*?^\s*```/gmx

languageSettings:
- languageId: markdown
ignoreRegExpList:
- Email
- GithubUser
- MarkdownCode
- MarkdownCodeBlock

words:
- Codecov
- Unmarshal
- Trotsenko
- Vladislav
- bestwebua
- codebases
- consts
- dockerized
- struct
- substeps
- truemail
- unexported
2 changes: 2 additions & 0 deletions .golangci.yml → .circleci/linter_configs/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

linters:
enable:
- gocyclo
Expand Down
19 changes: 19 additions & 0 deletions .circleci/linter_configs/.lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

no_tty: true
skip_output:
- meta

linters:
commands:
cspell:
run: cspell-cli lint -c '.circleci/linter_configs/.cspell.yml' '**/*.{txt,md}'
golangci:
run: golangci-lint -c '.circleci/linter_configs/.golangci.yml' run
markdownlint:
run: markdownlint -c '.circleci/linter_configs/.markdownlint.yml' '**/*.md'
shellcheck:
glob: '*.{sh}'
run: shellcheck --norc {all_files}
yamllint:
run: yamllint -c '.circleci/linter_configs/.yamllint.yml' .
9 changes: 9 additions & 0 deletions .circleci/linter_configs/.markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

default: true

MD013:
line_length: 500

MD024:
siblings_only: true
7 changes: 7 additions & 0 deletions .circleci/linter_configs/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

extends: default

rules:
line-length:
max: 200
13 changes: 13 additions & 0 deletions .circleci/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -e

latest_tag() {
git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | cut -d"-" -f 1 | sort | tail -n 1
}

publish_release() {
echo "Triggering pkg.go.dev about new truemail-go release..."
curl -X POST "https://pkg.go.dev/fetch/github.com/truemail-rb/truemail-go@$(latest_tag)"
}

publish_release
6 changes: 3 additions & 3 deletions .github/BRANCH_NAMING_CONVENTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bugfix/fix-some-bug-name

### Squash commits

Please squash all branch commits into the one before openning your PR from your fork. It's simple to do with the git:
Please squash all branch commits into the one before opening your PR from your fork. It's simple to do with the git:

```bash
git rebase -i [hash your first commit of your branch]~1
Expand All @@ -25,9 +25,9 @@ git rebase -i 6467fe36232401fa740af067cfd8ac9ec932fed2~1 # example

### Add commit description

Please complete your commit description folowing next pattern:
Please complete your commit description following next pattern:

```
```code
Technical/Add info files # should be the same name as your branch name
* Added license, changelog, contributing, code of conduct docs
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
---

github: [bestwebua]
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.3] - 2022-12-26

### Added

- Added [`cspell`](https://cspell.org) linter
- Added [`markdownlint`](https://github.com/DavidAnson/markdownlint) linter
- Added [`shellcheck`](https://www.shellcheck.net) linter
- Added [`yamllint`](https://yamllint.readthedocs.io) linter
- Added [`lefthook`](https://github.com/evilmartians/lefthook) linters aggregator

### Fixed

- Fixed typos in project's codebase
- Fixed new project's linter issues

### Updated

- Updated `CircleCI` config

## [1.0.2] - 2022-11-20

- Updated dependencies
Expand Down Expand Up @@ -32,7 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Updated

- Updated `ConfigurationAttr#validate`, tests
- Updated golangci config
- Updated `golangci` config
- Updated package documentation

## [0.1.2] - 2022-02-28
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform

## Feature requests

Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.

## Questions

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Configurable Golang 📨 email validator. Verify email via Regex, DNS, SMTP and
- [Versioning](#versioning)
- [Changelog](CHANGELOG.md)


## Synopsis

Email validation is a tricky thing. There are a number of different ways to validate an email address and all mechanisms must conform with the best practices and provide proper validation. The `truemail-go` package helps you validate emails via regex pattern, presence of DNS records, and real existence of email account on a current email server.
Expand Down Expand Up @@ -202,7 +201,7 @@ configuration := truemail.NewConfiguration(
// This parameter uses for SMTP session in SMTP validation layer.
SmtpPort: 2525,

// Optional parameter. This option will provide to use smtp fail fast behaviour. When
// Optional parameter. This option will provide to use smtp fail fast behavior. When
// smtpFailFast = true it means that Truemail ends smtp validation session after first
// attempt on the first mx server in any fail cases (network connection/timeout error,
// smtp validation error). This feature helps to reduce total time of SMTP validation
Expand Down Expand Up @@ -381,6 +380,7 @@ configuration := truemail.NewConfiguration(
truemail.Validate("[email protected]", configuration, "regex") // returns pointer to validatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "regex") // returns true
```

##### With custom regex pattern

You should define your custom regex pattern in a gem configuration before.
Expand Down Expand Up @@ -487,7 +487,7 @@ By default, you don't need pass with-parameter to use it. Example of usage is sp

##### SMTP fail fast enabled

Truemail can use fail fast behaviour for SMTP validation layer. When `SmtpFailFast = true` it means that `truemail` ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). This feature helps to reduce total time of SMTP validation session up to 1 second.
Truemail can use fail fast behavior for SMTP validation layer. When `SmtpFailFast = true` it means that `truemail` ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). This feature helps to reduce total time of SMTP validation session up to 1 second.

```go
import "github.com/truemail-rb/truemail-go"
Expand Down Expand Up @@ -550,7 +550,7 @@ truemail.IsValid("[email protected]", configuration)

## Truemail family

All Truemail solutions: https://truemail-rb.org
All Truemail solutions: <https://truemail-rb.org>

| Name | Type | Description |
| --- | --- | --- |
Expand All @@ -564,7 +564,7 @@ All Truemail solutions: https://truemail-rb.org

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail-go. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tickets](https://github.com/truemail-rb/truemail-go/issues). Be sure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md).
Bug reports and pull requests are welcome on GitHub at <https://github.com/truemail-rb/truemail-go>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tickets](https://github.com/truemail-rb/truemail-go/issues). Be sure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md).

## License

Expand Down
2 changes: 1 addition & 1 deletion dns_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestDnsResolverCnameRecord(t *testing.T) {

t.Run("when target CNAME record found", func(t *testing.T) {
otherDomain := randomDomain()
dnsRecords := map[string]mockdns.Zone{domain: {CNAME: toDnsHostName(otherDomain)}} // TODO: different go-mockdns behaviour for domain key, should be with dot
dnsRecords := map[string]mockdns.Zone{domain: {CNAME: toDnsHostName(otherDomain)}} // TODO: different go-mockdns behavior for domain key, should be with dot
dnsResolver := createDnsResolver(dnsRecords)
resolvedHostName, err := dnsResolver.cnameRecord(domain)

Expand Down
2 changes: 1 addition & 1 deletion validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (validatorResult *validatorResult) addError(key, value string) {
validatorResult.Errors[key] = value
}

// Structure with behaviour. Responsible for the
// Structure with behavior. Responsible for the
// logic of calling the validation layers sequence
type validator struct {
result *validatorResult
Expand Down