From ff0aa17944fd690d28a0acd05d0e3efc03fe0195 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Thu, 9 Apr 2026 08:27:30 +0200 Subject: [PATCH] compliance: Fix file report upload (#53425) Applies https://github.com/zed-industries/zed/pull/53424 to the main branch Release Notes: - N/A --- .github/workflows/compliance_check.yml | 9 ++-- .github/workflows/release.yml | 25 +++++----- .../src/tasks/workflows/compliance_check.rs | 11 +++-- tooling/xtask/src/tasks/workflows/release.rs | 47 +++++++------------ 4 files changed, 40 insertions(+), 52 deletions(-) diff --git a/.github/workflows/compliance_check.yml b/.github/workflows/compliance_check.yml index ac94d431ca2938fc512e8a480dd7ad46abe1041d..7eb53f082dd6aa22e60248acac1fd18529db3b26 100644 --- a/.github/workflows/compliance_check.yml +++ b/.github/workflows/compliance_check.yml @@ -36,18 +36,17 @@ jobs: - id: run-compliance-check name: compliance_check::scheduled_compliance_check::run_compliance_check run: | - echo "tag=$LATEST_TAG" >> "$GITHUB_OUTPUT" - cargo xtask compliance "$LATEST_TAG" --branch main --report-path compliance-report + cargo xtask compliance "$LATEST_TAG" --branch main --report-path "compliance-report-${GITHUB_REF_NAME}.md" env: LATEST_TAG: ${{ steps.determine-version.outputs.tag }} GITHUB_APP_ID: ${{ secrets.ZED_ZIPPY_APP_ID }} GITHUB_APP_KEY: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} - - name: '@actions/upload-artifact compliance-report.md' + - name: '@actions/upload-artifact compliance-report-${GITHUB_REF_NAME}.md' if: always() uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 with: - name: compliance-report.md - path: target/compliance-report.md + name: compliance-report-${GITHUB_REF_NAME}.md + path: compliance-report-${GITHUB_REF_NAME}.md if-no-files-found: error - name: send_compliance_slack_notification if: always() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62ada22ea0a95053973e93ae233bfdea485f6f01..e40c9f68b5f79c19238fd08da0b73919734f8fa4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -307,19 +307,19 @@ jobs: cache: rust path: ~/.rustup - id: run-compliance-check - name: release::compliance_check::run_compliance_check + name: release::run_compliance_check run: | - cargo xtask compliance "$GITHUB_REF_NAME" --report-path compliance-report + cargo xtask compliance "$GITHUB_REF_NAME" --report-path "compliance-report-${GITHUB_REF_NAME}.md" env: GITHUB_APP_ID: ${{ secrets.ZED_ZIPPY_APP_ID }} GITHUB_APP_KEY: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} continue-on-error: true - - name: '@actions/upload-artifact compliance-report.md' + - name: '@actions/upload-artifact compliance-report-${GITHUB_REF_NAME}.md' if: always() uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 with: - name: compliance-report.md - path: target/compliance-report.md + name: compliance-report-${GITHUB_REF_NAME}.md + path: compliance-report-${GITHUB_REF_NAME}.md if-no-files-found: error - name: send_compliance_slack_notification if: always() @@ -672,19 +672,20 @@ jobs: with: cache: rust path: ~/.rustup - - id: run-post-upload-compliance-check - name: release::validate_release_assets::run_post_upload_compliance_check + - id: run-compliance-check + name: release::run_compliance_check run: | - cargo xtask compliance "$GITHUB_REF_NAME" --report-path compliance-report + cargo xtask compliance "$GITHUB_REF_NAME" --report-path "compliance-report-${GITHUB_REF_NAME}.md" env: GITHUB_APP_ID: ${{ secrets.ZED_ZIPPY_APP_ID }} GITHUB_APP_KEY: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }} - - name: '@actions/upload-artifact compliance-report.md' + continue-on-error: true + - name: '@actions/upload-artifact compliance-report-${GITHUB_REF_NAME}.md' if: always() uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 with: - name: compliance-report.md - path: target/compliance-report.md + name: compliance-report-${GITHUB_REF_NAME}.md + path: compliance-report-${GITHUB_REF_NAME}.md if-no-files-found: error overwrite: true - name: send_compliance_slack_notification @@ -703,7 +704,7 @@ jobs: "$SLACK_WEBHOOK" env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WORKFLOW_FAILURES }} - COMPLIANCE_OUTCOME: ${{ steps.run-post-upload-compliance-check.outcome }} + COMPLIANCE_OUTCOME: ${{ steps.run-compliance-check.outcome }} COMPLIANCE_TAG: ${{ github.ref_name }} ARTIFACT_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts auto_release_preview: diff --git a/tooling/xtask/src/tasks/workflows/compliance_check.rs b/tooling/xtask/src/tasks/workflows/compliance_check.rs index e61465ab8252b9538a81b875e68749cffd7c43d5..941e993403a45c37477f88048376faa8807d2d4f 100644 --- a/tooling/xtask/src/tasks/workflows/compliance_check.rs +++ b/tooling/xtask/src/tasks/workflows/compliance_check.rs @@ -2,7 +2,10 @@ use gh_workflow::{Event, Job, Run, Schedule, Step, Workflow, WorkflowDispatch}; use indoc::formatdoc; use crate::tasks::workflows::{ - release::{COMPLIANCE_REPORT_PATH, ComplianceContext, add_compliance_notification_steps}, + release::{ + COMPLIANCE_REPORT_PATH, COMPLIANCE_STEP_ID, ComplianceContext, + add_compliance_notification_steps, + }, runners, steps::{self, CommonJobConditions, named}, vars::{self, StepOutput}, @@ -37,12 +40,11 @@ fn scheduled_compliance_check() -> steps::NamedJob { fn run_compliance_check(tag: &StepOutput) -> Step { named::bash( formatdoc! {r#" - echo "tag=$LATEST_TAG" >> "$GITHUB_OUTPUT" - cargo xtask compliance "$LATEST_TAG" --branch main --report-path {COMPLIANCE_REPORT_PATH} + cargo xtask compliance "$LATEST_TAG" --branch main --report-path "{COMPLIANCE_REPORT_PATH}" "#, } ) - .id("run-compliance-check") + .id(COMPLIANCE_STEP_ID) .add_env(("LATEST_TAG", tag.to_string())) .add_env(("GITHUB_APP_ID", vars::ZED_ZIPPY_APP_ID)) .add_env(("GITHUB_APP_KEY", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) @@ -61,6 +63,5 @@ fn scheduled_compliance_check() -> steps::NamedJob { ComplianceContext::Scheduled { tag_source: tag_output, }, - "run-compliance-check", )) } diff --git a/tooling/xtask/src/tasks/workflows/release.rs b/tooling/xtask/src/tasks/workflows/release.rs index be49ef7d7e7c552e3b52b350cbaab47c988ec39f..5a33cc911b5d940b2d52e93568c5f4e5c53a0898 100644 --- a/tooling/xtask/src/tasks/workflows/release.rs +++ b/tooling/xtask/src/tasks/workflows/release.rs @@ -151,8 +151,8 @@ pub(crate) fn create_sentry_release() -> Step { .add_with(("environment", "production")) } -pub(crate) const COMPLIANCE_REPORT_PATH: &str = "compliance-report"; -const COMPLIANCE_REPORT_FILE: &str = "target/compliance-report.md"; +pub(crate) const COMPLIANCE_REPORT_PATH: &str = "compliance-report-${GITHUB_REF_NAME}.md"; +pub(crate) const COMPLIANCE_STEP_ID: &str = "run-compliance-check"; const NEEDS_REVIEW_PULLS_URL: &str = "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22"; pub(crate) enum ComplianceContext { @@ -164,9 +164,8 @@ pub(crate) enum ComplianceContext { pub(crate) fn add_compliance_notification_steps( job: gh_workflow::Job, context: ComplianceContext, - compliance_step_id: &str, ) -> gh_workflow::Job { - let upload_step = upload_artifact(COMPLIANCE_REPORT_FILE) + let upload_step = upload_artifact(COMPLIANCE_REPORT_PATH) .if_condition(Expression::new("always()")) .when(matches!(context, ComplianceContext::Release), |step| { step.add_with(("overwrite", true)) @@ -203,7 +202,7 @@ pub(crate) fn add_compliance_notification_steps( .add_env(("SLACK_WEBHOOK", vars::SLACK_WEBHOOK_WORKFLOW_FAILURES)) .add_env(( "COMPLIANCE_OUTCOME", - format!("${{{{ steps.{compliance_step_id}.outcome }}}}"), + format!("${{{{ steps.{COMPLIANCE_STEP_ID}.outcome }}}}"), )) .add_env(( "COMPLIANCE_TAG", @@ -222,18 +221,18 @@ pub(crate) fn add_compliance_notification_steps( job.add_step(upload_step).add_step(notification_step) } -fn compliance_check() -> NamedJob { - fn run_compliance_check() -> Step { - named::bash(formatdoc! {r#" - cargo xtask compliance "$GITHUB_REF_NAME" --report-path {COMPLIANCE_REPORT_PATH} - "#, - }) - .id("run-compliance-check") - .add_env(("GITHUB_APP_ID", vars::ZED_ZIPPY_APP_ID)) - .add_env(("GITHUB_APP_KEY", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) - .continue_on_error(true) - } +fn run_compliance_check() -> Step { + named::bash(formatdoc! {r#" + cargo xtask compliance "$GITHUB_REF_NAME" --report-path "{COMPLIANCE_REPORT_PATH}" + "#, + }) + .id(COMPLIANCE_STEP_ID) + .add_env(("GITHUB_APP_ID", vars::ZED_ZIPPY_APP_ID)) + .add_env(("GITHUB_APP_KEY", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) + .continue_on_error(true) +} +fn compliance_check() -> NamedJob { let job = release_job(&[]) .runs_on(runners::LINUX_SMALL) .add_step( @@ -247,7 +246,6 @@ fn compliance_check() -> NamedJob { named::job(add_compliance_notification_steps( job, ComplianceContext::ReleaseNonBlocking, - "run-compliance-check", )) } @@ -273,31 +271,20 @@ fn validate_release_assets(deps: &[&NamedJob]) -> NamedJob { "#, }; - fn run_post_upload_compliance_check() -> Step { - named::bash(formatdoc! {r#" - cargo xtask compliance "$GITHUB_REF_NAME" --report-path {COMPLIANCE_REPORT_PATH} - "#, - }) - .id("run-post-upload-compliance-check") - .add_env(("GITHUB_APP_ID", vars::ZED_ZIPPY_APP_ID)) - .add_env(("GITHUB_APP_KEY", vars::ZED_ZIPPY_APP_PRIVATE_KEY)) - } - let job = dependant_job(deps) .runs_on(runners::LINUX_SMALL) .add_step(named::bash(&validation_script).add_env(("GITHUB_TOKEN", vars::GITHUB_TOKEN))) .add_step( steps::checkout_repo() .with_full_history() - .with_ref("${{ github.ref }}"), + .with_ref(Context::github().ref_()), ) .add_step(steps::cache_rust_dependencies_namespace()) - .add_step(run_post_upload_compliance_check()); + .add_step(run_compliance_check()); named::job(add_compliance_notification_steps( job, ComplianceContext::Release, - "run-post-upload-compliance-check", )) }