Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
compliance: Fix file report upload (#53425)
Finn Eversff0aa17944fd
diff --git a/.github/workflows/compliance_check.yml b/.github/workflows/compliance_check.ymlindex ac94d431ca2..7eb53f082dd 100644--- a/.github/workflows/compliance_check.yml+++ b/.github/workflows/compliance_check.yml@@ -36,18 +36,17 @@ jobs:- id: run-compliance-checkname: compliance_check::scheduled_compliance_check::run_compliance_checkrun: |- 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@330a01c490aca151604b8cf639adc76d48f6c5d4with:- name: compliance-report.md- path: target/compliance-report.md+ name: compliance-report-${GITHUB_REF_NAME}.md+ path: compliance-report-${GITHUB_REF_NAME}.mdif-no-files-found: error- name: send_compliance_slack_notificationif: always()diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 62ada22ea0a..e40c9f68b5f 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -307,19 +307,19 @@ jobs:cache: rustpath: ~/.rustup- id: run-compliance-check- name: release::compliance_check::run_compliance_check+ name: release::run_compliance_checkrun: |- 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@330a01c490aca151604b8cf639adc76d48f6c5d4with:- name: compliance-report.md- path: target/compliance-report.md+ name: compliance-report-${GITHUB_REF_NAME}.md+ path: compliance-report-${GITHUB_REF_NAME}.mdif-no-files-found: error- name: send_compliance_slack_notificationif: always()@@ -672,19 +672,20 @@ jobs:with:cache: rustpath: ~/.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_checkrun: |- 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@330a01c490aca151604b8cf639adc76d48f6c5d4with:- name: compliance-report.md- path: target/compliance-report.md+ name: compliance-report-${GITHUB_REF_NAME}.md+ path: compliance-report-${GITHUB_REF_NAME}.mdif-no-files-found: erroroverwrite: 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 }}#artifactsauto_release_preview:diff --git a/tooling/xtask/src/tasks/workflows/compliance_check.rs b/tooling/xtask/src/tasks/workflows/compliance_check.rsindex e61465ab825..941e993403a 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<Run> {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.rsindex be49ef7d7e7..5a33cc911b5 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<Use> {.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<Run> {- 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<Run> {+ 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<Run> {- 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",))}