From 8cdf51e1885005c44815c95af5b4047c5599bcaf Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Mon, 23 Nov 2026 12:03:51 +0300 Subject: [PATCH 01/20] IGNITE-29145 Report wire format changes on pull requests --- .github/scripts/report-wire-changes.js | 102 +++++++++++ .github/scripts/report-wire-changes.test.js | 170 ++++++++++++++++++ .github/workflows/check-protected-classes.yml | 131 -------------- .github/workflows/commit-check.yml | 3 +- .github/workflows/report-wire-changes.yml | 47 +++++ 5 files changed, 321 insertions(+), 132 deletions(-) create mode 100644 .github/scripts/report-wire-changes.js create mode 100644 .github/scripts/report-wire-changes.test.js delete mode 100644 .github/workflows/check-protected-classes.yml create mode 100644 .github/workflows/report-wire-changes.yml diff --git a/.github/scripts/report-wire-changes.js b/.github/scripts/report-wire-changes.js new file mode 100644 index 0000000000000..0fe614052bbbd --- /dev/null +++ b/.github/scripts/report-wire-changes.js @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +const marker = ''; +const label = 'compatibility'; +const bot = 'github-actions[bot]'; + +function only(items) { + return items.length === 1 ? items[0] : undefined; +} + +function stepResult(job, name) { + return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; +} + +module.exports = async function reportWireChanges({github, context, core}) { + const run = context.payload.workflow_run; + const repo = context.repo; + const {actions, issues, pulls} = github.rest; + const jobs = await github.paginate(actions.listJobsForWorkflowRun, { + ...repo, run_id: run.id, filter: 'all', per_page: 100, + }); + + if (jobs.some(job => job.run_attempt > run.run_attempt)) + return core.info('A newer attempt has started.'); + + // Rerunning failed jobs reuses completed jobs from earlier attempts of the same run. + function latestJob(name) { + const matches = jobs.filter(job => job.name === name); + const attempt = Math.max(...matches.map(job => job.run_attempt)); + + return only(matches.filter(job => job.run_attempt === attempt && job.head_sha === run.head_sha)); + } + + const wire = latestJob('Compare wire format descriptions'); + const java = latestJob('Check java code on JDK 17'); + const upload = stepResult(wire, 'Upload wire diff'); + + if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' + || stepResult(java, 'Check all wire format descriptions are collected') !== 'success' + || !['success', 'skipped'].includes(upload)) + return core.info('The wire comparison or completeness check could not be verified.'); + + // Fork runs can have no associated pull_requests. Read the original PR number and base ref + // recorded by check-wire, then verify them against the live PR before making any changes. + const checkout = only(wire.steps.filter(step => step.conclusion === 'success' + && step.name.startsWith('Check out target commit for PR #'))); + const target = checkout?.name.match(/^Check out target commit for PR #([1-9]\d*) into (.+)$/u); + if (!target || !run.head_repository) + return core.info('Could not identify the PR and its target branch.'); + + const [, number, baseRef] = target; + const issue = {...repo, issue_number: Number(number)}; + const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); + const comment = comments.find(c => c.user?.login === bot && c.body?.startsWith(marker)); + const changed = upload === 'success'; + let lastLabelEvent; + if (!changed) { + const events = await github.paginate(issues.listEvents, {...issue, per_page: 100}); + lastLabelEvent = events.findLast(e => e.label?.name === label && ['labeled', 'unlabeled'].includes(e.event)); + } + + const {data: pr} = await pulls.get({...repo, pull_number: issue.issue_number}); + if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch + || pr.head.sha !== run.head_sha || pr.base.ref !== baseRef) + return core.info('The PR has closed or changed since the comparison.'); + + const labeled = pr.labels.some(l => l.name === label); + if (changed) { + if (!labeled) + await issues.addLabels({...issue, labels: [label]}); + + const url = `${context.serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${run.id}/attempts/${wire.run_attempt}#summary-${wire.id}`; + const body = `${marker}\nWire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; + + if (!comment) + await issues.createComment({...issue, body}); + else if (comment.body !== body) + await issues.updateComment({...repo, comment_id: comment.id, body}); + } + else { + if (labeled && lastLabelEvent?.event === 'labeled' && lastLabelEvent.actor?.login === bot) + await issues.removeLabel({...issue, name: label}); + + if (comment) + await issues.deleteComment({...repo, comment_id: comment.id}); + } +}; diff --git a/.github/scripts/report-wire-changes.test.js b/.github/scripts/report-wire-changes.test.js new file mode 100644 index 0000000000000..9f425afb92e06 --- /dev/null +++ b/.github/scripts/report-wire-changes.test.js @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +const assert = require('node:assert/strict'); +const test = require('node:test'); +const report = require('./report-wire-changes'); + +const bot = {login: 'github-actions[bot]'}; +const reviewer = {login: 'reviewer'}; +const success = name => ({name, conclusion: 'success', status: 'completed'}); + +function fixture() { + const run = {id: 12, run_attempt: 1, head_sha: 'abc', head_branch: 'topic', head_repository: {id: 5}, pull_requests: []}; + const context = {repo: {owner: 'apache', repo: 'ignite'}, serverUrl: 'https://github.com', payload: {workflow_run: run}}; + const pr = {state: 'open', head: {sha: 'abc', ref: 'topic', repo: {id: 5}}, base: {ref: 'master'}, labels: []}; + const complete = success('Check all wire format descriptions are collected'); + const compare = success('Compare descriptions and publish summary'); + const upload = success('Upload wire diff'); + const checkout = success('Check out target commit for PR #42 into master'); + const wire = {id: 21, name: 'Compare wire format descriptions', steps: [checkout, compare, upload], + head_sha: 'abc', run_attempt: 1, conclusion: 'success'}; + const java = {name: 'Check java code on JDK 17', steps: [complete], head_sha: 'abc', run_attempt: 1}; + const jobs = [java, wire]; + const comments = []; + const events = []; + const label = {name: 'compatibility'}; + + function applyLabel(user) { + pr.labels.push(label); + events.push({label, event: 'labeled', actor: user}); + } + + function removeLabel(user) { + pr.labels = []; + events.push({label, event: 'unlabeled', actor: user}); + } + + const issues = { + listComments: () => comments, + listEvents: () => events, + createComment: ({body}) => comments.push({id: 99, user: bot, body}), + updateComment: ({comment_id, body}) => { comments.find(c => c.id === comment_id).body = body; }, + deleteComment: ({comment_id}) => comments.splice(comments.findIndex(c => c.id === comment_id), 1), + addLabels: () => applyLabel(bot), + removeLabel: () => removeLabel(bot), + }; + const actions = {listJobsForWorkflowRun: () => jobs}; + const pulls = {get: ({pull_number}) => { + assert.equal(pull_number, 42); + return {data: pr}; + }}; + const github = {rest: {actions, pulls, issues}, paginate: (method, params) => method(params)}; + const publish = () => report({github, context, core: {info() {}}}); + + return {run, pr, complete, compare, checkout, upload, jobs, wire, java, comments, events, issues, applyLabel, removeLabel, publish}; +} + +test('fork PR: reports a diff, updates the same comment on rerun and cleans up an empty diff', async () => { + const f = fixture(); + await f.publish(); + assert.deepEqual(f.pr.labels, [{name: 'compatibility'}]); + const [comment] = f.comments; + assert.match(comment.body, /actions\/runs\/12\/attempts\/1#summary-21/); + + f.removeLabel(reviewer); + f.run.run_attempt++; + f.jobs.push({...f.wire, id: 22, run_attempt: 2}); + await f.publish(); + assert.equal(f.events.at(-1).actor, bot); + assert.deepEqual(f.comments, [comment]); + assert.match(comment.body, /actions\/runs\/12\/attempts\/2#summary-22/); + + f.upload.conclusion = 'skipped'; + await f.publish(); + assert.deepEqual(f.comments, []); + assert.deepEqual(f.pr.labels, []); +}); + +for (const reapplied of [false, true]) { + test(`preserves a manual label (reapplied: ${reapplied}) and a reviewer's marked comment`, async () => { + const f = fixture(); + const manual = {id: 1, user: reviewer, body: ''}; + f.comments.push(manual); + if (reapplied) { + await f.publish(); + f.removeLabel(reviewer); + } + f.applyLabel(reviewer); + await f.publish(); + assert.equal(f.events.at(-1).actor, reviewer); + f.upload.conclusion = 'skipped'; + await f.publish(); + assert.deepEqual(f.pr.labels, [{name: 'compatibility'}]); + assert.deepEqual(f.comments, [manual]); + }); +} + +test('publishes after the target advances or a later Java step fails', async () => { + const f = fixture(); + f.pr.base.sha = 'new-target-commit'; + f.java.conclusion = 'failure'; + f.run.conclusion = 'failure'; + await f.publish(); + assert.equal(f.comments.length, 1); +}); + +test('adopts the previous reporter comment and preserves its ID', async () => { + const f = fixture(); + f.comments.push({id: 31, user: bot, body: '\nOld report'}); + await f.publish(); + assert.equal(f.comments.length, 1); + assert.equal(f.comments[0].id, 31); + assert.match(f.comments[0].body, /Job Summary/); +}); + +test('recovers when labeling succeeds but posting the comment fails', async () => { + const f = fixture(); + const create = f.issues.createComment; + f.issues.createComment = () => { throw new Error('Request failed'); }; + await assert.rejects(f.publish(), /Request failed/); + f.issues.createComment = create; + await f.publish(); + assert.equal(f.events.length, 1); + assert.equal(f.comments.length, 1); +}); + +const unverified = { + 'failed completeness': f => { f.complete.conclusion = 'failure'; }, + 'skipped completeness': f => { f.complete.conclusion = 'skipped'; }, + 'missing completeness': f => { f.java.steps = []; }, + 'failed wire job': f => { f.wire.conclusion = 'failure'; }, + 'skipped comparison': f => { f.compare.conclusion = 'skipped'; }, + 'cancelled upload': f => { f.upload.conclusion = 'cancelled'; }, + 'missing upload': f => { f.wire.steps.pop(); }, + 'newer PR head': f => { f.pr.head.sha = 'def'; }, + 'different source repository': f => { f.pr.head.repo.id++; }, + 'different source branch': f => { f.pr.head.ref = 'another'; }, + 'retargeted PR': f => { f.pr.base.ref = 'release'; }, + 'closed PR': f => { f.pr.state = 'closed'; }, + 'missing original PR target': f => { f.checkout.name = 'Check out target commit'; }, + 'superseded attempt': f => { f.jobs.push({...f.wire, run_attempt: 2}); }, +}; + +for (const [scenario, change] of Object.entries(unverified)) { + test(`leaves existing report alone: ${scenario}`, async () => { + const f = fixture(); + await f.publish(); + const before = structuredClone(f.comments); + f.upload.conclusion = 'skipped'; + change(f); + await f.publish(); + assert.deepEqual(f.comments, before); + assert.deepEqual(f.pr.labels, [{name: 'compatibility'}]); + assert.equal(f.events.length, 1); + }); +} diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml deleted file mode 100644 index 72edb90498837..0000000000000 --- a/.github/workflows/check-protected-classes.yml +++ /dev/null @@ -1,131 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -name: Protected Classes - -# pull_request_target for the write token needed to comment/label the PR. The fork's changes are -# read through the API as data and never checked out or executed, so no allow-unsafe-pr-checkout and -# no working copy of the PR code on the runner. Do not add a step that builds or runs the PR code. -on: pull_request_target - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} - cancel-in-progress: true - -jobs: - check-protected-classes: - runs-on: ubuntu-latest - name: Rolling Upgrade check - permissions: - issues: write - pull-requests: write - checks: write - steps: - - name: Detect protected class changes and report - uses: actions/github-script@v8 - with: - script: | - const ORDER_USE = '@Order('; - const ORDER_IMPORT = 'import org.apache.ignite.internal.Order;'; - const ORDER_PKG = 'package org.apache.ignite.internal;'; - const MARKER = ''; - const { owner, repo } = context.repo; - const pr = context.payload.pull_request; - const baseSha = pr.base.sha; - const headSha = pr.head.sha; - - // Changed files are read from the API as data; the fork's code is never checked out or executed. - const files = await github.paginate(github.rest.pulls.listFiles, { - owner, repo, pull_number: pr.number, per_page: 100, - }); - - // Reproduce `git diff --no-renames --diff-filter=ADM`: a rename is a delete(old)+add(new) pair. - // A protected class carries the @Order annotation; an added file is defined by the head revision, - // a deleted/modified one by the base. - const revisions = []; - for (const f of files) { - if (f.status === 'added' || f.status === 'copied') - revisions.push([f.filename, headSha]); - else if (f.status === 'removed' || f.status === 'modified' || f.status === 'changed') - revisions.push([f.filename, baseSha]); - else if (f.status === 'renamed') { - revisions.push([f.previous_filename, baseSha]); - revisions.push([f.filename, headSha]); - } - } - - const isProtected = async (path, ref) => { - let meta; - try { - ({ data: meta } = await github.rest.repos.getContent({ owner, repo, path, ref })); - } catch (e) { - if (e.status === 404) return false; - throw e; - } - if (Array.isArray(meta) || meta.type !== 'file') return false; - let content = meta.content ? Buffer.from(meta.content, 'base64').toString('utf8') : ''; - if (!content && meta.sha) { - const { data: blob } = await github.rest.git.getBlob({ owner, repo, file_sha: meta.sha }); - content = Buffer.from(blob.content, blob.encoding).toString('utf8'); - } - const lines = content.split(/\r?\n/); - - return content.includes(ORDER_USE) - && (lines.includes(ORDER_IMPORT) || lines.includes(ORDER_PKG)); - }; - - const hits = []; - for (const [path, ref] of revisions) { - if (path.endsWith('.java') - && !path.startsWith('modules/core/src/test/resources/codegen/') - && await isProtected(path, ref)) hits.push(path); - } - - if (hits.length === 0) return; - - // File names come from the fork; render them as inert inline code so they cannot inject - // markdown (backticks, @mentions, links) into content posted under the bot's write token. - const safe = f => '`' + String(f).replace(/[`\r\n]/g, '') + '`'; - const list = hits.map(f => '- ' + safe(f)).join('\n'); - const summary = [ - 'This PR modifies protected classes (with **Order** annotation).', - 'Changes to these classes can break rolling upgrade compatibility.', - '', - '**Affected files:**', - list, - ].join('\n'); - const body = MARKER + '\n## Possible compatibility issues. Please, check rolling upgrade cases\n\n' + summary + '\n'; - - const comments = await github.paginate(github.rest.issues.listComments, { - owner, repo, issue_number: pr.number, - }); - const existing = comments.find(c => c.body.includes(MARKER)); - if (existing) { - await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id }); - } - await github.rest.issues.createComment({ owner, repo, issue_number: pr.number, body }); - - await github.rest.issues.addLabels({ - owner, repo, issue_number: pr.number, labels: ['compatibility'], - }); - - await github.rest.checks.create({ - owner, repo, - name: 'Rolling upgrade compatibility', - head_sha: headSha, - status: 'completed', - conclusion: 'neutral', - output: { title: 'Possible compatibility issues', summary }, - }); diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 3bb987f9208ef..b75042800dacd 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -157,7 +157,8 @@ jobs: path: merge fetch-depth: 2 persist-credentials: false - - name: Check out target commit + # workflow_run.pull_requests can be empty for forks. Preserve the PR and target in the job metadata. + - name: 'Check out target commit for PR #${{ github.event.pull_request.number }} into ${{ github.base_ref }}' run: git -C merge worktree add ../base HEAD^1 - uses: actions/setup-java@v4 with: diff --git a/.github/workflows/report-wire-changes.yml b/.github/workflows/report-wire-changes.yml new file mode 100644 index 0000000000000..505c870652883 --- /dev/null +++ b/.github/workflows/report-wire-changes.yml @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +name: Report wire format changes + +on: + workflow_run: + workflows: ['Code Style, Abandoned Tests, Javadocs'] + types: [completed] + +permissions: {} + +jobs: + report: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.path == '.github/workflows/commit-check.yml' + runs-on: ubuntu-latest + concurrency: + group: wire-report-${{ github.event.workflow_run.head_repository.id }}-${{ github.event.workflow_run.head_branch }} + queue: max + permissions: + actions: read + contents: read + pull-requests: write + steps: + # On workflow_run, github.sha is a commit from the default branch. + - uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + persist-credentials: false + sparse-checkout: .github/scripts + + - uses: actions/github-script@v8 + with: + script: | + await require('./.github/scripts/report-wire-changes.js')({github, context, core}); From 5f200be45bd9b6a7d7651ea0f0f2ad97a4d44ac8 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Mon, 23 Nov 2026 14:48:17 +0300 Subject: [PATCH 02/20] IGNITE-29145 Remove standalone reporter tests --- .github/scripts/report-wire-changes.test.js | 170 -------------------- 1 file changed, 170 deletions(-) delete mode 100644 .github/scripts/report-wire-changes.test.js diff --git a/.github/scripts/report-wire-changes.test.js b/.github/scripts/report-wire-changes.test.js deleted file mode 100644 index 9f425afb92e06..0000000000000 --- a/.github/scripts/report-wire-changes.test.js +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -const assert = require('node:assert/strict'); -const test = require('node:test'); -const report = require('./report-wire-changes'); - -const bot = {login: 'github-actions[bot]'}; -const reviewer = {login: 'reviewer'}; -const success = name => ({name, conclusion: 'success', status: 'completed'}); - -function fixture() { - const run = {id: 12, run_attempt: 1, head_sha: 'abc', head_branch: 'topic', head_repository: {id: 5}, pull_requests: []}; - const context = {repo: {owner: 'apache', repo: 'ignite'}, serverUrl: 'https://github.com', payload: {workflow_run: run}}; - const pr = {state: 'open', head: {sha: 'abc', ref: 'topic', repo: {id: 5}}, base: {ref: 'master'}, labels: []}; - const complete = success('Check all wire format descriptions are collected'); - const compare = success('Compare descriptions and publish summary'); - const upload = success('Upload wire diff'); - const checkout = success('Check out target commit for PR #42 into master'); - const wire = {id: 21, name: 'Compare wire format descriptions', steps: [checkout, compare, upload], - head_sha: 'abc', run_attempt: 1, conclusion: 'success'}; - const java = {name: 'Check java code on JDK 17', steps: [complete], head_sha: 'abc', run_attempt: 1}; - const jobs = [java, wire]; - const comments = []; - const events = []; - const label = {name: 'compatibility'}; - - function applyLabel(user) { - pr.labels.push(label); - events.push({label, event: 'labeled', actor: user}); - } - - function removeLabel(user) { - pr.labels = []; - events.push({label, event: 'unlabeled', actor: user}); - } - - const issues = { - listComments: () => comments, - listEvents: () => events, - createComment: ({body}) => comments.push({id: 99, user: bot, body}), - updateComment: ({comment_id, body}) => { comments.find(c => c.id === comment_id).body = body; }, - deleteComment: ({comment_id}) => comments.splice(comments.findIndex(c => c.id === comment_id), 1), - addLabels: () => applyLabel(bot), - removeLabel: () => removeLabel(bot), - }; - const actions = {listJobsForWorkflowRun: () => jobs}; - const pulls = {get: ({pull_number}) => { - assert.equal(pull_number, 42); - return {data: pr}; - }}; - const github = {rest: {actions, pulls, issues}, paginate: (method, params) => method(params)}; - const publish = () => report({github, context, core: {info() {}}}); - - return {run, pr, complete, compare, checkout, upload, jobs, wire, java, comments, events, issues, applyLabel, removeLabel, publish}; -} - -test('fork PR: reports a diff, updates the same comment on rerun and cleans up an empty diff', async () => { - const f = fixture(); - await f.publish(); - assert.deepEqual(f.pr.labels, [{name: 'compatibility'}]); - const [comment] = f.comments; - assert.match(comment.body, /actions\/runs\/12\/attempts\/1#summary-21/); - - f.removeLabel(reviewer); - f.run.run_attempt++; - f.jobs.push({...f.wire, id: 22, run_attempt: 2}); - await f.publish(); - assert.equal(f.events.at(-1).actor, bot); - assert.deepEqual(f.comments, [comment]); - assert.match(comment.body, /actions\/runs\/12\/attempts\/2#summary-22/); - - f.upload.conclusion = 'skipped'; - await f.publish(); - assert.deepEqual(f.comments, []); - assert.deepEqual(f.pr.labels, []); -}); - -for (const reapplied of [false, true]) { - test(`preserves a manual label (reapplied: ${reapplied}) and a reviewer's marked comment`, async () => { - const f = fixture(); - const manual = {id: 1, user: reviewer, body: ''}; - f.comments.push(manual); - if (reapplied) { - await f.publish(); - f.removeLabel(reviewer); - } - f.applyLabel(reviewer); - await f.publish(); - assert.equal(f.events.at(-1).actor, reviewer); - f.upload.conclusion = 'skipped'; - await f.publish(); - assert.deepEqual(f.pr.labels, [{name: 'compatibility'}]); - assert.deepEqual(f.comments, [manual]); - }); -} - -test('publishes after the target advances or a later Java step fails', async () => { - const f = fixture(); - f.pr.base.sha = 'new-target-commit'; - f.java.conclusion = 'failure'; - f.run.conclusion = 'failure'; - await f.publish(); - assert.equal(f.comments.length, 1); -}); - -test('adopts the previous reporter comment and preserves its ID', async () => { - const f = fixture(); - f.comments.push({id: 31, user: bot, body: '\nOld report'}); - await f.publish(); - assert.equal(f.comments.length, 1); - assert.equal(f.comments[0].id, 31); - assert.match(f.comments[0].body, /Job Summary/); -}); - -test('recovers when labeling succeeds but posting the comment fails', async () => { - const f = fixture(); - const create = f.issues.createComment; - f.issues.createComment = () => { throw new Error('Request failed'); }; - await assert.rejects(f.publish(), /Request failed/); - f.issues.createComment = create; - await f.publish(); - assert.equal(f.events.length, 1); - assert.equal(f.comments.length, 1); -}); - -const unverified = { - 'failed completeness': f => { f.complete.conclusion = 'failure'; }, - 'skipped completeness': f => { f.complete.conclusion = 'skipped'; }, - 'missing completeness': f => { f.java.steps = []; }, - 'failed wire job': f => { f.wire.conclusion = 'failure'; }, - 'skipped comparison': f => { f.compare.conclusion = 'skipped'; }, - 'cancelled upload': f => { f.upload.conclusion = 'cancelled'; }, - 'missing upload': f => { f.wire.steps.pop(); }, - 'newer PR head': f => { f.pr.head.sha = 'def'; }, - 'different source repository': f => { f.pr.head.repo.id++; }, - 'different source branch': f => { f.pr.head.ref = 'another'; }, - 'retargeted PR': f => { f.pr.base.ref = 'release'; }, - 'closed PR': f => { f.pr.state = 'closed'; }, - 'missing original PR target': f => { f.checkout.name = 'Check out target commit'; }, - 'superseded attempt': f => { f.jobs.push({...f.wire, run_attempt: 2}); }, -}; - -for (const [scenario, change] of Object.entries(unverified)) { - test(`leaves existing report alone: ${scenario}`, async () => { - const f = fixture(); - await f.publish(); - const before = structuredClone(f.comments); - f.upload.conclusion = 'skipped'; - change(f); - await f.publish(); - assert.deepEqual(f.comments, before); - assert.deepEqual(f.pr.labels, [{name: 'compatibility'}]); - assert.equal(f.events.length, 1); - }); -} From 3879592c89b71bb0ed49866f0fb93aeb11a9919c Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Mon, 23 Nov 2026 14:54:04 +0300 Subject: [PATCH 03/20] IGNITE-29145 Simplify wire report publishing --- .github/scripts/report-wire-changes.js | 50 ++++++++++---------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/.github/scripts/report-wire-changes.js b/.github/scripts/report-wire-changes.js index 0fe614052bbbd..33703eede3e6d 100644 --- a/.github/scripts/report-wire-changes.js +++ b/.github/scripts/report-wire-changes.js @@ -32,22 +32,15 @@ module.exports = async function reportWireChanges({github, context, core}) { const repo = context.repo; const {actions, issues, pulls} = github.rest; const jobs = await github.paginate(actions.listJobsForWorkflowRun, { - ...repo, run_id: run.id, filter: 'all', per_page: 100, + ...repo, run_id: run.id, filter: 'latest', per_page: 100, }); if (jobs.some(job => job.run_attempt > run.run_attempt)) return core.info('A newer attempt has started.'); - // Rerunning failed jobs reuses completed jobs from earlier attempts of the same run. - function latestJob(name) { - const matches = jobs.filter(job => job.name === name); - const attempt = Math.max(...matches.map(job => job.run_attempt)); - - return only(matches.filter(job => job.run_attempt === attempt && job.head_sha === run.head_sha)); - } - - const wire = latestJob('Compare wire format descriptions'); - const java = latestJob('Check java code on JDK 17'); + const headJobs = jobs.filter(job => job.head_sha === run.head_sha); + const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); + const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); const upload = stepResult(wire, 'Upload wire diff'); if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' @@ -67,12 +60,7 @@ module.exports = async function reportWireChanges({github, context, core}) { const issue = {...repo, issue_number: Number(number)}; const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); const comment = comments.find(c => c.user?.login === bot && c.body?.startsWith(marker)); - const changed = upload === 'success'; - let lastLabelEvent; - if (!changed) { - const events = await github.paginate(issues.listEvents, {...issue, per_page: 100}); - lastLabelEvent = events.findLast(e => e.label?.name === label && ['labeled', 'unlabeled'].includes(e.event)); - } + const events = upload === 'skipped' ? await github.paginate(issues.listEvents, {...issue, per_page: 100}) : []; const {data: pr} = await pulls.get({...repo, pull_number: issue.issue_number}); if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch @@ -80,23 +68,23 @@ module.exports = async function reportWireChanges({github, context, core}) { return core.info('The PR has closed or changed since the comparison.'); const labeled = pr.labels.some(l => l.name === label); - if (changed) { - if (!labeled) - await issues.addLabels({...issue, labels: [label]}); - - const url = `${context.serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${run.id}/attempts/${wire.run_attempt}#summary-${wire.id}`; - const body = `${marker}\nWire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; - - if (!comment) - await issues.createComment({...issue, body}); - else if (comment.body !== body) - await issues.updateComment({...repo, comment_id: comment.id, body}); - } - else { - if (labeled && lastLabelEvent?.event === 'labeled' && lastLabelEvent.actor?.login === bot) + if (upload === 'skipped') { + const last = events.findLast(e => e.label?.name === label && ['labeled', 'unlabeled'].includes(e.event)); + if (labeled && last?.event === 'labeled' && last.actor?.login === bot) await issues.removeLabel({...issue, name: label}); if (comment) await issues.deleteComment({...repo, comment_id: comment.id}); + return; } + + if (!labeled) + await issues.addLabels({...issue, labels: [label]}); + + const url = `${context.serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${run.id}/attempts/${wire.run_attempt}#summary-${wire.id}`; + const body = `${marker}\nWire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; + if (!comment) + await issues.createComment({...issue, body}); + else if (comment.body !== body) + await issues.updateComment({...repo, comment_id: comment.id, body}); }; From 829f9636ac1b8fb9acb935368c0bd1799edc24de Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 12:32:27 +0300 Subject: [PATCH 04/20] IGNITE-29145 Label protected Java changes before wire comparison completes --- .github/workflows/check-protected-classes.yml | 131 ++++++++++++++++++ .github/workflows/report-wire-changes.yml | 47 ------- 2 files changed, 131 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/check-protected-classes.yml delete mode 100644 .github/workflows/report-wire-changes.yml diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml new file mode 100644 index 0000000000000..746d6afe4a62a --- /dev/null +++ b/.github/workflows/check-protected-classes.yml @@ -0,0 +1,131 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +name: Protected Classes + +on: + workflow_run: + workflows: ['Code Style, Abandoned Tests, Javadocs'] + types: [requested, completed] + +permissions: {} + +jobs: + report: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.path == '.github/workflows/commit-check.yml' + runs-on: ubuntu-latest + concurrency: + # Serialize the preliminary label and the final comparison result. + group: wire-report-${{ github.event.workflow_run.head_repository.id }}-${{ github.event.workflow_run.head_branch }} + queue: max + permissions: + actions: read + contents: read + pull-requests: write + steps: + - name: Label changes to protected Java classes + if: github.event.action == 'requested' + uses: actions/github-script@v8 + with: + script: | + const ORDER_USE = '@Order('; + const ORDER_IMPORT = 'import org.apache.ignite.internal.Order;'; + const ORDER_PKG = 'package org.apache.ignite.internal;'; + const {owner, repo} = context.repo; + const run = context.payload.workflow_run; + if (!run.head_repository) return; + + // A delayed requested event can enter the concurrency group after the final report. + const {data: latest} = await github.rest.actions.getWorkflowRun({owner, repo, run_id: run.id}); + if (latest.status === 'completed' || latest.run_attempt !== run.run_attempt) return; + + // Fork runs may omit pull_requests. Only label an unambiguous open PR for this head. + const head = `${run.head_repository.owner.login}:${run.head_branch}`; + const open = await github.paginate(github.rest.pulls.list, {owner, repo, state: 'open', head, per_page: 100}); + const matches = open.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.head.sha === run.head_sha + && (!run.pull_requests?.length || run.pull_requests.some(p => p.number === pr.number && p.base.ref === pr.base.ref))); + if (matches.length !== 1) return; + + const [pr] = matches; + if (pr.labels.some(l => l.name === 'compatibility')) return; + const baseSha = pr.base.sha; + const headSha = pr.head.sha; + + // Changed files are read from the API as data; the fork's code is never checked out or executed. + const files = await github.paginate(github.rest.pulls.listFiles, { + owner, repo, pull_number: pr.number, per_page: 100, + }); + + // Reproduce `git diff --no-renames --diff-filter=ADM`: a rename is a delete(old)+add(new) pair. + // A protected class carries the @Order annotation; an added file is defined by the head revision, + // a deleted/modified one by the base. + const revisions = []; + for (const f of files) { + if (f.status === 'added' || f.status === 'copied') + revisions.push([f.filename, headSha]); + else if (f.status === 'removed' || f.status === 'modified' || f.status === 'changed') + revisions.push([f.filename, baseSha]); + else if (f.status === 'renamed') { + revisions.push([f.previous_filename, baseSha]); + revisions.push([f.filename, headSha]); + } + } + + const isProtected = async (path, ref) => { + let meta; + try { + ({ data: meta } = await github.rest.repos.getContent({ owner, repo, path, ref })); + } catch (e) { + if (e.status === 404) return false; + throw e; + } + if (Array.isArray(meta) || meta.type !== 'file') return false; + let content = meta.content ? Buffer.from(meta.content, 'base64').toString('utf8') : ''; + if (!content && meta.sha) { + const { data: blob } = await github.rest.git.getBlob({ owner, repo, file_sha: meta.sha }); + content = Buffer.from(blob.content, blob.encoding).toString('utf8'); + } + const lines = content.split(/\r?\n/); + + return content.includes(ORDER_USE) + && (lines.includes(ORDER_IMPORT) || lines.includes(ORDER_PKG)); + }; + + for (const [path, ref] of revisions) { + if (!path.endsWith('.java') || path.startsWith('modules/core/src/test/resources/codegen/') + || !await isProtected(path, ref)) continue; + + const {data: current} = await github.rest.pulls.get({owner, repo, pull_number: pr.number}); + if (current.state === 'open' && current.head.repo?.id === run.head_repository.id + && current.head.ref === run.head_branch && current.head.sha === headSha && current.base.ref === pr.base.ref + && !current.labels.some(l => l.name === 'compatibility')) + await github.rest.issues.addLabels({owner, repo, issue_number: pr.number, labels: ['compatibility']}); + return; + } + + # On workflow_run, github.sha is a commit from the default branch. + - uses: actions/checkout@v4 + if: github.event.action == 'completed' + with: + ref: ${{ github.sha }} + persist-credentials: false + sparse-checkout: .github/scripts + + - name: Report the wire comparison + if: github.event.action == 'completed' + uses: actions/github-script@v8 + with: + script: | + await require('./.github/scripts/report-wire-changes.js')({github, context, core}); diff --git a/.github/workflows/report-wire-changes.yml b/.github/workflows/report-wire-changes.yml deleted file mode 100644 index 505c870652883..0000000000000 --- a/.github/workflows/report-wire-changes.yml +++ /dev/null @@ -1,47 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -name: Report wire format changes - -on: - workflow_run: - workflows: ['Code Style, Abandoned Tests, Javadocs'] - types: [completed] - -permissions: {} - -jobs: - report: - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.path == '.github/workflows/commit-check.yml' - runs-on: ubuntu-latest - concurrency: - group: wire-report-${{ github.event.workflow_run.head_repository.id }}-${{ github.event.workflow_run.head_branch }} - queue: max - permissions: - actions: read - contents: read - pull-requests: write - steps: - # On workflow_run, github.sha is a commit from the default branch. - - uses: actions/checkout@v4 - with: - ref: ${{ github.sha }} - persist-credentials: false - sparse-checkout: .github/scripts - - - uses: actions/github-script@v8 - with: - script: | - await require('./.github/scripts/report-wire-changes.js')({github, context, core}); From ad991a487c2e537e8063e2eb647479c77eec96d7 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 12:35:37 +0300 Subject: [PATCH 05/20] IGNITE-29145 Clear the compatibility label whenever the wire diff is empty --- .github/scripts/report-wire-changes.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/scripts/report-wire-changes.js b/.github/scripts/report-wire-changes.js index 33703eede3e6d..630319729db8b 100644 --- a/.github/scripts/report-wire-changes.js +++ b/.github/scripts/report-wire-changes.js @@ -60,7 +60,6 @@ module.exports = async function reportWireChanges({github, context, core}) { const issue = {...repo, issue_number: Number(number)}; const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); const comment = comments.find(c => c.user?.login === bot && c.body?.startsWith(marker)); - const events = upload === 'skipped' ? await github.paginate(issues.listEvents, {...issue, per_page: 100}) : []; const {data: pr} = await pulls.get({...repo, pull_number: issue.issue_number}); if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch @@ -69,8 +68,7 @@ module.exports = async function reportWireChanges({github, context, core}) { const labeled = pr.labels.some(l => l.name === label); if (upload === 'skipped') { - const last = events.findLast(e => e.label?.name === label && ['labeled', 'unlabeled'].includes(e.event)); - if (labeled && last?.event === 'labeled' && last.actor?.login === bot) + if (labeled) await issues.removeLabel({...issue, name: label}); if (comment) From ef20db5e7f746a0545a8f7b4262ea48ea1455b7a Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 12:38:41 +0300 Subject: [PATCH 06/20] IGNITE-29145 Publish the wire report directly from the workflow --- .github/scripts/report-wire-changes.js | 88 ------------------- .github/workflows/check-protected-classes.yml | 78 ++++++++++++++-- 2 files changed, 69 insertions(+), 97 deletions(-) delete mode 100644 .github/scripts/report-wire-changes.js diff --git a/.github/scripts/report-wire-changes.js b/.github/scripts/report-wire-changes.js deleted file mode 100644 index 630319729db8b..0000000000000 --- a/.github/scripts/report-wire-changes.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -const marker = ''; -const label = 'compatibility'; -const bot = 'github-actions[bot]'; - -function only(items) { - return items.length === 1 ? items[0] : undefined; -} - -function stepResult(job, name) { - return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; -} - -module.exports = async function reportWireChanges({github, context, core}) { - const run = context.payload.workflow_run; - const repo = context.repo; - const {actions, issues, pulls} = github.rest; - const jobs = await github.paginate(actions.listJobsForWorkflowRun, { - ...repo, run_id: run.id, filter: 'latest', per_page: 100, - }); - - if (jobs.some(job => job.run_attempt > run.run_attempt)) - return core.info('A newer attempt has started.'); - - const headJobs = jobs.filter(job => job.head_sha === run.head_sha); - const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); - const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); - const upload = stepResult(wire, 'Upload wire diff'); - - if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' - || stepResult(java, 'Check all wire format descriptions are collected') !== 'success' - || !['success', 'skipped'].includes(upload)) - return core.info('The wire comparison or completeness check could not be verified.'); - - // Fork runs can have no associated pull_requests. Read the original PR number and base ref - // recorded by check-wire, then verify them against the live PR before making any changes. - const checkout = only(wire.steps.filter(step => step.conclusion === 'success' - && step.name.startsWith('Check out target commit for PR #'))); - const target = checkout?.name.match(/^Check out target commit for PR #([1-9]\d*) into (.+)$/u); - if (!target || !run.head_repository) - return core.info('Could not identify the PR and its target branch.'); - - const [, number, baseRef] = target; - const issue = {...repo, issue_number: Number(number)}; - const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); - const comment = comments.find(c => c.user?.login === bot && c.body?.startsWith(marker)); - - const {data: pr} = await pulls.get({...repo, pull_number: issue.issue_number}); - if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch - || pr.head.sha !== run.head_sha || pr.base.ref !== baseRef) - return core.info('The PR has closed or changed since the comparison.'); - - const labeled = pr.labels.some(l => l.name === label); - if (upload === 'skipped') { - if (labeled) - await issues.removeLabel({...issue, name: label}); - - if (comment) - await issues.deleteComment({...repo, comment_id: comment.id}); - return; - } - - if (!labeled) - await issues.addLabels({...issue, labels: [label]}); - - const url = `${context.serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${run.id}/attempts/${wire.run_attempt}#summary-${wire.id}`; - const body = `${marker}\nWire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; - if (!comment) - await issues.createComment({...issue, body}); - else if (comment.body !== body) - await issues.updateComment({...repo, comment_id: comment.id, body}); -}; diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 746d6afe4a62a..2b25c4f59a0c0 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -115,17 +115,77 @@ jobs: return; } - # On workflow_run, github.sha is a commit from the default branch. - - uses: actions/checkout@v4 - if: github.event.action == 'completed' - with: - ref: ${{ github.sha }} - persist-credentials: false - sparse-checkout: .github/scripts - - name: Report the wire comparison if: github.event.action == 'completed' uses: actions/github-script@v8 with: script: | - await require('./.github/scripts/report-wire-changes.js')({github, context, core}); + const marker = ''; + const label = 'compatibility'; + + function only(items) { + return items.length === 1 ? items[0] : undefined; + } + + function stepResult(job, name) { + return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; + } + + const run = context.payload.workflow_run; + const repo = context.repo; + const {actions, issues, pulls} = github.rest; + const jobs = await github.paginate(actions.listJobsForWorkflowRun, { + ...repo, run_id: run.id, filter: 'latest', per_page: 100, + }); + + if (jobs.some(job => job.run_attempt > run.run_attempt)) + return core.info('A newer attempt has started.'); + + const headJobs = jobs.filter(job => job.head_sha === run.head_sha); + const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); + const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); + const upload = stepResult(wire, 'Upload wire diff'); + + if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' + || stepResult(java, 'Check all wire format descriptions are collected') !== 'success' + || !['success', 'skipped'].includes(upload)) + return core.info('The wire comparison or completeness check could not be verified.'); + + // Fork runs can have no associated pull_requests. Read the original PR number and base ref + // recorded by check-wire, then verify them against the live PR before making any changes. + const checkout = only(wire.steps.filter(step => step.conclusion === 'success' + && step.name.startsWith('Check out target commit for PR #'))); + const target = checkout?.name.match(/^Check out target commit for PR #([1-9]\d*) into (.+)$/u); + if (!target || !run.head_repository) + return core.info('Could not identify the PR and its target branch.'); + + const [, number, baseRef] = target; + const pullNumber = Number(number); + const issue = {...repo, issue_number: pullNumber}; + const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); + const comment = comments.find(c => c.user?.login === 'github-actions[bot]' && c.body?.startsWith(marker)); + + const {data: pr} = await pulls.get({...repo, pull_number: pullNumber}); + if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch + || pr.head.sha !== run.head_sha || pr.base.ref !== baseRef) + return core.info('The PR has closed or changed since the comparison.'); + + const labeled = pr.labels.some(l => l.name === label); + if (upload === 'skipped') { + if (labeled) + await issues.removeLabel({...issue, name: label}); + + if (comment) + await issues.deleteComment({...repo, comment_id: comment.id}); + return; + } + + if (!labeled) + await issues.addLabels({...issue, labels: [label]}); + + const url = `${run.html_url}/attempts/${wire.run_attempt}#summary-${wire.id}`; + const body = `${marker}\nWire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; + if (!comment) + await issues.createComment({...issue, body}); + else if (comment.body !== body) + await issues.updateComment({...repo, comment_id: comment.id, body}); From c46d2bbe3a2a318c811405201babdaf9d3f8bbdf Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 12:40:19 +0300 Subject: [PATCH 07/20] IGNITE-29145 Remove the checkout step comment --- .github/workflows/commit-check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index b75042800dacd..58fb85cd9e968 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -157,7 +157,6 @@ jobs: path: merge fetch-depth: 2 persist-credentials: false - # workflow_run.pull_requests can be empty for forks. Preserve the PR and target in the job metadata. - name: 'Check out target commit for PR #${{ github.event.pull_request.number }} into ${{ github.base_ref }}' run: git -C merge worktree add ../base HEAD^1 - uses: actions/setup-java@v4 From 375712aa11ce65b9d91d615f793ecb3251b34a53 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 12:49:12 +0300 Subject: [PATCH 08/20] IGNITE-29145 Resolve the pull request without parsing a checkout step --- .github/workflows/check-protected-classes.yml | 27 +++++++++++++------ .github/workflows/commit-check.yml | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 2b25c4f59a0c0..313d4359273bb 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -151,16 +151,27 @@ jobs: || !['success', 'skipped'].includes(upload)) return core.info('The wire comparison or completeness check could not be verified.'); - // Fork runs can have no associated pull_requests. Read the original PR number and base ref - // recorded by check-wire, then verify them against the live PR before making any changes. - const checkout = only(wire.steps.filter(step => step.conclusion === 'success' - && step.name.startsWith('Check out target commit for PR #'))); - const target = checkout?.name.match(/^Check out target commit for PR #([1-9]\d*) into (.+)$/u); - if (!target || !run.head_repository) + if (!run.head_repository) return; + let target = only(run.pull_requests ?? []); + if (!run.pull_requests?.length) { + // Fork runs can omit pull_requests. Match the source branch to a single PR open at run creation. + const head = `${run.head_repository.owner.login}:${run.head_branch}`; + const candidates = await github.paginate(pulls.list, {...repo, head, state: 'all', per_page: 100}); + target = only(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id + && pr.created_at <= run.created_at && (!pr.closed_at || pr.closed_at >= run.created_at))); + if (!target || target.state !== 'open' || target.head.sha !== run.head_sha) return; + + const {node} = await github.graphql(`query($id: ID!, $since: DateTime!) { + node(id: $id) { ... on PullRequest { + timelineItems(first: 1, since: $since, itemTypes: [BASE_REF_CHANGED_EVENT]) { nodes { __typename } } + } } + }`, {id: target.node_id, since: run.created_at}); + if (!node || node.timelineItems.nodes.length) return; + } + if (!target) return core.info('Could not identify the PR and its target branch.'); - const [, number, baseRef] = target; - const pullNumber = Number(number); + const {number: pullNumber, base: {ref: baseRef}} = target; const issue = {...repo, issue_number: pullNumber}; const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); const comment = comments.find(c => c.user?.login === 'github-actions[bot]' && c.body?.startsWith(marker)); diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 58fb85cd9e968..3bb987f9208ef 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -157,7 +157,7 @@ jobs: path: merge fetch-depth: 2 persist-credentials: false - - name: 'Check out target commit for PR #${{ github.event.pull_request.number }} into ${{ github.base_ref }}' + - name: Check out target commit run: git -C merge worktree add ../base HEAD^1 - uses: actions/setup-java@v4 with: From 6e4f8d9c7c775689ecb326f888a8b4bfeef81537 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 13:12:49 +0300 Subject: [PATCH 09/20] IGNITE-29145 Remove the preliminary Order label check --- .github/workflows/check-protected-classes.yml | 87 +------------------ 1 file changed, 2 insertions(+), 85 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 313d4359273bb..83756d9fa3b26 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: Protected Classes +name: Wire format report on: workflow_run: workflows: ['Code Style, Abandoned Tests, Javadocs'] - types: [requested, completed] + types: [completed] permissions: {} @@ -27,96 +27,13 @@ jobs: if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.path == '.github/workflows/commit-check.yml' runs-on: ubuntu-latest concurrency: - # Serialize the preliminary label and the final comparison result. group: wire-report-${{ github.event.workflow_run.head_repository.id }}-${{ github.event.workflow_run.head_branch }} queue: max permissions: actions: read - contents: read pull-requests: write steps: - - name: Label changes to protected Java classes - if: github.event.action == 'requested' - uses: actions/github-script@v8 - with: - script: | - const ORDER_USE = '@Order('; - const ORDER_IMPORT = 'import org.apache.ignite.internal.Order;'; - const ORDER_PKG = 'package org.apache.ignite.internal;'; - const {owner, repo} = context.repo; - const run = context.payload.workflow_run; - if (!run.head_repository) return; - - // A delayed requested event can enter the concurrency group after the final report. - const {data: latest} = await github.rest.actions.getWorkflowRun({owner, repo, run_id: run.id}); - if (latest.status === 'completed' || latest.run_attempt !== run.run_attempt) return; - - // Fork runs may omit pull_requests. Only label an unambiguous open PR for this head. - const head = `${run.head_repository.owner.login}:${run.head_branch}`; - const open = await github.paginate(github.rest.pulls.list, {owner, repo, state: 'open', head, per_page: 100}); - const matches = open.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.head.sha === run.head_sha - && (!run.pull_requests?.length || run.pull_requests.some(p => p.number === pr.number && p.base.ref === pr.base.ref))); - if (matches.length !== 1) return; - - const [pr] = matches; - if (pr.labels.some(l => l.name === 'compatibility')) return; - const baseSha = pr.base.sha; - const headSha = pr.head.sha; - - // Changed files are read from the API as data; the fork's code is never checked out or executed. - const files = await github.paginate(github.rest.pulls.listFiles, { - owner, repo, pull_number: pr.number, per_page: 100, - }); - - // Reproduce `git diff --no-renames --diff-filter=ADM`: a rename is a delete(old)+add(new) pair. - // A protected class carries the @Order annotation; an added file is defined by the head revision, - // a deleted/modified one by the base. - const revisions = []; - for (const f of files) { - if (f.status === 'added' || f.status === 'copied') - revisions.push([f.filename, headSha]); - else if (f.status === 'removed' || f.status === 'modified' || f.status === 'changed') - revisions.push([f.filename, baseSha]); - else if (f.status === 'renamed') { - revisions.push([f.previous_filename, baseSha]); - revisions.push([f.filename, headSha]); - } - } - - const isProtected = async (path, ref) => { - let meta; - try { - ({ data: meta } = await github.rest.repos.getContent({ owner, repo, path, ref })); - } catch (e) { - if (e.status === 404) return false; - throw e; - } - if (Array.isArray(meta) || meta.type !== 'file') return false; - let content = meta.content ? Buffer.from(meta.content, 'base64').toString('utf8') : ''; - if (!content && meta.sha) { - const { data: blob } = await github.rest.git.getBlob({ owner, repo, file_sha: meta.sha }); - content = Buffer.from(blob.content, blob.encoding).toString('utf8'); - } - const lines = content.split(/\r?\n/); - - return content.includes(ORDER_USE) - && (lines.includes(ORDER_IMPORT) || lines.includes(ORDER_PKG)); - }; - - for (const [path, ref] of revisions) { - if (!path.endsWith('.java') || path.startsWith('modules/core/src/test/resources/codegen/') - || !await isProtected(path, ref)) continue; - - const {data: current} = await github.rest.pulls.get({owner, repo, pull_number: pr.number}); - if (current.state === 'open' && current.head.repo?.id === run.head_repository.id - && current.head.ref === run.head_branch && current.head.sha === headSha && current.base.ref === pr.base.ref - && !current.labels.some(l => l.name === 'compatibility')) - await github.rest.issues.addLabels({owner, repo, issue_number: pr.number, labels: ['compatibility']}); - return; - } - - name: Report the wire comparison - if: github.event.action == 'completed' uses: actions/github-script@v8 with: script: | From 62f60716a74f256a44b37168a144b0e48b2bee9b Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 14:21:39 +0300 Subject: [PATCH 10/20] IGNITE-29145 Preserve newer verified wire reports on reruns --- .github/workflows/check-protected-classes.yml | 73 ++++++++++++++----- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 83756d9fa3b26..e4daeadc5e814 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -51,30 +51,36 @@ jobs: const run = context.payload.workflow_run; const repo = context.repo; const {actions, issues, pulls} = github.rest; - const jobs = await github.paginate(actions.listJobsForWorkflowRun, { - ...repo, run_id: run.id, filter: 'latest', per_page: 100, - }); - if (jobs.some(job => job.run_attempt > run.run_attempt)) - return core.info('A newer attempt has started.'); + function jobsFor(source, filter) { + return github.paginate(actions.listJobsForWorkflowRun, {...repo, run_id: source.id, filter, per_page: 100}); + } - const headJobs = jobs.filter(job => job.head_sha === run.head_sha); - const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); - const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); - const upload = stepResult(wire, 'Upload wire diff'); + function comparison(jobs, attempt) { + // A partial rerun keeps the jobs that were not rerun from earlier attempts. + function latestJob(name) { + const matches = jobs.filter(job => job.name === name && job.head_sha === run.head_sha && job.run_attempt <= attempt); + const latest = Math.max(...matches.map(job => job.run_attempt)); + return only(matches.filter(job => job.run_attempt === latest)); + } + + const wire = latestJob('Compare wire format descriptions'); + const java = latestJob('Check java code on JDK 17'); + const upload = stepResult(wire, 'Upload wire diff'); + if (wire?.conclusion === 'success' && stepResult(wire, 'Compare descriptions and publish summary') === 'success' + && stepResult(java, 'Check all wire format descriptions are collected') === 'success' + && ['success', 'skipped'].includes(upload)) + return {wire, upload}; + } - if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' - || stepResult(java, 'Check all wire format descriptions are collected') !== 'success' - || !['success', 'skipped'].includes(upload)) - return core.info('The wire comparison or completeness check could not be verified.'); + async function targetOf(run) { + if (!run.head_repository) return; + if (run.pull_requests?.length) return only(run.pull_requests); - if (!run.head_repository) return; - let target = only(run.pull_requests ?? []); - if (!run.pull_requests?.length) { // Fork runs can omit pull_requests. Match the source branch to a single PR open at run creation. const head = `${run.head_repository.owner.login}:${run.head_branch}`; const candidates = await github.paginate(pulls.list, {...repo, head, state: 'all', per_page: 100}); - target = only(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id + const target = only(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.created_at <= run.created_at && (!pr.closed_at || pr.closed_at >= run.created_at))); if (!target || target.state !== 'open' || target.head.sha !== run.head_sha) return; @@ -84,11 +90,44 @@ jobs: } } }`, {id: target.node_id, since: run.created_at}); if (!node || node.timelineItems.nodes.length) return; + return target; } + + const jobs = await jobsFor(run, 'latest'); + if (jobs.some(job => job.run_attempt > run.run_attempt)) + return core.info('A newer attempt has started.'); + + const result = comparison(jobs, run.run_attempt); + if (!result) + return core.info('The wire comparison or completeness check could not be verified.'); + + const {wire, upload} = result; + const target = await targetOf(run); if (!target) return core.info('Could not identify the PR and its target branch.'); const {number: pullNumber, base: {ref: baseRef}} = target; + + // An empty report leaves no comment. Check CI history for newer verified results on this PR and base. + const runs = await github.paginate(actions.listWorkflowRuns, { + ...repo, workflow_id: run.workflow_id, event: 'pull_request', branch: run.head_branch, + head_sha: run.head_sha, created: `>=${run.created_at}`, per_page: 100, + }); + for (const newer of runs) { + if (newer.run_number <= run.run_number || newer.head_repository?.id !== run.head_repository.id) continue; + const lastCompletedAttempt = newer.status === 'completed' ? newer.run_attempt : newer.run_attempt - 1; + if (!lastCompletedAttempt) continue; + + const newerTarget = await targetOf(newer); + if (newerTarget?.number !== pullNumber || newerTarget.base.ref !== baseRef) continue; + + const history = await jobsFor(newer, 'all'); + for (let attempt = lastCompletedAttempt; attempt >= 1; attempt--) { + if (comparison(history, attempt)) + return core.info(`Newer run ${newer.id} already has a verified wire comparison.`); + } + } + const issue = {...repo, issue_number: pullNumber}; const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); const comment = comments.find(c => c.user?.login === 'github-actions[bot]' && c.body?.startsWith(marker)); From e0a5fcb60b34d014cf03da14a8ca09a02d47e868 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 14:52:49 +0300 Subject: [PATCH 11/20] IGNITE-29145 Simplify the wire reporter and its PR condition --- .github/workflows/check-protected-classes.yml | 48 ++++++++----------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index e4daeadc5e814..bd26d06c48587 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -24,7 +24,7 @@ permissions: {} jobs: report: - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.path == '.github/workflows/commit-check.yml' + if: github.event.workflow_run.event == 'pull_request' runs-on: ubuntu-latest concurrency: group: wire-report-${{ github.event.workflow_run.head_repository.id }}-${{ github.event.workflow_run.head_branch }} @@ -40,20 +40,14 @@ jobs: const marker = ''; const label = 'compatibility'; - function only(items) { - return items.length === 1 ? items[0] : undefined; - } - - function stepResult(job, name) { - return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; - } - const run = context.payload.workflow_run; const repo = context.repo; const {actions, issues, pulls} = github.rest; + const only = items => items.length === 1 ? items[0] : undefined; + const list = (method, params) => github.paginate(method, {...repo, ...params, per_page: 100}); - function jobsFor(source, filter) { - return github.paginate(actions.listJobsForWorkflowRun, {...repo, run_id: source.id, filter, per_page: 100}); + function stepResult(job, name) { + return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; } function comparison(jobs, attempt) { @@ -79,7 +73,7 @@ jobs: // Fork runs can omit pull_requests. Match the source branch to a single PR open at run creation. const head = `${run.head_repository.owner.login}:${run.head_branch}`; - const candidates = await github.paginate(pulls.list, {...repo, head, state: 'all', per_page: 100}); + const candidates = await list(pulls.list, {head, state: 'all'}); const target = only(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.created_at <= run.created_at && (!pr.closed_at || pr.closed_at >= run.created_at))); if (!target || target.state !== 'open' || target.head.sha !== run.head_sha) return; @@ -89,29 +83,25 @@ jobs: timelineItems(first: 1, since: $since, itemTypes: [BASE_REF_CHANGED_EVENT]) { nodes { __typename } } } } }`, {id: target.node_id, since: run.created_at}); - if (!node || node.timelineItems.nodes.length) return; - return target; + if (node?.timelineItems.nodes.length === 0) return target; } - const jobs = await jobsFor(run, 'latest'); + const jobs = await list(actions.listJobsForWorkflowRun, {run_id: run.id, filter: 'latest'}); if (jobs.some(job => job.run_attempt > run.run_attempt)) return core.info('A newer attempt has started.'); - const result = comparison(jobs, run.run_attempt); - if (!result) + const {wire, upload} = comparison(jobs, run.run_attempt) ?? {}; + if (!wire) return core.info('The wire comparison or completeness check could not be verified.'); - const {wire, upload} = result; const target = await targetOf(run); if (!target) return core.info('Could not identify the PR and its target branch.'); - const {number: pullNumber, base: {ref: baseRef}} = target; - // An empty report leaves no comment. Check CI history for newer verified results on this PR and base. - const runs = await github.paginate(actions.listWorkflowRuns, { - ...repo, workflow_id: run.workflow_id, event: 'pull_request', branch: run.head_branch, - head_sha: run.head_sha, created: `>=${run.created_at}`, per_page: 100, + const runs = await list(actions.listWorkflowRuns, { + workflow_id: run.workflow_id, event: 'pull_request', branch: run.head_branch, + head_sha: run.head_sha, created: `>=${run.created_at}`, }); for (const newer of runs) { if (newer.run_number <= run.run_number || newer.head_repository?.id !== run.head_repository.id) continue; @@ -119,22 +109,22 @@ jobs: if (!lastCompletedAttempt) continue; const newerTarget = await targetOf(newer); - if (newerTarget?.number !== pullNumber || newerTarget.base.ref !== baseRef) continue; + if (newerTarget?.number !== target.number || newerTarget.base.ref !== target.base.ref) continue; - const history = await jobsFor(newer, 'all'); + const history = await list(actions.listJobsForWorkflowRun, {run_id: newer.id, filter: 'all'}); for (let attempt = lastCompletedAttempt; attempt >= 1; attempt--) { if (comparison(history, attempt)) return core.info(`Newer run ${newer.id} already has a verified wire comparison.`); } } - const issue = {...repo, issue_number: pullNumber}; - const comments = await github.paginate(issues.listComments, {...issue, per_page: 100}); + const issue = {...repo, issue_number: target.number}; + const comments = await list(issues.listComments, issue); const comment = comments.find(c => c.user?.login === 'github-actions[bot]' && c.body?.startsWith(marker)); - const {data: pr} = await pulls.get({...repo, pull_number: pullNumber}); + const {data: pr} = await pulls.get({...repo, pull_number: target.number}); if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch - || pr.head.sha !== run.head_sha || pr.base.ref !== baseRef) + || pr.head.sha !== run.head_sha || pr.base.ref !== target.base.ref) return core.info('The PR has closed or changed since the comparison.'); const labeled = pr.labels.some(l => l.name === label); From a376d9212185b00e170a5dcf20f63f52df634528 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:00:36 +0300 Subject: [PATCH 12/20] IGNITE-29145 Report the current wire comparison without scanning CI history --- .github/workflows/check-protected-classes.yml | 46 +++---------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index bd26d06c48587..bed85d61fbd7f 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -50,23 +50,6 @@ jobs: return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; } - function comparison(jobs, attempt) { - // A partial rerun keeps the jobs that were not rerun from earlier attempts. - function latestJob(name) { - const matches = jobs.filter(job => job.name === name && job.head_sha === run.head_sha && job.run_attempt <= attempt); - const latest = Math.max(...matches.map(job => job.run_attempt)); - return only(matches.filter(job => job.run_attempt === latest)); - } - - const wire = latestJob('Compare wire format descriptions'); - const java = latestJob('Check java code on JDK 17'); - const upload = stepResult(wire, 'Upload wire diff'); - if (wire?.conclusion === 'success' && stepResult(wire, 'Compare descriptions and publish summary') === 'success' - && stepResult(java, 'Check all wire format descriptions are collected') === 'success' - && ['success', 'skipped'].includes(upload)) - return {wire, upload}; - } - async function targetOf(run) { if (!run.head_repository) return; if (run.pull_requests?.length) return only(run.pull_requests); @@ -90,34 +73,19 @@ jobs: if (jobs.some(job => job.run_attempt > run.run_attempt)) return core.info('A newer attempt has started.'); - const {wire, upload} = comparison(jobs, run.run_attempt) ?? {}; - if (!wire) + const headJobs = jobs.filter(job => job.head_sha === run.head_sha); + const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); + const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); + const upload = stepResult(wire, 'Upload wire diff'); + if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' + || stepResult(java, 'Check all wire format descriptions are collected') !== 'success' + || !['success', 'skipped'].includes(upload)) return core.info('The wire comparison or completeness check could not be verified.'); const target = await targetOf(run); if (!target) return core.info('Could not identify the PR and its target branch.'); - // An empty report leaves no comment. Check CI history for newer verified results on this PR and base. - const runs = await list(actions.listWorkflowRuns, { - workflow_id: run.workflow_id, event: 'pull_request', branch: run.head_branch, - head_sha: run.head_sha, created: `>=${run.created_at}`, - }); - for (const newer of runs) { - if (newer.run_number <= run.run_number || newer.head_repository?.id !== run.head_repository.id) continue; - const lastCompletedAttempt = newer.status === 'completed' ? newer.run_attempt : newer.run_attempt - 1; - if (!lastCompletedAttempt) continue; - - const newerTarget = await targetOf(newer); - if (newerTarget?.number !== target.number || newerTarget.base.ref !== target.base.ref) continue; - - const history = await list(actions.listJobsForWorkflowRun, {run_id: newer.id, filter: 'all'}); - for (let attempt = lastCompletedAttempt; attempt >= 1; attempt--) { - if (comparison(history, attempt)) - return core.info(`Newer run ${newer.id} already has a verified wire comparison.`); - } - } - const issue = {...repo, issue_number: target.number}; const comments = await list(issues.listComments, issue); const comment = comments.find(c => c.user?.login === 'github-actions[bot]' && c.body?.startsWith(marker)); From 0a3e325d33e42fa85eb0128e06baf4d6e1e43071 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:05:42 +0300 Subject: [PATCH 13/20] IGNITE-29145 Post a new comment for each wire diff --- .github/workflows/check-protected-classes.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index bed85d61fbd7f..1de5fb0e9a7d1 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -37,7 +37,6 @@ jobs: uses: actions/github-script@v8 with: script: | - const marker = ''; const label = 'compatibility'; const run = context.payload.workflow_run; @@ -87,9 +86,6 @@ jobs: return core.info('Could not identify the PR and its target branch.'); const issue = {...repo, issue_number: target.number}; - const comments = await list(issues.listComments, issue); - const comment = comments.find(c => c.user?.login === 'github-actions[bot]' && c.body?.startsWith(marker)); - const {data: pr} = await pulls.get({...repo, pull_number: target.number}); if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch || pr.head.sha !== run.head_sha || pr.base.ref !== target.base.ref) @@ -100,8 +96,6 @@ jobs: if (labeled) await issues.removeLabel({...issue, name: label}); - if (comment) - await issues.deleteComment({...repo, comment_id: comment.id}); return; } @@ -109,8 +103,5 @@ jobs: await issues.addLabels({...issue, labels: [label]}); const url = `${run.html_url}/attempts/${wire.run_attempt}#summary-${wire.id}`; - const body = `${marker}\nWire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; - if (!comment) - await issues.createComment({...issue, body}); - else if (comment.body !== body) - await issues.updateComment({...repo, comment_id: comment.id, body}); + const body = `Wire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; + await issues.createComment({...issue, body}); From 8647f02ca13fdc0c1a60f60a751a8d707c3fb201 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:13:53 +0300 Subject: [PATCH 14/20] IGNITE-29145 Clarify wire report helper names --- .github/workflows/check-protected-classes.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 1de5fb0e9a7d1..e951f1377a99f 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -45,15 +45,14 @@ jobs: const only = items => items.length === 1 ? items[0] : undefined; const list = (method, params) => github.paginate(method, {...repo, ...params, per_page: 100}); - function stepResult(job, name) { + function findStepConclusion(job, name) { return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; } - async function targetOf(run) { + async function findPullRequestForRun(run) { if (!run.head_repository) return; if (run.pull_requests?.length) return only(run.pull_requests); - // Fork runs can omit pull_requests. Match the source branch to a single PR open at run creation. const head = `${run.head_repository.owner.login}:${run.head_branch}`; const candidates = await list(pulls.list, {head, state: 'all'}); const target = only(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id @@ -75,13 +74,13 @@ jobs: const headJobs = jobs.filter(job => job.head_sha === run.head_sha); const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); - const upload = stepResult(wire, 'Upload wire diff'); - if (wire?.conclusion !== 'success' || stepResult(wire, 'Compare descriptions and publish summary') !== 'success' - || stepResult(java, 'Check all wire format descriptions are collected') !== 'success' + const upload = findStepConclusion(wire, 'Upload wire diff'); + if (wire?.conclusion !== 'success' || findStepConclusion(wire, 'Compare descriptions and publish summary') !== 'success' + || findStepConclusion(java, 'Check all wire format descriptions are collected') !== 'success' || !['success', 'skipped'].includes(upload)) return core.info('The wire comparison or completeness check could not be verified.'); - const target = await targetOf(run); + const target = await findPullRequestForRun(run); if (!target) return core.info('Could not identify the PR and its target branch.'); From f32235b0c2ab3fa973543f9e4ee65e67de40d758 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:18:56 +0300 Subject: [PATCH 15/20] IGNITE-29145 Rename only to singleOrUndefined in the wire report --- .github/workflows/check-protected-classes.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index e951f1377a99f..808f105195e1c 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -42,20 +42,20 @@ jobs: const run = context.payload.workflow_run; const repo = context.repo; const {actions, issues, pulls} = github.rest; - const only = items => items.length === 1 ? items[0] : undefined; + const singleOrUndefined = items => items.length === 1 ? items[0] : undefined; const list = (method, params) => github.paginate(method, {...repo, ...params, per_page: 100}); function findStepConclusion(job, name) { - return only(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; + return singleOrUndefined(job?.steps?.filter(step => step.name === name && step.status === 'completed') ?? [])?.conclusion; } async function findPullRequestForRun(run) { if (!run.head_repository) return; - if (run.pull_requests?.length) return only(run.pull_requests); + if (run.pull_requests?.length) return singleOrUndefined(run.pull_requests); const head = `${run.head_repository.owner.login}:${run.head_branch}`; const candidates = await list(pulls.list, {head, state: 'all'}); - const target = only(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id + const target = singleOrUndefined(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.created_at <= run.created_at && (!pr.closed_at || pr.closed_at >= run.created_at))); if (!target || target.state !== 'open' || target.head.sha !== run.head_sha) return; @@ -72,8 +72,8 @@ jobs: return core.info('A newer attempt has started.'); const headJobs = jobs.filter(job => job.head_sha === run.head_sha); - const wire = only(headJobs.filter(job => job.name === 'Compare wire format descriptions')); - const java = only(headJobs.filter(job => job.name === 'Check java code on JDK 17')); + const wire = singleOrUndefined(headJobs.filter(job => job.name === 'Compare wire format descriptions')); + const java = singleOrUndefined(headJobs.filter(job => job.name === 'Check java code on JDK 17')); const upload = findStepConclusion(wire, 'Upload wire diff'); if (wire?.conclusion !== 'success' || findStepConclusion(wire, 'Compare descriptions and publish summary') !== 'success' || findStepConclusion(java, 'Check all wire format descriptions are collected') !== 'success' From 72fd4cd5515d4fad7ac2e5cd054e6cf82e8f0303 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:23:18 +0300 Subject: [PATCH 16/20] IGNITE-29145 Remove redundant wire report checks --- .github/workflows/check-protected-classes.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 808f105195e1c..55ce755262e3c 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -50,14 +50,13 @@ jobs: } async function findPullRequestForRun(run) { - if (!run.head_repository) return; - if (run.pull_requests?.length) return singleOrUndefined(run.pull_requests); + if (run.pull_requests.length) return singleOrUndefined(run.pull_requests); const head = `${run.head_repository.owner.login}:${run.head_branch}`; const candidates = await list(pulls.list, {head, state: 'all'}); const target = singleOrUndefined(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.created_at <= run.created_at && (!pr.closed_at || pr.closed_at >= run.created_at))); - if (!target || target.state !== 'open' || target.head.sha !== run.head_sha) return; + if (!target) return; const {node} = await github.graphql(`query($id: ID!, $since: DateTime!) { node(id: $id) { ... on PullRequest { @@ -71,9 +70,8 @@ jobs: if (jobs.some(job => job.run_attempt > run.run_attempt)) return core.info('A newer attempt has started.'); - const headJobs = jobs.filter(job => job.head_sha === run.head_sha); - const wire = singleOrUndefined(headJobs.filter(job => job.name === 'Compare wire format descriptions')); - const java = singleOrUndefined(headJobs.filter(job => job.name === 'Check java code on JDK 17')); + const wire = singleOrUndefined(jobs.filter(job => job.name === 'Compare wire format descriptions')); + const java = singleOrUndefined(jobs.filter(job => job.name === 'Check java code on JDK 17')); const upload = findStepConclusion(wire, 'Upload wire diff'); if (wire?.conclusion !== 'success' || findStepConclusion(wire, 'Compare descriptions and publish summary') !== 'success' || findStepConclusion(java, 'Check all wire format descriptions are collected') !== 'success' From cd9774511fb5379c0a9f594301e549c9d3c9b61e Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:35:38 +0300 Subject: [PATCH 17/20] IGNITE-29145 Simplify PR lookup and rerun handling in the wire report --- .github/workflows/check-protected-classes.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 55ce755262e3c..5ec03c1356b7a 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -54,22 +54,11 @@ jobs: const head = `${run.head_repository.owner.login}:${run.head_branch}`; const candidates = await list(pulls.list, {head, state: 'all'}); - const target = singleOrUndefined(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id + return singleOrUndefined(candidates.filter(pr => pr.head.repo?.id === run.head_repository.id && pr.created_at <= run.created_at && (!pr.closed_at || pr.closed_at >= run.created_at))); - if (!target) return; - - const {node} = await github.graphql(`query($id: ID!, $since: DateTime!) { - node(id: $id) { ... on PullRequest { - timelineItems(first: 1, since: $since, itemTypes: [BASE_REF_CHANGED_EVENT]) { nodes { __typename } } - } } - }`, {id: target.node_id, since: run.created_at}); - if (node?.timelineItems.nodes.length === 0) return target; } - const jobs = await list(actions.listJobsForWorkflowRun, {run_id: run.id, filter: 'latest'}); - if (jobs.some(job => job.run_attempt > run.run_attempt)) - return core.info('A newer attempt has started.'); - + const jobs = await list(actions.listJobsForWorkflowRun, {run_id: run.id}); const wire = singleOrUndefined(jobs.filter(job => job.name === 'Compare wire format descriptions')); const java = singleOrUndefined(jobs.filter(job => job.name === 'Check java code on JDK 17')); const upload = findStepConclusion(wire, 'Upload wire diff'); From b1b1f88cb9f6b8ba447215092f0c0fe53bbcdcc6 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 15:58:05 +0300 Subject: [PATCH 18/20] IGNITE-29145 Highlight the wire diff in the PR comment --- .github/workflows/check-protected-classes.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 5ec03c1356b7a..a6a80cd7ded51 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -89,5 +89,8 @@ jobs: await issues.addLabels({...issue, labels: [label]}); const url = `${run.html_url}/attempts/${wire.run_attempt}#summary-${wire.id}`; - const body = `Wire format changed. Review the [wire diff in Job Summary](${url}) for rolling upgrade compatibility.`; + const body = `> [!IMPORTANT] + > **Wire format changed** + > + > [Review the wire diff in Job Summary](${url}) before approving this PR. Check that the change is compatible with rolling upgrades.`; await issues.createComment({...issue, body}); From 157fcf5b446816be1556de9f4eb9bf0f1fe7e4ec Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 24 Nov 2026 17:25:52 +0300 Subject: [PATCH 19/20] Fix review comments --- .github/workflows/check-protected-classes.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index a6a80cd7ded51..74b0493ecb438 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -38,6 +38,7 @@ jobs: with: script: | const label = 'compatibility'; + const marker = ''; const run = context.payload.workflow_run; const repo = context.repo; @@ -72,11 +73,17 @@ jobs: return core.info('Could not identify the PR and its target branch.'); const issue = {...repo, issue_number: target.number}; + const comments = await list(issues.listComments, issue); const {data: pr} = await pulls.get({...repo, pull_number: target.number}); if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch || pr.head.sha !== run.head_sha || pr.base.ref !== target.base.ref) return core.info('The PR has closed or changed since the comparison.'); + for (const comment of comments) { + if (comment.user?.login === 'github-actions[bot]' && comment.body?.startsWith(marker)) + await issues.deleteComment({...repo, comment_id: comment.id}); + } + const labeled = pr.labels.some(l => l.name === label); if (upload === 'skipped') { if (labeled) @@ -93,4 +100,4 @@ jobs: > **Wire format changed** > > [Review the wire diff in Job Summary](${url}) before approving this PR. Check that the change is compatible with rolling upgrades.`; - await issues.createComment({...issue, body}); + await issues.createComment({...issue, body: `${marker}\n\n${body}`}); From ab944adc1cd3f5eb704ddaf8fa4de4f9e613b1e9 Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Wed, 25 Nov 2026 11:04:24 +0300 Subject: [PATCH 20/20] IGNITE-29145 Post the new wire warning before deleting old comments --- .github/workflows/check-protected-classes.yml | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/check-protected-classes.yml b/.github/workflows/check-protected-classes.yml index 74b0493ecb438..ca6b4e8644263 100644 --- a/.github/workflows/check-protected-classes.yml +++ b/.github/workflows/check-protected-classes.yml @@ -74,30 +74,29 @@ jobs: const issue = {...repo, issue_number: target.number}; const comments = await list(issues.listComments, issue); + const oldWarnings = comments.filter(comment => comment.user?.login === 'github-actions[bot]' + && comment.body?.startsWith(marker)); + const {data: pr} = await pulls.get({...repo, pull_number: target.number}); if (pr.state !== 'open' || pr.head.repo?.id !== run.head_repository.id || pr.head.ref !== run.head_branch || pr.head.sha !== run.head_sha || pr.base.ref !== target.base.ref) return core.info('The PR has closed or changed since the comparison.'); - for (const comment of comments) { - if (comment.user?.login === 'github-actions[bot]' && comment.body?.startsWith(marker)) - await issues.deleteComment({...repo, comment_id: comment.id}); - } - const labeled = pr.labels.some(l => l.name === label); - if (upload === 'skipped') { - if (labeled) - await issues.removeLabel({...issue, name: label}); - - return; - } + if (upload === 'success') { + if (!labeled) + await issues.addLabels({...issue, labels: [label]}); - if (!labeled) - await issues.addLabels({...issue, labels: [label]}); - - const url = `${run.html_url}/attempts/${wire.run_attempt}#summary-${wire.id}`; - const body = `> [!IMPORTANT] + const url = `${run.html_url}/attempts/${wire.run_attempt}#summary-${wire.id}`; + const body = `> [!IMPORTANT] > **Wire format changed** > > [Review the wire diff in Job Summary](${url}) before approving this PR. Check that the change is compatible with rolling upgrades.`; - await issues.createComment({...issue, body: `${marker}\n\n${body}`}); + await issues.createComment({...issue, body: `${marker}\n\n${body}`}); + } + + for (const warning of oldWarnings) + await issues.deleteComment({...repo, comment_id: warning.id}); + + if (upload === 'skipped' && labeled) + await issues.removeLabel({...issue, name: label});