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

[TT-500][TT-682]Add build and lint to integration-tests #11221

Merged
merged 27 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5d59226
Add build and lint to integration-tests
tateexon Nov 7, 2023
adec0fe
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 7, 2023
50b2d40
Fix the build to actually build all the test files
tateexon Nov 7, 2023
6b728d6
Add needs for the new job so it will affect required steps
tateexon Nov 7, 2023
c61b836
Review comments
tateexon Nov 8, 2023
f9a394a
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 8, 2023
697af4b
fix build and lint errors
tateexon Nov 8, 2023
2a48aa9
bump lint and go versions
tateexon Nov 8, 2023
9041ef7
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 8, 2023
b7f4239
lint weirdness in migration test
tateexon Nov 8, 2023
51f12d0
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 8, 2023
59a72ae
Wire the test context in the VRFV2SoakTest Run function to a parent c…
tateexon Nov 8, 2023
309af3b
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 8, 2023
e0ba4b8
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
4d16c29
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 9, 2023
3136d6e
Merge conflict fix and improved .golangci lint file with fixes for those
tateexon Nov 9, 2023
42d3655
One more .golangci cleanup
tateexon Nov 9, 2023
322e014
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
27015ba
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
6c5e88b
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
73837c2
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 9, 2023
faed3cb
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 11, 2023
35e4a15
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 13, 2023
8baaf97
Fix newly added lint errors
tateexon Nov 13, 2023
2369eae
Merge branch 'develop' into TT-653-Migrate-CTF-Packages-To-CTF
tateexon Nov 13, 2023
6bf6b9d
add build to integration-tests makefile
tateexon Nov 13, 2023
86b119d
Merge remote-tracking branch 'origin/develop' into TT-653-Migrate-CTF…
tateexon Nov 13, 2023
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
2 changes: 1 addition & 1 deletion .github/actions/golangci-lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ runs:
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.55.0
version: v1.55.2
# We already cache these directories in setup-go
skip-pkg-cache: true
skip-build-cache: true
Expand Down
72 changes: 51 additions & 21 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,36 @@ jobs:
outputs:
src: ${{ steps.changes.outputs.src }}

build-lint-integration-tests:
name: Build and Lint integration-tests
runs-on: ubuntu20.04-16cores-64GB
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: smartcontractkit/chainlink-github-actions/chainlink-testing-framework/setup-go@e865e376b8c2d594028c8d645dd6c47169b72974 # v2.2.16
with:
test_download_vendor_packages_command: cd ./integration-tests && go mod download
go_mod_path: ./integration-tests/go.mod
cache_key_id: core-e2e-${{ env.MOD_CACHE_VERSION }}
cache_restore_only: "true"
- name: Build Go
run: |
cd ./integration-tests
go build ./...
SELECTED_NETWORKS=SIMULATED go test -run=^# ./...
- name: Lint Go
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.55.2
# We already cache these directories in setup-go
skip-pkg-cache: true
skip-build-cache: true
# only-new-issues is only applicable to PRs, otherwise it is always set to false
only-new-issues: false # disabled for PRs due to unreliability
args: --out-format colored-line-number,checkstyle:golangci-lint-report.xml
working-directory: ./integration-tests

build-chainlink:
environment: integration
permissions:
Expand Down Expand Up @@ -174,7 +204,7 @@ jobs:
pull-requests: write
id-token: write
contents: read
needs: [build-chainlink, changes, compare-tests]
needs: [build-chainlink, changes, compare-tests, build-lint-integration-tests]
env:
SELECTED_NETWORKS: SIMULATED,SIMULATED_1,SIMULATED_2
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
Expand Down Expand Up @@ -242,7 +272,7 @@ jobs:
pull-requests: write
id-token: write
contents: read
needs: [build-chainlink, changes]
needs: [build-chainlink, changes, build-lint-integration-tests]
env:
SELECTED_NETWORKS: SIMULATED,SIMULATED_1,SIMULATED_2
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
Expand Down Expand Up @@ -356,16 +386,16 @@ jobs:
run: |
PORT_BASE=3001
MAX_PORT=8000

# Use PR number as offset. Given GitHub PRs are incremental, this guarantees uniqueness for at least 5000 PRs.
OFFSET=$GITHUB_PR_NUMBER
echo "PR Number: $OFFSET"

# Ensure that we don't exceed the max port
if (( OFFSET > (MAX_PORT - PORT_BASE) )); then
OFFSET=$((OFFSET % (MAX_PORT - PORT_BASE)))
fi

