Skip to content

Commit

Permalink
Adds gofmt checker action to GitHub workflow (#6132)
Browse files Browse the repository at this point in the history
* adds gofmt checker action to GitHub workflow
* gofmt applied
  • Loading branch information
farazdagi committed Jun 4, 2020
1 parent 84ae840 commit 53b0c0f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/actions/gofmt/Dockerfile
@@ -0,0 +1,5 @@
FROM cytopia/gofmt

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
12 changes: 12 additions & 0 deletions .github/actions/gofmt/action.yml
@@ -0,0 +1,12 @@
name: 'Gofmt checker'
description: 'Checks that all project files have been properly formatted.'
inputs:
path:
description: 'Path to check'
required: true
default: './'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.path }}
15 changes: 15 additions & 0 deletions .github/actions/gofmt/entrypoint.sh
@@ -0,0 +1,15 @@
#!/bin/sh -l
set -e

cd $GITHUB_WORKSPACE

# Check if any files are not formatted.
nonformatted="$(gofmt -l $1 2>&1)"

# Return if `go fmt` passes.
[ -z "$nonformatted" ] && exit 0

# Notify of issues with formatting.
echo "Following files need to be properly formatted:"
echo "$nonformatted"
exit 1
14 changes: 13 additions & 1 deletion .github/workflows/go.yml
Expand Up @@ -8,11 +8,23 @@ on:

jobs:

check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Gofmt checker
id: gofmt
uses: ./.github/actions/gofmt
with:
path: ./

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/powchain/service_test.go
Expand Up @@ -14,13 +14,13 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
gethTypes "github.com/ethereum/go-ethereum/core/types"
logTest "github.com/sirupsen/logrus/hooks/test"
dbutil "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
mockPOW "github.com/prysmaticlabs/prysm/beacon-chain/powchain/testing"
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
protodb "github.com/prysmaticlabs/prysm/proto/beacon/db"
"github.com/prysmaticlabs/prysm/shared/event"
"github.com/prysmaticlabs/prysm/shared/testutil"
logTest "github.com/sirupsen/logrus/hooks/test"
)

var _ = ChainStartFetcher(&Service{})
Expand Down

0 comments on commit 53b0c0f

Please sign in to comment.