Cherry-pick compliance changes to preview branch (#53435)

Finn Evers created

Release Notes:

- N/A

Change summary

.github/workflows/compliance_check.yml       |  7 -----
.github/workflows/release.yml                | 16 +++----------
tooling/xtask/src/tasks/workflows/release.rs | 26 ++++++++++++---------
3 files changed, 20 insertions(+), 29 deletions(-)

Detailed changes

.github/workflows/compliance_check.yml 🔗

@@ -52,18 +52,13 @@ jobs:
     - name: send_compliance_slack_notification
       if: always()
       run: |
-        REPORT_CONTENT=""
-        if [ -f "compliance-report.md" ]; then
-            REPORT_CONTENT=$(cat "compliance-report.md")
-        fi
-
         if [ "$COMPLIANCE_OUTCOME" == "success" ]; then
             STATUS="✅ Scheduled compliance check passed for $COMPLIANCE_TAG"
         else
             STATUS="⚠️ Scheduled compliance check failed for $COMPLIANCE_TAG"
         fi
 
-        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s\n\n%s" "$STATUS" "$ARTIFACT_URL" "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22" "$REPORT_CONTENT")
+        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s" "$STATUS" "$ARTIFACT_URL" "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22")
 
         curl -X POST -H 'Content-type: application/json' \
             --data "$(jq -n --arg text "$MESSAGE" '{"text": $text}')" \

.github/workflows/release.yml 🔗

@@ -315,6 +315,7 @@ jobs:
       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'
       if: always()
       uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
@@ -325,18 +326,13 @@ jobs:
     - name: send_compliance_slack_notification
       if: always()
       run: |
-        REPORT_CONTENT=""
-        if [ -f "compliance-report.md" ]; then
-            REPORT_CONTENT=$(cat "compliance-report.md")
-        fi
-
         if [ "$COMPLIANCE_OUTCOME" == "success" ]; then
             STATUS="✅ Compliance check passed for $COMPLIANCE_TAG"
         else
             STATUS="❌ Compliance check failed for $COMPLIANCE_TAG"
         fi
 
-        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s\n\n%s" "$STATUS" "$ARTIFACT_URL" "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22" "$REPORT_CONTENT")
+        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s" "$STATUS" "$ARTIFACT_URL" "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22")
 
         curl -X POST -H 'Content-type: application/json' \
             --data "$(jq -n --arg text "$MESSAGE" '{"text": $text}')" \
@@ -692,21 +688,17 @@ jobs:
         name: compliance-report.md
         path: compliance-report.md
         if-no-files-found: error
+        overwrite: true
     - name: send_compliance_slack_notification
       if: always()
       run: |
-        REPORT_CONTENT=""
-        if [ -f "compliance-report.md" ]; then
-            REPORT_CONTENT=$(cat "compliance-report.md")
-        fi
-
         if [ "$COMPLIANCE_OUTCOME" == "success" ]; then
             STATUS="✅ Compliance check passed for $COMPLIANCE_TAG"
         else
             STATUS="❌ Compliance check failed for $COMPLIANCE_TAG"
         fi
 
-        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s\n\n%s" "$STATUS" "$ARTIFACT_URL" "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22" "$REPORT_CONTENT")
+        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s" "$STATUS" "$ARTIFACT_URL" "https://github.com/zed-industries/zed/pulls?q=is%3Apr+is%3Aclosed+label%3A%22PR+state%3Aneeds+review%22")
 
         curl -X POST -H 'Content-type: application/json' \
             --data "$(jq -n --arg text "$MESSAGE" '{"text": $text}')" \

tooling/xtask/src/tasks/workflows/release.rs 🔗

@@ -156,6 +156,7 @@ const NEEDS_REVIEW_PULLS_URL: &str = "https://github.com/zed-industries/zed/pull
 
 pub(crate) enum ComplianceContext {
     Release,
+    ReleaseNonBlocking,
     Scheduled { tag_source: StepOutput },
 }
 
@@ -164,11 +165,16 @@ pub(crate) fn add_compliance_notification_steps(
     context: ComplianceContext,
     compliance_step_id: &str,
 ) -> gh_workflow::Job {
-    let upload_step =
-        upload_artifact(COMPLIANCE_REPORT_PATH).if_condition(Expression::new("always()"));
+    let upload_step = upload_artifact(COMPLIANCE_REPORT_PATH)
+        .if_condition(Expression::new("always()"))
+        .when(matches!(context, ComplianceContext::Release), |step| {
+            step.add_with(("overwrite", true))
+        });
 
     let (success_prefix, failure_prefix) = match context {
-        ComplianceContext::Release => ("✅ Compliance check passed", "❌ Compliance check failed"),
+        ComplianceContext::Release | ComplianceContext::ReleaseNonBlocking => {
+            ("✅ Compliance check passed", "❌ Compliance check failed")
+        }
         ComplianceContext::Scheduled { .. } => (
             "✅ Scheduled compliance check passed",
             "⚠️ Scheduled compliance check failed",
@@ -176,18 +182,13 @@ pub(crate) fn add_compliance_notification_steps(
     };
 
     let script = formatdoc! {r#"
-        REPORT_CONTENT=""
-        if [ -f "{COMPLIANCE_REPORT_PATH}" ]; then
-            REPORT_CONTENT=$(cat "{COMPLIANCE_REPORT_PATH}")
-        fi
-
         if [ "$COMPLIANCE_OUTCOME" == "success" ]; then
             STATUS="{success_prefix} for $COMPLIANCE_TAG"
         else
             STATUS="{failure_prefix} for $COMPLIANCE_TAG"
         fi
 
-        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s\n\n%s" "$STATUS" "$ARTIFACT_URL" "{NEEDS_REVIEW_PULLS_URL}" "$REPORT_CONTENT")
+        MESSAGE=$(printf "%s\n\nReport: %s\nPRs needing review: %s" "$STATUS" "$ARTIFACT_URL" "{NEEDS_REVIEW_PULLS_URL}")
 
         curl -X POST -H 'Content-type: application/json' \
             --data "$(jq -n --arg text "$MESSAGE" '{{"text": $text}}')" \
@@ -206,7 +207,9 @@ pub(crate) fn add_compliance_notification_steps(
         .add_env((
             "COMPLIANCE_TAG",
             match context {
-                ComplianceContext::Release => Context::github().ref_name().to_string(),
+                ComplianceContext::Release | ComplianceContext::ReleaseNonBlocking => {
+                    Context::github().ref_name().to_string()
+                }
                 ComplianceContext::Scheduled { tag_source } => tag_source.to_string(),
             },
         ))
@@ -227,6 +230,7 @@ fn compliance_check() -> NamedJob {
         .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)
     }
 
     let job = release_job(&[])
@@ -241,7 +245,7 @@ fn compliance_check() -> NamedJob {
 
     named::job(add_compliance_notification_steps(
         job,
-        ComplianceContext::Release,
+        ComplianceContext::ReleaseNonBlocking,
         "run-compliance-check",
     ))
 }