From 3c516ae16b42df3021e6749d341551ad5f53d5ac Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Tue, 4 Mar 2025 10:29:02 +0100 Subject: [PATCH 01/11] gather sunset/deprecation warnings --- internal/controller/atlas/provider.go | 11 +++++--- internal/deprecation/transport.go | 37 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 internal/deprecation/transport.go diff --git a/internal/controller/atlas/provider.go b/internal/controller/atlas/provider.go index 0297155db9..12f8b33e79 100644 --- a/internal/controller/atlas/provider.go +++ b/internal/controller/atlas/provider.go @@ -17,6 +17,7 @@ package atlas import ( "context" "fmt" + "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/deprecation" "net/http" "net/url" "runtime" @@ -124,7 +125,7 @@ func (p *ProductionProvider) IsResourceSupported(resource api.AtlasCustomResourc func (p *ProductionProvider) SdkClientSet(ctx context.Context, creds *Credentials, log *zap.SugaredLogger) (*ClientSet, error) { var transport http.RoundTripper = digest.NewTransport(creds.APIKeys.PublicKey, creds.APIKeys.PrivateKey) - transport = p.newDryRunTransport(transport) + transport = p.newTransport(transport, log) transport = httputil.NewLoggingTransport(log, false, transport) if p.isLogInDebug { log.Debug("JSON payload diff is enabled for Atlas API requests (PATCH & PUT)") @@ -155,12 +156,14 @@ func (p *ProductionProvider) SdkClientSet(ctx context.Context, creds *Credential }, nil } -func (p *ProductionProvider) newDryRunTransport(delegate http.RoundTripper) http.RoundTripper { +func (p *ProductionProvider) newTransport(delegate http.RoundTripper, log *zap.SugaredLogger) http.RoundTripper { + var t http.RoundTripper = deprecation.NewLoggingTransport(delegate, log.Desugar()) + if p.dryRun { - return dryrun.NewDryRunTransport(delegate) + return dryrun.NewDryRunTransport(t) } - return delegate + return t } func operatorUserAgent() string { diff --git a/internal/deprecation/transport.go b/internal/deprecation/transport.go new file mode 100644 index 0000000000..d61bfc477e --- /dev/null +++ b/internal/deprecation/transport.go @@ -0,0 +1,37 @@ +package deprecation + +import ( + "net/http" + + "go.uber.org/zap" +) + +type Transport struct { + delegate http.RoundTripper + logger *zap.Logger +} + +func NewLoggingTransport(delegate http.RoundTripper, logger *zap.Logger) *Transport { + return &Transport{ + delegate: delegate, + logger: logger.Named("deprecated"), + } +} + +func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { + resp, err := t.delegate.RoundTrip(req) + if resp != nil { + javaMethod := resp.Header.Get("X-Java-Method") + deprecation := resp.Header.Get("Deprecation") + sunset := resp.Header.Get("Sunset") + + if deprecation != "" { + t.logger.Warn("deprecation", zap.String("date", deprecation), zap.String("javaMethod", javaMethod), zap.String("path", req.URL.Path), zap.String("method", req.Method)) + } + + if sunset != "" { + t.logger.Warn("sunset", zap.String("date", sunset), zap.String("javaMethod", javaMethod), zap.String("path", req.URL.Path), zap.String("method", req.Method)) + } + } + return resp, err +} From c7e2607cea2d776c2e396ebb6c24fb54b97d1f17 Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Thu, 3 Jul 2025 17:05:45 +0100 Subject: [PATCH 02/11] Add env var for deprecation warnings in logs --- internal/controller/atlas/provider.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/controller/atlas/provider.go b/internal/controller/atlas/provider.go index 12f8b33e79..f2c68f272b 100644 --- a/internal/controller/atlas/provider.go +++ b/internal/controller/atlas/provider.go @@ -20,6 +20,7 @@ import ( "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/deprecation" "net/http" "net/url" + "os" "runtime" "strings" @@ -157,13 +158,15 @@ func (p *ProductionProvider) SdkClientSet(ctx context.Context, creds *Credential } func (p *ProductionProvider) newTransport(delegate http.RoundTripper, log *zap.SugaredLogger) http.RoundTripper { - var t http.RoundTripper = deprecation.NewLoggingTransport(delegate, log.Desugar()) + if os.Getenv("AKO_DEPRECATION_WARNINGS") != "" { + return deprecation.NewLoggingTransport(delegate, log.Desugar()) + } if p.dryRun { - return dryrun.NewDryRunTransport(t) + return dryrun.NewDryRunTransport(delegate) } - return t + return delegate } func operatorUserAgent() string { From 63e01d9b4e628efdfe4f7a151194d0bc298cf283 Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Thu, 3 Jul 2025 17:06:21 +0100 Subject: [PATCH 03/11] include deprecation type in json body --- internal/deprecation/transport.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/deprecation/transport.go b/internal/deprecation/transport.go index d61bfc477e..c58987e024 100644 --- a/internal/deprecation/transport.go +++ b/internal/deprecation/transport.go @@ -26,11 +26,11 @@ func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { sunset := resp.Header.Get("Sunset") if deprecation != "" { - t.logger.Warn("deprecation", zap.String("date", deprecation), zap.String("javaMethod", javaMethod), zap.String("path", req.URL.Path), zap.String("method", req.Method)) + t.logger.Warn("deprecation", zap.String("type", "deprecation"), zap.String("date", deprecation), zap.String("javaMethod", javaMethod), zap.String("path", req.URL.Path), zap.String("method", req.Method)) } if sunset != "" { - t.logger.Warn("sunset", zap.String("date", sunset), zap.String("javaMethod", javaMethod), zap.String("path", req.URL.Path), zap.String("method", req.Method)) + t.logger.Warn("sunset", zap.String("type", "sunset"), zap.String("date", sunset), zap.String("javaMethod", javaMethod), zap.String("path", req.URL.Path), zap.String("method", req.Method)) } } return resp, err From 4386b6fd9d15e571b22ed9595aa0d0974608be9c Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Thu, 3 Jul 2025 17:06:49 +0100 Subject: [PATCH 04/11] parse logs for deprecation warnings after e2e run --- .github/workflows/test-e2e.yml | 35 ++++++++++ tools/scandeprecation/scan_deprecations.go | 76 ++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 tools/scandeprecation/scan_deprecations.go diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 5ab452d2dd..0a0bca4cde 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -68,6 +68,10 @@ jobs: needs: [prepare-e2e] runs-on: ubuntu-latest environment: test + env: + GHCR_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease + GHCR_BUNDLES_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-bundles-prerelease + AKO_DEPRECATION_WARNINGS: true strategy: fail-fast: false matrix: @@ -231,3 +235,34 @@ jobs: with: name: logs path: output/** + gather-deprecations: + name: Gather Deprecation Warnings + environment: test + needs: [e2e] + runs-on: ubuntu-latest + steps: + # Get GitHub logs for run; + # Get only lines with 'javaMethod'; + # Parse the JSON within; + # Grab the unique fields we want; + # Check the length (leave no comment if there are no deprecations); + # Create a Markdown table from the JSON for the comment; + - name: Parse logs from e2e tests + run: | + LOGS=$(gh run view ${{ github.run_id }} --log | grep "javaMethod" | grep -o '{.*}' | jq '{javaMethod, type, date}' | jq -s 'unique | sort_by(.javaMethod)') + LOGS_LENGTH=$(echo $LOGS | jq '. | length') + echo "LOGS_LENGTH=$LOGS_LENGTH" >> $GITHUB_ENV + LOGS_TABLE=$(echo $LOGS | jq -r '"|Type|Java Method|Date|\n|------|------|------|\n" + (map("\(.type)|\(.javaMethod)|\(.date)|") | join("\n"))')) + echo "LOGS_TABLE=$LOGS_TABLE" >> $GITHUB_ENV + - name: Create comment from data + if: ${{ ! env.LOGS_LENGTH == 0 }} + uses: actions/github-script@v7 + with: + github-token: ${{ }} #TODO: This needs a secret in the test env to leave comments + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + issue_number: context.issue.number, + repo: context.repo.repo, + body: process.env.LOGS_TABLE + }) diff --git a/tools/scandeprecation/scan_deprecations.go b/tools/scandeprecation/scan_deprecations.go new file mode 100644 index 0000000000..6af55ff018 --- /dev/null +++ b/tools/scandeprecation/scan_deprecations.go @@ -0,0 +1,76 @@ +package main + +import ( + "bufio" + "cmp" + "encoding/json" + "fmt" + "go.uber.org/zap" + "os" + "slices" + "strings" +) + +type DeprecationResponse struct { + Type string `json:"type"` + Date string `json:"date"` + JavaMethod string `json:"javaMethod"` +} + +func main() { + l, err := zap.NewProduction() + if err != nil { + panic(err) + } + log := l.Sugar() + + // Take file from GH CLI tool (which has already aggregated logs) + file, err := os.Open("/Users/roo.thorp/test/log.out") // TODO: This is a local test file currently :) + if err != nil { + log.Fatal("failed to open log file", zap.Error(err)) + } + defer file.Close() + + scanner := bufio.NewScanner(file) + var responses []DeprecationResponse + var out strings.Builder + // Markdown table header for GH Comment + out.WriteString("|Type|Java Method|Date|\n|------|------|------|\n") + + for scanner.Scan() { + example := scanner.Text() + // Non-JSON logs mean we split by tabs + split := strings.Split(example, "\t") + + // Last element is the JSON "body" of the log line + example = split[len(split)-1] + + res := DeprecationResponse{} + err = json.Unmarshal([]byte(example), &res) + if err != nil { + log.Warn("failed to unmarshal JSON", zap.Error(err)) + continue + } + responses = append(responses, res) + } + + // Sort & Compact to remove duplicates + slices.SortFunc(responses, func(a, b DeprecationResponse) int { + if a.JavaMethod != b.JavaMethod { + return cmp.Compare(a.JavaMethod, b.JavaMethod) + } + if a.Type != b.Type { + return cmp.Compare(a.Type, b.Type) + } + return cmp.Compare(a.Date, b.Date) + }) + responses = slices.Compact(responses) + + // Build the Markdown table + for _, res := range responses { + out.WriteString(res.Type + "|" + res.JavaMethod + "|" + res.Date + "|\n") + } + + // Print to stdout + fmt.Println(out.String()) +} From a77143e47e7f9943eaeb41130240b604efc37dbc Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Thu, 10 Jul 2025 11:21:16 +0100 Subject: [PATCH 05/11] use go binary instead of bash --- .github/workflows/test-e2e.yml | 31 +++++++++++----------- .gitignore | 1 + Makefile | 3 +++ tools/scandeprecation/go.mod | 7 +++++ tools/scandeprecation/go.sum | 14 ++++++++++ tools/scandeprecation/scan_deprecations.go | 15 +++++------ 6 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 tools/scandeprecation/go.mod create mode 100644 tools/scandeprecation/go.sum diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 0a0bca4cde..a83f42aae6 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -237,32 +237,33 @@ jobs: path: output/** gather-deprecations: name: Gather Deprecation Warnings - environment: test + environment: release needs: [e2e] runs-on: ubuntu-latest steps: - # Get GitHub logs for run; - # Get only lines with 'javaMethod'; - # Parse the JSON within; - # Grab the unique fields we want; - # Check the length (leave no comment if there are no deprecations); - # Create a Markdown table from the JSON for the comment; - name: Parse logs from e2e tests run: | - LOGS=$(gh run view ${{ github.run_id }} --log | grep "javaMethod" | grep -o '{.*}' | jq '{javaMethod, type, date}' | jq -s 'unique | sort_by(.javaMethod)') - LOGS_LENGTH=$(echo $LOGS | jq '. | length') - echo "LOGS_LENGTH=$LOGS_LENGTH" >> $GITHUB_ENV - LOGS_TABLE=$(echo $LOGS | jq -r '"|Type|Java Method|Date|\n|------|------|------|\n" + (map("\(.type)|\(.javaMethod)|\(.date)|") | join("\n"))')) - echo "LOGS_TABLE=$LOGS_TABLE" >> $GITHUB_ENV + devbox run -- 'make tools/scandeprecation/scandeprecation' + LOGS=$(gh run view ${{ github.run_id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) + echo "LOGS=$LOGS" >> $GITHUB_ENV` + - name: Generate GitHub App Token + id: generate_token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ secrets.AKO_RELEASER_APP_ID }} + private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + mongodb-atlas-kubernetes - name: Create comment from data - if: ${{ ! env.LOGS_LENGTH == 0 }} + if: ${{ ! env.LOGS == '' }} uses: actions/github-script@v7 with: - github-token: ${{ }} #TODO: This needs a secret in the test env to leave comments + github-token: ${{ steps.generate_token.outputs.token }} script: | github.rest.issues.createComment({ owner: context.repo.owner, issue_number: context.issue.number, repo: context.repo.repo, - body: process.env.LOGS_TABLE + body: process.env.LOGS }) diff --git a/.gitignore b/.gitignore index 981ef2cfb1..30e9d581a6 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ deploy/ tools/clean/clean tools/makejwt/makejwt tools/metrics/metrics +tools/scandeprecation/scandeprecations # ignore the ako.siging key local copy ako.pem diff --git a/Makefile b/Makefile index c12e64a668..4255e685d0 100644 --- a/Makefile +++ b/Makefile @@ -644,3 +644,6 @@ install-ako-helm: --set subobjectDeletionProtection=false \ --namespace=$(HELM_AKO_NAMESPACE) --create-namespace kubectl get crds + +tools/scandeprecation/scandeprecation: tools/scandeprecation/*.go + cd tools/scandeprecation && go build . \ No newline at end of file diff --git a/tools/scandeprecation/go.mod b/tools/scandeprecation/go.mod new file mode 100644 index 0000000000..1b71739ae2 --- /dev/null +++ b/tools/scandeprecation/go.mod @@ -0,0 +1,7 @@ +module tools/scandeprecations + +go 1.24.4 + +require go.uber.org/zap v1.27.0 + +require go.uber.org/multierr v1.10.0 // indirect diff --git a/tools/scandeprecation/go.sum b/tools/scandeprecation/go.sum new file mode 100644 index 0000000000..2d29b57e61 --- /dev/null +++ b/tools/scandeprecation/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tools/scandeprecation/scan_deprecations.go b/tools/scandeprecation/scan_deprecations.go index 6af55ff018..c106ae0378 100644 --- a/tools/scandeprecation/scan_deprecations.go +++ b/tools/scandeprecation/scan_deprecations.go @@ -24,14 +24,8 @@ func main() { } log := l.Sugar() - // Take file from GH CLI tool (which has already aggregated logs) - file, err := os.Open("/Users/roo.thorp/test/log.out") // TODO: This is a local test file currently :) - if err != nil { - log.Fatal("failed to open log file", zap.Error(err)) - } - defer file.Close() - - scanner := bufio.NewScanner(file) + // Take input from stdin (pipe from GitHub CLI) + scanner := bufio.NewScanner(os.Stdin) var responses []DeprecationResponse var out strings.Builder // Markdown table header for GH Comment @@ -54,6 +48,11 @@ func main() { responses = append(responses, res) } + // Quit out if there is no deprecations logged + if len(responses) == 0 { + os.Exit(0) + } + // Sort & Compact to remove duplicates slices.SortFunc(responses, func(a, b DeprecationResponse) int { if a.JavaMethod != b.JavaMethod { From 9588c09b80937d1ec0f352c0375f27a245125627 Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Thu, 10 Jul 2025 11:23:46 +0100 Subject: [PATCH 06/11] add headers --- internal/controller/atlas/provider.go | 2 +- internal/deprecation/transport.go | 14 ++++++++++++++ tools/scandeprecation/scan_deprecations.go | 17 ++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/internal/controller/atlas/provider.go b/internal/controller/atlas/provider.go index f2c68f272b..8317a7b0fa 100644 --- a/internal/controller/atlas/provider.go +++ b/internal/controller/atlas/provider.go @@ -17,7 +17,6 @@ package atlas import ( "context" "fmt" - "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/deprecation" "net/http" "net/url" "os" @@ -31,6 +30,7 @@ import ( "github.com/mongodb/mongodb-atlas-kubernetes/v2/api" akov2 "github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1" + "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/deprecation" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/dryrun" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/httputil" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/version" diff --git a/internal/deprecation/transport.go b/internal/deprecation/transport.go index c58987e024..68ce42ea9e 100644 --- a/internal/deprecation/transport.go +++ b/internal/deprecation/transport.go @@ -1,3 +1,17 @@ +// Copyright 2025 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package deprecation import ( diff --git a/tools/scandeprecation/scan_deprecations.go b/tools/scandeprecation/scan_deprecations.go index c106ae0378..b975e8ad9d 100644 --- a/tools/scandeprecation/scan_deprecations.go +++ b/tools/scandeprecation/scan_deprecations.go @@ -1,3 +1,17 @@ +// Copyright 2025 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package main import ( @@ -5,10 +19,11 @@ import ( "cmp" "encoding/json" "fmt" - "go.uber.org/zap" "os" "slices" "strings" + + "go.uber.org/zap" ) type DeprecationResponse struct { From 63b95e1a3d09fe7a3bc80d7943264bab0cd66efb Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Mon, 21 Jul 2025 09:51:41 +0100 Subject: [PATCH 07/11] fix http roundtripper --- internal/controller/atlas/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/controller/atlas/provider.go b/internal/controller/atlas/provider.go index 8317a7b0fa..9f8a5fae23 100644 --- a/internal/controller/atlas/provider.go +++ b/internal/controller/atlas/provider.go @@ -159,7 +159,7 @@ func (p *ProductionProvider) SdkClientSet(ctx context.Context, creds *Credential func (p *ProductionProvider) newTransport(delegate http.RoundTripper, log *zap.SugaredLogger) http.RoundTripper { if os.Getenv("AKO_DEPRECATION_WARNINGS") != "" { - return deprecation.NewLoggingTransport(delegate, log.Desugar()) + delegate = deprecation.NewLoggingTransport(delegate, log.Desugar()) } if p.dryRun { From a59e5b61847345da8a66c180bb9b55631a4bac2f Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Thu, 24 Jul 2025 10:53:56 +0100 Subject: [PATCH 08/11] initialize devbox in github action --- .github/workflows/test-e2e.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index a83f42aae6..67efb913f4 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -241,11 +241,13 @@ jobs: needs: [e2e] runs-on: ubuntu-latest steps: - - name: Parse logs from e2e tests - run: | - devbox run -- 'make tools/scandeprecation/scandeprecation' - LOGS=$(gh run view ${{ github.run_id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) - echo "LOGS=$LOGS" >> $GITHUB_ENV` + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + - name: Install devbox + uses: jetify-com/devbox-install-action@v0.13.0 + with: + enable-cache: 'true' - name: Generate GitHub App Token id: generate_token uses: actions/create-github-app-token@v2 @@ -255,6 +257,13 @@ jobs: owner: ${{ github.repository_owner }} repositories: | mongodb-atlas-kubernetes + - name: Parse logs from e2e tests + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + devbox run -- 'make tools/scandeprecation/scandeprecation' + LOGS=$(gh run view ${{ github.run_id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) + echo "LOGS=$LOGS" >> $GITHUB_ENV` - name: Create comment from data if: ${{ ! env.LOGS == '' }} uses: actions/github-script@v7 From 7470c230c458d62acf8b0b7e6cd3849fe4665624 Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Mon, 28 Jul 2025 09:51:32 +0100 Subject: [PATCH 09/11] move to seperate workflow --- .github/workflows/gather-deprecations.yml | 50 +++++++++++++++++++++++ .github/workflows/test-e2e.yml | 41 ------------------- 2 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/gather-deprecations.yml diff --git a/.github/workflows/gather-deprecations.yml b/.github/workflows/gather-deprecations.yml new file mode 100644 index 0000000000..97de9c3d5d --- /dev/null +++ b/.github/workflows/gather-deprecations.yml @@ -0,0 +1,50 @@ + + name: E2E tests + + on: + workflow_run: + workflows: [E2E tests] + types: + - completed + + jobs: + gather-deprecations: + name: Gather Deprecation Warnings + environment: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha || github.sha }} + - name: Install devbox + uses: jetify-com/devbox-install-action@v0.13.0 + with: + enable-cache: 'true' + - name: Generate GitHub App Token + id: generate_token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ secrets.AKO_RELEASER_APP_ID }} + private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + mongodb-atlas-kubernetes + - name: Parse logs from e2e tests + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + devbox run -- 'make tools/scandeprecation/scandeprecation' + LOGS=$(gh run view ${{ context.payload.workflow_run.id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) + echo "LOGS=$LOGS" >> $GITHUB_ENV` + - name: Create comment from data + if: ${{ ! env.LOGS == '' }} + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate_token.outputs.token }} + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + issue_number: context.issue.number, + repo: context.repo.repo, + body: process.env.LOGS + }) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 67efb913f4..63081836c6 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -235,44 +235,3 @@ jobs: with: name: logs path: output/** - gather-deprecations: - name: Gather Deprecation Warnings - environment: release - needs: [e2e] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha || github.sha }} - - name: Install devbox - uses: jetify-com/devbox-install-action@v0.13.0 - with: - enable-cache: 'true' - - name: Generate GitHub App Token - id: generate_token - uses: actions/create-github-app-token@v2 - with: - app-id: ${{ secrets.AKO_RELEASER_APP_ID }} - private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }} - owner: ${{ github.repository_owner }} - repositories: | - mongodb-atlas-kubernetes - - name: Parse logs from e2e tests - env: - GH_TOKEN: ${{ steps.generate_token.outputs.token }} - run: | - devbox run -- 'make tools/scandeprecation/scandeprecation' - LOGS=$(gh run view ${{ github.run_id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) - echo "LOGS=$LOGS" >> $GITHUB_ENV` - - name: Create comment from data - if: ${{ ! env.LOGS == '' }} - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate_token.outputs.token }} - script: | - github.rest.issues.createComment({ - owner: context.repo.owner, - issue_number: context.issue.number, - repo: context.repo.repo, - body: process.env.LOGS - }) From 643aaf5babe4018c2af9932a63f50846f0a662fd Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Fri, 15 Aug 2025 11:16:46 +0100 Subject: [PATCH 10/11] cleanup workflow yaml --- .github/workflows/gather-deprecations.yml | 95 +++++++++++------------ 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/.github/workflows/gather-deprecations.yml b/.github/workflows/gather-deprecations.yml index 97de9c3d5d..0b2b783e28 100644 --- a/.github/workflows/gather-deprecations.yml +++ b/.github/workflows/gather-deprecations.yml @@ -1,50 +1,49 @@ +name: Gather Deprecations - name: E2E tests +on: + workflow_run: + workflows: [E2E tests] + types: + - completed - on: - workflow_run: - workflows: [E2E tests] - types: - - completed - - jobs: - gather-deprecations: - name: Gather Deprecation Warnings - environment: release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.workflow_run.head_sha || github.sha }} - - name: Install devbox - uses: jetify-com/devbox-install-action@v0.13.0 - with: - enable-cache: 'true' - - name: Generate GitHub App Token - id: generate_token - uses: actions/create-github-app-token@v2 - with: - app-id: ${{ secrets.AKO_RELEASER_APP_ID }} - private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }} - owner: ${{ github.repository_owner }} - repositories: | - mongodb-atlas-kubernetes - - name: Parse logs from e2e tests - env: - GH_TOKEN: ${{ steps.generate_token.outputs.token }} - run: | - devbox run -- 'make tools/scandeprecation/scandeprecation' - LOGS=$(gh run view ${{ context.payload.workflow_run.id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) - echo "LOGS=$LOGS" >> $GITHUB_ENV` - - name: Create comment from data - if: ${{ ! env.LOGS == '' }} - uses: actions/github-script@v7 - with: - github-token: ${{ steps.generate_token.outputs.token }} - script: | - github.rest.issues.createComment({ - owner: context.repo.owner, - issue_number: context.issue.number, - repo: context.repo.repo, - body: process.env.LOGS - }) +jobs: + gather-deprecations: + name: Gather Deprecation Warnings + environment: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha || github.sha }} + - name: Install devbox + uses: jetify-com/devbox-install-action@v0.13.0 + with: + enable-cache: 'true' + - name: Generate GitHub App Token + id: generate_token + uses: actions/create-github-app-token@v2 + with: + app-id: ${{ secrets.AKO_RELEASER_APP_ID }} + private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + mongodb-atlas-kubernetes + - name: Parse logs from e2e tests + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + devbox run -- 'make tools/scandeprecation/scandeprecation' + LOGS=$(gh run view ${{ context.payload.workflow_run.id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) + echo "LOGS=$LOGS" >> $GITHUB_ENV` + - name: Create comment from data + if: ${{ ! env.LOGS == '' }} + uses: actions/github-script@v7 + with: + github-token: ${{ steps.generate_token.outputs.token }} + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + issue_number: context.issue.number, + repo: context.repo.repo, + body: process.env.LOGS + }) From 3dcc0c407a6ba4169bfbe08d4db77c96bb8711fd Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Sun, 24 Aug 2025 16:19:15 +0100 Subject: [PATCH 11/11] fix getting workflow id --- .github/workflows/gather-deprecations.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gather-deprecations.yml b/.github/workflows/gather-deprecations.yml index 0b2b783e28..b564d8498b 100644 --- a/.github/workflows/gather-deprecations.yml +++ b/.github/workflows/gather-deprecations.yml @@ -33,7 +33,7 @@ jobs: GH_TOKEN: ${{ steps.generate_token.outputs.token }} run: | devbox run -- 'make tools/scandeprecation/scandeprecation' - LOGS=$(gh run view ${{ context.payload.workflow_run.id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) + LOGS=$(gh run view ${{ github.event.workflow_run.id }} --log | grep "javaMethod" | ./tools/scandeprecation/scandeprecations) echo "LOGS=$LOGS" >> $GITHUB_ENV` - name: Create comment from data if: ${{ ! env.LOGS == '' }}