Skip to content

Commit

Permalink
chore(workflow): Run linter in CI (#126)
Browse files Browse the repository at this point in the history
* chore(workflow): Run linter in CI

Signed-off-by: Ce Gao <cegao@tensorchord.ai>

* fix: Update

Signed-off-by: Ce Gao <cegao@tensorchord.ai>

* fix: Update

Signed-off-by: Ce Gao <cegao@tensorchord.ai>

* fix: Update

Signed-off-by: Ce Gao <cegao@tensorchord.ai>
  • Loading branch information
gaocegege authored May 9, 2022
1 parent 6d505a2 commit 22f8fb9
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ on:
- pull_request

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/checkout@v3
- name: Cache Go modules
uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Check Go modules
run: |
-compat=1.17 && git add go.*
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Verify gofmt
run: |
make fmt && git add pkg cmd
git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1);
- name: Verify govet
run: |
make vet && git add pkg cmd
git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1);
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29
test:
name: test
runs-on: ubuntu-latest
Expand All @@ -22,16 +56,19 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.17.2
- uses: actions/cache@v2
- name: Cache Go modules
uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Verify mockgen
run: |
make generate && git add pkg
git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1);
git diff --cached --exit-code || (echo 'Please run "make generate" to verify generate' && exit 1);
- name: Test
run: make test
# - name: send coverage
Expand Down Expand Up @@ -59,25 +96,14 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.17.2
- uses: actions/cache@v2
- name: Cache Go modules
uses: actions/cache@preview
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Check Go modules
run: |
-compat=1.17 && git add go.*
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Check license
run: |
make addlicense && git add .
git diff --cached --exit-code || (echo 'Please run "go mod tidy" to sync Go modules' && exit 1);
- name: Verify gofmt
run: |
make fmt && git add pkg cmd
git diff --cached --exit-code || (echo 'Please run "make fmt" to verify gofmt' && exit 1);
- name: Verify govet
run: |
make vet && git add pkg cmd
git diff --cached --exit-code || (echo 'Please run "make vet" to verify govet' && exit 1);
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Build
run: make
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,9 @@ test: generate
clean:
@-rm -vrf ${OUTPUT_DIR}
@-rm -vrf ${DEBUG_DIR}

fmt: ## Run go fmt against code.
go fmt ./...

vet: ## Run go vet against code.
go vet ./...
4 changes: 3 additions & 1 deletion pkg/lang/frontend/starlark/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ func ruleFuncRun(thread *starlark.Thread, _ *starlark.Builtin,
}

logger.Debugf("rule `%s` is invoked, commands=%v", ruleRun, goCommands)
ir.Run(goCommands)
if err := ir.Run(goCommands); err != nil {
return nil, err
}

return starlark.None, nil
}
1 change: 0 additions & 1 deletion pkg/lang/ir/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ type JupyterConfig struct {
const (
shellBASH = "bash"
shellZSH = "zsh"
shellSH = "sh"
)
2 changes: 2 additions & 0 deletions pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ func signerFromPem(pemBytes []byte, password []byte) (ssh.Signer, error) {
}

// handle encrypted key
//nolint
if x509.IsEncryptedPEMBlock(pemBlock) {
// decrypt PEM
//nolint
pemBlock.Bytes, err = x509.DecryptPEMBlock(pemBlock, []byte(password))
if err != nil {
return nil, fmt.Errorf("decrypting PEM block failed %v", err)
Expand Down

0 comments on commit 22f8fb9

Please sign in to comment.