Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
25f63cf
Add prototype config.yml.
onetechnical Jun 25, 2021
6f15e49
Move circle config to proper location.
onetechnical Jun 25, 2021
aa00149
Add .circleci/config.yml
algojohnlee Jun 25, 2021
0f305f8
add prepare_go command to attempt to clear out existing Go distribution
cce Jun 28, 2021
1183a9d
Clean out more of existing CircleCI go
cce Jun 28, 2021
11d5d05
have Go cleanup step modfiy $BASH_ENV
cce Jun 28, 2021
a617d58
fix NEWPATH
cce Jun 28, 2021
bbe8e9e
Remove travis from branches that list 'circleci'
onetechnical Jun 28, 2021
3b89275
export GOPATH=$HOME/go
cce Jun 28, 2021
11fb003
Fix GOPATH
cce Jun 28, 2021
a8ddbc6
Fix build
cce Jun 28, 2021
e17ffc7
Merge remote-tracking branch 'origin/master' into feature/circleci-split
cce Jun 28, 2021
92eabec
Try making test & integration test dependent on build
cce Jun 28, 2021
9d9b413
run gotestsum directly rather than through makefile
cce Jun 28, 2021
47c7b7c
run gimme before running tests
cce Jun 28, 2021
0fb6012
make go mod cache key match
cce Jun 28, 2021
24276bb
Correctly call packages for split
cce Jun 28, 2021
bc46ec6
download gotestsum before running tests
cce Jun 28, 2021
3f6770e
add GOPATH/bin to path
cce Jun 28, 2021
d001476
Add configure_dev lines
cce Jun 28, 2021
85259b3
Attempt to add parallelization to integration tests
cce Jun 29, 2021
eff24df
upload test results
cce Jun 29, 2021
dc46c48
make arch-generic commands for build, test, integration
cce Jun 29, 2021
755a062
Add gotetsum to integration tests
cce Jun 29, 2021
00c2e27
increase parallelism to 8
cce Jun 29, 2021
404a1b7
Test partitioning utility
algonautshant Jun 29, 2021
1d84aa5
Add arm64 builds
cce Jun 29, 2021
3cf7e18
Merge branch 'shant/turboTests' into feature/circleci-split-turbo
cce Jun 29, 2021
03f7f4d
Run go fmt ./...
cce Jun 29, 2021
1398643
use shant/turboTests PARTITION_TOTAL and PARTITION_ID hashes
cce Jun 29, 2021
cb448ab
Fix lint errors
cce Jun 29, 2021
092fbe9
Use arm64 parallelism
cce Jun 29, 2021
d03fe5e
Use arm64 parallelism
cce Jun 29, 2021
8cd0f17
Add no_output_timeout to short tests
cce Jun 29, 2021
44852be
Add no_output_timeout to short tests
cce Jun 29, 2021
1b382fd
use lowercase testPartitioning to make vet and lint happy
cce Jun 29, 2021
5410138
run check_license.sh -i
cce Jun 29, 2021
cc28c5e
Disable arm64
cce Jun 29, 2021
521b17b
split amd64 and arm64 into separate workflows
cce Jun 29, 2021
f1dbd4a
add build_mac workflow
cce Jun 29, 2021
5d09c73
Fix mac build error
cce Jun 29, 2021
db4cd52
remove parallelism from initial arm64 build step
cce Jun 29, 2021
5a4de45
combine into single workflow
cce Jun 29, 2021
2c0eaef
Merge branch 'feature/circleci-split' into feature/circleci-split-mac
cce Jun 29, 2021
5683a54
single workflow with mac
cce Jun 29, 2021
3cb774a
move homebrew fix up in mac build
cce Jun 29, 2021
a7be031
add homebrew fix to all mac targets
cce Jun 29, 2021
a5ca85f
Use newer MacOS image with newer version of homebrew
cce Jun 29, 2021
d9799e8
Add test partitioning to ExpectFixture.Run expect subtest runner
cce Jun 29, 2021
4ff1ad8
parameterize home dir for mac
cce Jun 29, 2021
132b891
Merge branch 'feature/circleci-split' into feature/circleci-split-turbo
cce Jun 29, 2021
3701ee2
fix double sharding
algonautshant Jun 29, 2021
0a0804f
Remove parallelism: 8 mistake on arm64_build
cce Jun 29, 2021
47e2f51
change to parallelism: 4 for comparison
cce Jun 29, 2021
758a169
Merge pull request #2339 from algonautshant/shant/turboTests
cce Jun 29, 2021
3946996
fix double sharding
algonautshant Jun 29, 2021
fa6cf2b
split out e2e_subs to its own job
cce Jun 30, 2021
a23ab9c
Merge remote-tracking branch 'origin/feature/circleci-split-turbo-4' …
cce Jun 30, 2021
c8bc1da
Merge remote-tracking branch 'origin/feature/circleci-split-turbo-4-s…
cce Jun 30, 2021
715a55d
Try using amd64 "large" for e2e_subs and integration
cce Jun 30, 2021
3676946
Merge remote-tracking branch 'origin/feature/circleci-split-mac' into…
cce Jul 2, 2021
b8d8815
fix parallelism values for max
cce Jul 2, 2021
f7da7fb
Custom search for strings in tests
algojack Jul 14, 2021
e72931d
Updated custom search to use regex
algojack Jul 15, 2021
4d89a5f
rough draft
algojack Jul 22, 2021
73c0896
First running version
algojack Jul 22, 2021
c296018
cleaning up and renaming things
algojack Jul 22, 2021
da07142
Resetting go.mod and go.sum files
algojack Jul 22, 2021
e5bd0bb
Latest changes
algojack Jul 26, 2021
5f8efcc
Merge branch 'master' into jack/custom-search
algojack Jul 26, 2021
ef03119
Checked out latest master
algojack Jul 26, 2021
3db29bb
Checked out latest master
algojack Jul 26, 2021
979841d
Added latest packages
algojack Jul 26, 2021
445f69c
Updated to work with new version of partitiontest
algojack Jul 26, 2021
837d52a
renamed directory
algojack Jul 26, 2021
17f9c5f
Adding draft of linter plugin
algojack Jul 26, 2021
546021d
Removing tests already automatically being tested.
algojack Jul 27, 2021
1c9e345
Clarified imports and naming logic
algojack Jul 27, 2021
51972f0
Fixed license check
algojack Jul 27, 2021
90c9171
Moved files around to follow example golangci linter
algojack Jul 27, 2021
c3800cb
Fixed license
algojack Jul 27, 2021
d9d1bc8
Removed dep from main go.mod
algojack Jul 27, 2021
ca40520
Enabled testing
algojack Jul 28, 2021
e81cfdd
Removed binary
algojack Jul 28, 2021
9790a6e
Added makefile target for building custom linters
algojack Jul 29, 2021
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
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
run:
timeout: 5m
tests: false
tests: true

