Skip to content

Commit

Permalink
Add max limit of 2 groups to import blocks (#566)
Browse files Browse the repository at this point in the history
## Description

Updates CONTRIBUTING.md with a Go style item.
Also enforces the new style via code in ./ci-checks.sh

## Why is this needed

Consistency within the code base.

## How Has This Been Tested?

Ran locally.

## How are existing users impacted? What migration steps/scripts do we need?

NA

## Checklist:

I have:

- [x] updated the documentation and/or roadmap (if required)
  • Loading branch information
mergify[bot] committed Dec 9, 2021
2 parents b89f887 + d05bf69 commit b18b238
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
nix_path: nixpkgs=channel:nixos-unstable
- name: Fetch Nix Packages
run: nix-shell --run 'true'
- run: ./ci-checks.sh
- run: make bin/gofumpt
- run: PATH=$PWD/bin/:$PATH ./ci-checks.sh
validation:
runs-on: ubuntu-latest
needs:
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ One must support their proposed changes with unit tests.
As you submit a pull request(PR) the CI generates a code coverage report.
It will help you identify parts of the code that are not yet covered in unit tests.

#### Go

##### Import Groups

There should be two groups of import blocks, one for stdlib and the other for everything else.

## Understanding code structure

This is a nonexhaustive list important packages that happen to cover most of the code base.
Expand Down
4 changes: 4 additions & 0 deletions ci-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ if ! nixfmt shell.nix; then
failed=1
fi

if ! git ls-files '*.go' | xargs -I% sh -c 'sed -i "/^import (/,/^)/ { /^\s*$/ d }" % && gofumpt -w -s %'; then
failed=1
fi

if ! git diff | (! grep .); then
failed=1
fi
Expand Down
3 changes: 1 addition & 2 deletions cmd/tink-cli/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"encoding/json"
"fmt"

"github.com/pkg/errors"

"github.com/jedib0t/go-pretty/table"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tinkerbell/tink/client"
"google.golang.org/grpc"
Expand Down
1 change: 0 additions & 1 deletion db/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/tinkerbell/tink/db"
"github.com/tinkerbell/tink/protos/hardware"
pb "github.com/tinkerbell/tink/protos/workflow"

"github.com/tinkerbell/tink/workflow"
)

Expand Down

0 comments on commit b18b238

Please sign in to comment.