Skip to content

Do not run lintcheck summary on feature-freezed PRs #15272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/workflows/lintcheck_summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ permissions:
jobs:
download:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
# FIXME(feature freeze): Make sure to remove that last part after the feature freeze is over
if: ${{ github.event.workflow_run.conclusion == 'success' && ! contains(github.event.pull_request.labels.*.name, 'A-new-lint') }}
steps:
- name: Download artifact
uses: actions/download-artifact@v4
Expand All @@ -40,54 +41,54 @@ jobs:
script: |
const fs = require("fs");
const assert = require("assert/strict");

function validateName(s) {
assert.match(s, /^[a-z0-9_:]+$/);
return s;
}

function validateInt(i) {
assert.ok(Number.isInteger(i));
return i;
}

function tryReadSummary() {
try {
return JSON.parse(fs.readFileSync("untrusted/summary.json"));
} catch {
return null;
}
}

const prNumber = parseInt(fs.readFileSync("untrusted/pr.txt"), 10);
core.exportVariable("PR", prNumber.toString());

const untrustedSummary = tryReadSummary();
if (!Array.isArray(untrustedSummary)) {
return;
}

let summary = `Lintcheck changes for ${context.payload.workflow_run.head_sha}

| Lint | Added | Removed | Changed |
| ---- | ----: | ------: | ------: |
`;

for (const untrustedRow of untrustedSummary) {
const name = validateName(untrustedRow.name);

const added = validateInt(untrustedRow.added);
const removed = validateInt(untrustedRow.removed);
const changed = validateInt(untrustedRow.changed);

const id = name.replace("clippy::", "user-content-").replaceAll("_", "-");
const url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${context.payload.workflow_run.id}#${id}`;

summary += `| [\`${name}\`](${url}) | ${added} | ${removed} | ${changed} |\n`;
}

summary += "\nThis comment will be updated if you push new changes";

fs.writeFileSync("summary.md", summary);

- name: Create/update comment
Expand Down