linters:
enable:
- golint
- misspell
- govet
- ineffassign
- partitiontest

disable:
- deadcode
Expand All @@ -19,6 +20,11 @@ linters:
- varcheck

linters-settings:
custom:
partitiontest:
path: cmd/partitiontest_linter/plugin.so
description: This custom linter checks files that end in '_test.go', specifically functions that start with 'Test' and have testing argument, for a line 'partitiontest.ParitionTest(<testing arg>)'
original-url: github.com/algorand/go-algorand/cmd/partitiontest_linter
# govet:
# check-shadowing: true

Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,8 @@ include ./scripts/release/mule/Makefile.mule

archive:
aws s3 cp tmp/node_pkgs s3://algorand-internal/channel/$(CHANNEL)/$(FULLBUILDNUMBER) --recursive --exclude "*" --include "*$(FULLBUILDNUMBER)*"

build_custom_linters:
cd cmd/partitiontest_linter/
go build -buildmode=plugin -trimpath plugin/plugin.go
cd -
5 changes: 5 additions & 0 deletions cmd/partitiontest_linter/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/algorand/go-algorand/cmd/partitiontest_linter

go 1.16

require golang.org/x/tools v0.1.3
27 changes: 27 additions & 0 deletions cmd/partitiontest_linter/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.3 h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
132 changes: 132 additions & 0 deletions cmd/partitiontest_linter/linter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Copyright (C) 2019-2021 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package linter

import (
"go/ast"
"strings"

"golang.org/x/tools/go/analysis"
)

const packageName string = "partitiontest"
const functionName string = "PartitionTest"
const fileNameSuffix string = "_test.go"
const functionNamePrefix string = "Test"
const parameterType string = "T"

// Analyzer initilization
var Analyzer = &analysis.Analyzer{
Name: "lint",
Doc: "This custom linter checks inside files that end in '_test.go', and inside functions that start with 'Test' and have testing argument, for a line 'partitiontest.ParitionTest(<testing arg>)'",
Run: run,
}

func run(pass *analysis.Pass) (interface{}, error) {
for _, f := range pass.Files {
currentFileName := pass.Fset.File(f.Pos()).Name()
if !strings.HasSuffix(currentFileName, fileNameSuffix) {
continue
}
for _, decl := range f.Decls {
fn, ok := decl.(*ast.FuncDecl)
if !ok || fn.Recv != nil {
// Ignore non-functions or functions with receivers.
continue
}

// Check that function name starts with "Test"
if !strings.HasPrefix(fn.Name.Name, functionNamePrefix) {
continue
}

if !isTestParameterInFunction(fn.Type.Params.List[0].Type, parameterType) {
continue
}
if !isSearchLineInFunction(fn) {
pass.Reportf(fn.Pos(), "%s function is missing %s.%s(<%s type parameter>)", fn.Name.Name, packageName, functionName, parameterType)
}

}
}
return nil, nil
}