# Map the offset to the port range
REMOTE_PORT=$((PORT_BASE + OFFSET))
echo "REMOTE_PORT=$REMOTE_PORT" >> $GITHUB_OUTPUT
Expand All @@ -376,25 +406,25 @@ jobs:
TRACING_SSH_SERVER: ${{ secrets.TRACING_SSH_SERVER }}
REMOTE_PORT: ${{ steps.generate-port.outputs.REMOTE_PORT }}
run: |
eval $(ssh-agent)
echo "test"
echo "$TRACING_SSH_KEY" | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | base64 --decode | ssh-add -
# f: background process
# N: do not execute a remote command
# R: remote port forwarding
ssh -o StrictHostKeyChecking=no -f -N -R $REMOTE_PORT:127.0.0.1:3000 user-gha@$TRACING_SSH_SERVER
echo "To view Grafana locally:"
echo "ssh -N -L 8000:localhost:$REMOTE_PORT user-gha@$TRACING_SSH_SERVER"
echo "Then visit http://localhost:8000 in a browser."
echo "If you are unable to connect, check with the security team that you have access to the tracing server."
eval $(ssh-agent)
echo "test"
echo "$TRACING_SSH_KEY" | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | wc -c
echo "$TRACING_SSH_KEY" | tr -d '\r' | base64 --decode | ssh-add -
# f: background process
# N: do not execute a remote command
# R: remote port forwarding
ssh -o StrictHostKeyChecking=no -f -N -R $REMOTE_PORT:127.0.0.1:3000 user-gha@$TRACING_SSH_SERVER
echo "To view Grafana locally:"
echo "ssh -N -L 8000:localhost:$REMOTE_PORT user-gha@$TRACING_SSH_SERVER"
echo "Then visit http://localhost:8000 in a browser."
echo "If you are unable to connect, check with the security team that you have access to the tracing server."
- name: Show Grafana Logs
if: steps.check-label.outputs.trace == 'true' && matrix.product.name == 'ocr2' && matrix.product.tag_suffix == '-plugins'
run: |
docker logs grafana
docker logs tempo
docker logs otel-collector
docker logs grafana
docker logs tempo
docker logs otel-collector
- name: Set sleep time to use in future steps
if: steps.check-label.outputs.trace == 'true' && matrix.product.name == 'ocr2' && matrix.product.tag_suffix == '-plugins'
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ on:
useExistingEnv:
description: Set `true` to use existing environment or `false` to deploy CL node and all contracts
required: false
default: false
default: "false"
configBase64:
description: TOML config in base64 (Needed when overriding config or providing contract addresses for existing env)
required: false
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
golang 1.21.1
golang 1.21.4
mockery 2.35.4
nodejs 16.16.0
postgres 13.3
helm 3.10.3
zig 0.10.1
golangci-lint 1.55.0
golangci-lint 1.55.2
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ config-docs: ## Generate core node configuration documentation
.PHONY: golangci-lint
golangci-lint: ## Run golangci-lint for all issues.
[ -d "./golangci-lint" ] || mkdir ./golangci-lint && \
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.55.0 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt


GORELEASER_CONFIG ?= .goreleaser.yaml
Expand Down
78 changes: 78 additions & 0 deletions integration-tests/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
run:
timeout: 15m
linters:
enable:
- exhaustive
- exportloopref
- revive
- goimports
- gosec
- misspell
- rowserrcheck
- errorlint
linters-settings:
exhaustive:
default-signifies-exhaustive: true
goimports:
local-prefixes: github.com/smartcontractkit/chainlink
golint:
min-confidence: 0.999
gosec:
excludes:
- G101
govet:
# report about shadowed variables
check-shadowing: true
revive:
confidence: 0.8
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
# - name: var-naming // doesn't work with some generated names
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
- name: waitgroup-by-value
- name: unconditional-recursion
- name: struct-tag
- name: string-format
- name: string-of-int
- name: range-val-address
- name: range-val-in-closure
- name: modifies-value-receiver
- name: modifies-parameter
- name: identical-branches
- name: get-return
# - name: flag-parameter // probably one we should work on doing better at in the future
# - name: early-return // probably one we should work on doing better at in the future
- name: defer
- name: constant-logical-expr
- name: confusing-naming
- name: confusing-results
- name: bool-literal-in-expr
- name: atomic
issues:
exclude-rules:
- text: "^G404: Use of weak random number generator"
linters:
- gosec
- linters:
- govet
text: "declaration of \"err\" shadows"
3 changes: 2 additions & 1 deletion integration-tests/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
golang 1.21.1
golang 1.21.4
k3d 5.4.6
kubectl 1.25.5
nodejs 18.13.0
golangci-lint 1.55.2
6 changes: 6 additions & 0 deletions integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ install_gotestfmt:
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
set -euo pipefail

lint:
golangci-lint --color=always run ./... --fix -v

build:
@go build ./... && SELECTED_NETWORKS=SIMULATED go test -run=^# ./...

