From d95471534492a7d79f9be2c64cb26287ca502231 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Oct 2023 09:55:10 -0500 Subject: [PATCH] GODRIVER-3008 Use mongodb-drivers-comment-bot for API reports (#1424) (cherry picked from commit 38ed5bb90fe0d41f26bcce8b30d58b808aefce5e) --- .evergreen/config.yml | 15 ++++++++++++- .evergreen/run-tests.sh | 2 +- .github/workflows/comment.yml | 42 ----------------------------------- .gitignore | 4 ++++ Makefile | 4 ---- etc/api_report.sh | 27 +++++++++++++++------- 6 files changed, 38 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/comment.yml diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 96515bc41a..978506ae97 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -54,7 +54,7 @@ functions: export GOCACHE="$(pwd)/.cache" # Set other relevant variables for Evergreen processes. - export DRIVERS_TOOLS="$(pwd)/../drivers-tools" + export DRIVERS_TOOLS="$(dirname $(dirname $(dirname `pwd`)))/drivers-tools" export PROJECT_DIRECTORY="$(pwd)" export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration" export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" @@ -329,6 +329,18 @@ functions: ${PREPARE_SHELL} sh ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh + create-api-report: + - command: shell.exec + type: test + params: + shell: "bash" + working_dir: src/go.mongodb.org/mongo-driver + script: | + ${PREPARE_SHELL} + export BASE_SHA=${revision} + export HEAD_SHA=${github_commit} + bash etc/api_report.sh + send-perf-data: - command: perf.send params: @@ -1190,6 +1202,7 @@ tasks: - func: run-make vars: targets: "check-fmt check-license check-modules lint" + - func: "create-api-report" - name: perf tags: ["performance"] diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 73a0ca6539..2188851bde 100644 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -7,7 +7,7 @@ export GOCACHE="$(pwd)/.cache" export DRIVERS_TOOLS=${DRIVERS_TOOLS:-""} if [ -z $DRIVERS_TOOLS ]; then - export DRIVERS_TOOLS="$(pwd)/../drivers-tools" + export DRIVERS_TOOLS=="$(dirname $(dirname $(dirname `pwd`)))/drivers-tools" fi if [ "Windows_NT" = "$OS" ]; then diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml deleted file mode 100644 index 0b471f3fff..0000000000 --- a/.github/workflows/comment.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: PR API Report -on: - pull_request_target: - types: [review_requested] - -jobs: - comment: - runs-on: ubuntu-latest - permissions: - pull-requests: write - issues: write - environment: - api-report - steps: - - uses: actions/setup-go@v4 - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: "## API Change Report" - - - name: Create the comment body - run: | - set -eux - git clone https://github.com/mongodb/mongo-go-driver - cd mongo-go-driver - git remote add source https://github.com/$GITHUB_REPOSITORY_OWNER/mongo-go-driver - git fetch origin $GITHUB_BASE_REF - git fetch source $GITHUB_HEAD_REF - git checkout $GITHUB_HEAD_REF - make api-report - cat api-report.md - - - name: Create or update comment - uses: peter-evans/create-or-update-comment@v3 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body-path: 'mongo-go-driver/api-report.md' - edit-mode: replace diff --git a/.gitignore b/.gitignore index 369aecd8c1..f5f3edd904 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,10 @@ perf .DS_Store install main.so +.cache +install +libmongocrypt +venv test.suite # AWS SAM-generated files diff --git a/Makefile b/Makefile index aef8162b7a..d6275d44e9 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,6 @@ build: cross-compile build-tests build-compile-check build-tests: go test -short $(BUILD_TAGS) -run ^$$ ./... -.PHONY: api-report -api-report: - etc/api_report.sh - .PHONY: build-compile-check build-compile-check: etc/compile_check.sh diff --git a/etc/api_report.sh b/etc/api_report.sh index ffdac7f975..5478241dca 100755 --- a/etc/api_report.sh +++ b/etc/api_report.sh @@ -3,18 +3,29 @@ # Generates a report of Go Driver API changes for the current branch. set -eux -cmd=$(command -v gorelease || true) +# Skip the report of it isn't a PR run. +if [ "$BASE_SHA" == "$HEAD_SHA" ]; then + echo "Skipping API Report" + exit 0 +fi + +# Ensure a clean checkout. +git checkout -b test-api-report +git add . +git commit -m "local changes" +# Ensure gorelease is installed. +cmd=$(command -v gorelease || true) if [ -z $cmd ]; then go install golang.org/x/exp/cmd/gorelease@latest fi -branch=${GITHUB_BASE_REF:-master} -git fetch origin $branch:$branch -sha=$(git merge-base $branch HEAD) - -gorelease -base=$sha > api-report.txt || true - +# Generate and parse the report. +gorelease -base=$BASE_SHA > api-report.txt || true +cat api-report.txt go run ./cmd/parse-api-report/main.go +rm api-report.txt -rm api-report.txt \ No newline at end of file +# Make the PR comment. +target=$DRIVERS_TOOLS/.evergreen/github_app/create_or_modify_comment.sh +bash $target -m "## API Change Report" -c "$(pwd)/api-report.md" -h $HEAD_SHA -o "mongodb" -n "mongo-go-driver"