From b145321413b45fcef648bbaa80cd410296610f45 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 14 Sep 2024 07:33:18 -0500 Subject: [PATCH] cleanup --- .evergreen/config.yml | 16 ++++++------- Taskfile.yml | 53 +++++++++++++++++++++++++++++++------------ docs/CONTRIBUTING.md | 10 ++++---- etc/prep-perf.sh | 5 ++++ 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 9bc7038d03..05cff358d7 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -101,7 +101,7 @@ functions: go install github.com/go-task/task/v3/cmd/task@latest # Install libmongocrypt. - bash etc/install-libmongocrypt.sh + task install-libmongocrypt if [ "Windows_NT" = "$OS" ]; then export PATH=$PATH:/cygdrive/c/libmongocrypt/bin fi @@ -279,7 +279,7 @@ functions: script: | ${PREPARE_SHELL} export OIDC="oidc" - bash ${PROJECT_DIRECTORY}/etc/run-oidc-test.sh 'task --silent evg-test-oidc-auth' + task test-oidc run-task: - command: shell.exec @@ -312,7 +312,7 @@ functions: ${PREPARE_SHELL} export BASE_SHA=${revision} export HEAD_SHA=${github_commit} - bash etc/api_report.sh + task api-report "add PR labels": - command: shell.exec @@ -394,7 +394,7 @@ functions: include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"] script: | ${PREPARE_SHELL} - bash etc/run-atlas-test.sh + task run-atlas run-ocsp-test: - command: shell.exec @@ -525,8 +525,8 @@ functions: working_dir: src/go.mongodb.org/mongo-driver script: | ${PREPARE_SHELL} - bash etc/run_docker.sh - TOPOLOGY=sharded_cluster bash etc/run_docker.sh test-short + task run-docker + TOPOLOGY=sharded_cluster task run-docker -- test-short run-valid-ocsp-server: - command: shell.exec @@ -1780,7 +1780,7 @@ tasks: working_dir: src/go.mongodb.org/mongo-driver script: | ${PREPARE_SHELL} - bash etc/run-awskms-test.sh + task test-awskms - name: "testawskms-fail-task" # testawskms-fail-task runs without environment variables. @@ -1794,7 +1794,7 @@ tasks: script: | ${PREPARE_SHELL} export EXPECT_ERROR='status=400' - bash etc/run-awskms-test.sh + task test-awskms - name: "testazurekms-task" commands: diff --git a/Taskfile.yml b/Taskfile.yml index 8d5ee918c2..35062e9ee1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -7,7 +7,7 @@ env: tasks: - ### Utility targets. ### + ### Utility tasks. ### default: deps: [build, check-license, check-fmt, check-modules, lint, test-short] @@ -33,8 +33,6 @@ tasks: - GOOS=linux GOARCH=ppc64le go build ./... - GOOS=linux GOARCH=s390x go build ./... - install-lll: go install github.com/walle/lll/...@latest - check-fmt: deps: [install-lll] cmds: @@ -46,12 +44,15 @@ tasks: fmt: go fmt ./... - # NOTE: A golangci-lint version is also pinned in .pre-commit-config.yaml. Make - # sure to change it there to keep it in-sync with what's used here! - install-golangci-lint: - - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 + api-report: etc/api_report.sh + + install-libmongocrypt: etc/install-libmongocrypt.sh - # Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect + run-docker: etc/run_docker.sh + + cherry-picker: etc/cherry-picker.sh + + # Lint with various GOOS and GOARCH tasks to catch static analysis failures that may only affect # specific operating systems or architectures. For example, staticcheck will only check for 64-bit # alignment of atomically accessed variables on 32-bit architectures (see # https://staticcheck.io/docs/checks#SA1027) @@ -67,7 +68,7 @@ tasks: update-notices: etc/generate_notices.pl > THIRD-PARTY-NOTICES - ### Local testing targets. ### + ### Local testing tasks. ### test: go test ${BUILD_TAGS} -timeout {{.TEST_TIMEOUT}}s -p 1 ./... test-cover: @@ -78,14 +79,20 @@ tasks: test-short: go test ${BUILD_TAGS} -timeout 60s -short ./... - ### Local FaaS targets. ### + test-oidc: etc/run-oidc-test.sh 'task --silent evg-test-oidc-auth' + + test-atlas: etc/run-atlas-test.sh + + test-awskms: etc/run-awskms-test.sh + + ### Local FaaS tasks. ### build-faas-awslambda: requires: vars: [MONGODB_URI] cmds: - make -c internal/cmd/faas/awslambda - ### Evergreen specific targets. ### + ### Evergreen specific tasks. ### build-aws-ecs-test: go build ${BUILD_TAGS} ./internal/cmd/testaws/main.go evg-test: @@ -160,15 +167,31 @@ tasks: build-kms-test: go build ${BUILD_TAGS} ./internal/cmd/testkms - ### Benchmark specific targets and support. ### + ### Benchmark specific tasks and support. ### benchmark: - deps: [perf] + deps: [perf-files] cmds: - go test ${BUILD_TAGS} -benchmem -bench=. ./benchmark | test benchmark.suite driver-benchmark: - deps: [perf] + deps: [perf-files] cmds: - go run ./internal/cmd/benchmark | tee perf.suite - perf: etc/prep-perf.sh + ### Internal tasks. ### + perf-files: + internal: true + cmds: + - etc/prep-perf.sh + + install-lll: + internal: true + cmds: + - go install github.com/walle/lll/...@latest + + # NOTE: A golangci-lint version is also pinned in .pre-commit-config.yaml. Make + # sure to change it there to keep it in-sync with what's used here! + install-golangci-lint: + internal: true + cmds: + - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 \ No newline at end of file diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index b0ec3f5c71..fcca800429 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -75,13 +75,13 @@ git config --global github.user If a Pull Request needs to be cherry-picked to a new branch, get the sha of the commit in the base branch, and then run ```bash -bash etc/cherry-picker.sh +task cherry-picker -- ``` By default it will use `master` as the target branch. The branch can be specified as the second argument, e.g. ```bash -bash etc/cherry-picker.sh branch +task cherry-picker -- branch ``` It will create a new checkout in a temp dir, create a new branch, perform the cherry-pick, and then @@ -91,7 +91,7 @@ prompt before creating a PR to the target branch. The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run `task`. This will run coverage, run go-lint, run go-vet, and build the examples. -You can install `libmongocrypt` locally by running `bash etc/build-libmongocrypt.sh`, which will create an `install` directory +You can install `libmongocrypt` locally by running `task install-libmongocrypt`, which will create an `install` directory in the repository top level directory. On Windows you will also need to add `c:/libmongocrypt/` to your `PATH`. ### Testing Different Topologies @@ -227,7 +227,7 @@ See the readme in `$DRIVERS_TOOLS/.evergreen/docker` for more information on usa 1. Finally, run the Go Driver tests using the following script in this repo: ```bash -bash etc/run_docker.sh +make run-docker ``` The script takes an optional argument for the `TASKFILE_TARGET` and allows for some environment variable overrides. @@ -238,7 +238,7 @@ For example, to test against a sharded cluster (make sure you started the server using enterprise auth, run: ```bash -TOPOLOGY=sharded_cluster bash etc/run_docker.sh evg-test-enterprise-auth +TOPOLOGY=sharded_cluster task run-docker -- evg-test-enterprise-auth ``` ## Talk To Us diff --git a/etc/prep-perf.sh b/etc/prep-perf.sh index aa853cd33a..89036d87d7 100644 --- a/etc/prep-perf.sh +++ b/etc/prep-perf.sh @@ -2,6 +2,11 @@ # Prepares perf data. set -eux +if [ -d /testdata/perf/ ]; then + echo "/testdata/perf/ already exists, skipping download" + exit 0 +fi + curl --retry 5 "https://s3.amazonaws.com/boxes.10gen.com/build/driver-test-data.tar.gz" -o driver-test-data.tar.gz --silent --max-time 120 if [ $(uname -s) == "Darwin" ]; then