# Builds the test image
# tag: the tag for the test image being built, example: tag=tate
# base_tag: the tag for the base-test-image to use, example: base_tag=latest
Expand Down
1 change: 0 additions & 1 deletion integration-tests/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ func GetMockserverInitializerDataForOTPE(
func TeardownSuite(
t *testing.T,
env *environment.Environment,
logsFolderPath string,
chainlinkNodes []*client.ChainlinkK8sClient,
optionalTestReporter testreporters.TestReporter, // Optionally pass in a test reporter to log further metrics
failingLogLevel zapcore.Level, // Examines logs after the test, and fails the test if any Chainlink logs are found at or above provided level
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/actions/actions_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func UpgradeChainlinkNodeVersionsLocal(
return fmt.Errorf("unable to upgrade node version, found empty image and version, must provide either a new image or a new version")
}
for _, node := range nodes {
if err := node.UpgradeVersion(node.NodeConfig, newImage, newVersion); err != nil {
if err := node.UpgradeVersion(newImage, newVersion); err != nil {
return err
}
}
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/actions/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import (
"github.com/stretchr/testify/require"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
ocr2keepers20config "github.com/smartcontractkit/ocr2keepers/pkg/v2/config"
ocr2keepers30config "github.com/smartcontractkit/ocr2keepers/pkg/v3/config"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/logging"

"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/actions/ocr2_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ import (
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand Down
11 changes: 6 additions & 5 deletions integration-tests/actions/ocr2_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ import (
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/rs/zerolog/log"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/testhelpers"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"
)

func CreateOCRv2JobsLocal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import (
"go.dedis.ch/kyber/v3/group/edwards25519"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"github.com/smartcontractkit/ocr2vrf/altbn_128"
"github.com/smartcontractkit/ocr2vrf/dkg"
"github.com/smartcontractkit/ocr2vrf/ocr2vrf"
ocr2vrftypes "github.com/smartcontractkit/ocr2vrf/types"

"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
)
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/actions/ocr2vrf_actions/ocr2vrf_steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/actions/ocr2vrf_actions/ocr2vrf_constants"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/utils"
)

func SetAndWaitForVRFBeaconProcessToFinish(t *testing.T, ocr2VRFPluginConfig *OCR2VRFPluginConfig, vrfBeacon contracts.VRFBeacon) {
Expand Down Expand Up @@ -172,7 +173,7 @@ func FundVRFCoordinatorV3Subscription(t *testing.T, linkToken contracts.LinkToke
require.NoError(t, err, "Error waiting for TXs to complete")
}

func DeployOCR2VRFContracts(t *testing.T, contractDeployer contracts.ContractDeployer, chainClient blockchain.EVMClient, linkToken contracts.LinkToken, mockETHLinkFeed contracts.MockETHLINKFeed, beaconPeriodBlocksCount *big.Int, keyID string) (contracts.DKG, contracts.VRFCoordinatorV3, contracts.VRFBeacon, contracts.VRFBeaconConsumer) {
func DeployOCR2VRFContracts(t *testing.T, contractDeployer contracts.ContractDeployer, chainClient blockchain.EVMClient, linkToken contracts.LinkToken, beaconPeriodBlocksCount *big.Int, keyID string) (contracts.DKG, contracts.VRFCoordinatorV3, contracts.VRFBeacon, contracts.VRFBeaconConsumer) {
dkg, err := contractDeployer.DeployDKG()
require.NoError(t, err, "Error deploying DKG Contract")

Expand Down Expand Up @@ -272,14 +273,14 @@ func RequestRandomnessFulfillmentAndWaitForFulfilment(
}

func getRequestId(t *testing.T, consumer contracts.VRFBeaconConsumer, receipt *types.Receipt, confirmationDelay *big.Int) *big.Int {
periodBlocks, err := consumer.IBeaconPeriodBlocks(nil)
periodBlocks, err := consumer.IBeaconPeriodBlocks(utils.TestContext(t))
require.NoError(t, err, "Error getting Beacon Period block count")

blockNumber := receipt.BlockNumber
periodOffset := new(big.Int).Mod(blockNumber, periodBlocks)
nextBeaconOutputHeight := new(big.Int).Sub(new(big.Int).Add(blockNumber, periodBlocks), periodOffset)

requestID, err := consumer.GetRequestIdsBy(nil, nextBeaconOutputHeight, confirmationDelay)
requestID, err := consumer.GetRequestIdsBy(utils.TestContext(t), nextBeaconOutputHeight, confirmationDelay)
require.NoError(t, err, "Error getting requestID from consumer contract")

return requestID
Expand All @@ -305,7 +306,6 @@ func SetupOCR2VRFUniverse(
contractDeployer,
chainClient,
linkToken,
mockETHLinkFeed,
ocr2vrf_constants.BeaconPeriodBlocksCount,
ocr2vrf_constants.KeyID,
)
Expand Down
Loading
Loading