func isTestParameterInFunction(typ ast.Expr, wantType string) bool {
ptr, ok := typ.(*ast.StarExpr)
if !ok {
// Not a pointer.
return false
}

if name, ok := ptr.X.(*ast.Ident); ok {
return name.Name == wantType
}
if sel, ok := ptr.X.(*ast.SelectorExpr); ok {
return sel.Sel.Name == wantType
}
return false
}

func isSearchLineInFunction(fn *ast.FuncDecl) bool {
for _, oneline := range fn.Body.List {
if exprStmt, ok := oneline.(*ast.ExprStmt); ok {
if call, ok := exprStmt.X.(*ast.CallExpr); ok {
if fun, ok := call.Fun.(*ast.SelectorExpr); ok {
if !doesPackageNameMatch(fun) {
continue
}
if !doesFunctionNameMatch(fun) {
continue
}
}

if !doesParameterNameMatch(call, fn) {
continue
}

return true
}
}
}
return false
}

func doesPackageNameMatch(fun *ast.SelectorExpr) bool {
if packageobject, ok := fun.X.(*ast.Ident); ok {
if packageobject.Name == packageName {
return true
}
}
return false
}

func doesFunctionNameMatch(fun *ast.SelectorExpr) bool {
return fun.Sel.Name == functionName
}

func doesParameterNameMatch(call *ast.CallExpr, fn *ast.FuncDecl) bool {
for _, oneArg := range call.Args {

if realArg, ok := oneArg.(*ast.Ident); ok {
if realArg.Obj.Name == fn.Type.Params.List[0].Names[0].Obj.Name {
return true
}
}
}
return false
}
27 changes: 27 additions & 0 deletions cmd/partitiontest_linter/linter_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2019-2021 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package linter

import (
"testing"

"golang.org/x/tools/go/analysis/analysistest"
)

func TestAll(t *testing.T) {
analysistest.Run(t, analysistest.TestData(), Analyzer)
}
39 changes: 39 additions & 0 deletions cmd/partitiontest_linter/plugin/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2019-2021 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

package main

import (
linter "github.com/algorand/go-algorand/cmd/partitiontest_linter"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/singlechecker"
)

type analyzerPlugin struct{}

// This must be implemented
func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
return []*analysis.Analyzer{
linter.Analyzer,
}
}

// This must be defined and named 'AnalyzerPlugin'
var AnalyzerPlugin analyzerPlugin

func main() {
singlechecker.Main(linter.Analyzer)
}
73 changes: 73 additions & 0 deletions cmd/partitiontest_linter/testdata/linter_testdata_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (C) 2019-2021 Algorand, Inc.
// This file is part of go-algorand
//
// go-algorand is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// go-algorand is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>.

/*
This file is input file for analyzer_test.go
That's why we are using relative path in import below
It is also why we named this file _test.go, since linter only looks at files that end in _test.go
*/

package linter_testdata

import (
"testing"

"../../../test/partitiontest"
)

func notTestFunction() {}

func notTestFunctionWithWrongParam(t string) {}

func notTestFunctionWithCorrectParam(t *testing.T) {}

func notTestFunctionWithCorrectParamCorrectLine(t *testing.T) {
partitiontest.PartitionTest(t)
}

func notTestFunctionWithCorrectParamWrongLine(t *testing.T) {
println("something")
}

func TestFunctionWithCorrectParamOnly(t *testing.T) {} // want "function is missing partitiontest.PartitionTest"

func TestFunctionWithCorrectParamCorrectLine(t *testing.T) {
partitiontest.PartitionTest(t)
}

func TestFunctionWithCorrectParamBadLine(t *testing.T) { // want "function is missing partitiontest.PartitionTest"
println("something")
}

func TestFunctionWithDifferentName(n *testing.T) {
partitiontest.PartitionTest(n)
}

func TestFunctionWithCorrectParamNotFirstCorrectLine(t *testing.T) {
println("something")
partitiontest.PartitionTest(t)
}

func TestFunctionWithCorrectParamNotLastCorrectLine(t *testing.T) {
partitiontest.PartitionTest(t)
println("something")
}

func TestFunctionWithCorrectParamMiddleCorrectLine(t *testing.T) {
println("something")
partitiontest.PartitionTest(t)
println("something")
}