about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-25 22:37:08 +0000
committerbors <bors@rust-lang.org>2023-07-25 22:37:08 +0000
commit0dd5730e0f2cb73ff673c3cd0c9897bc2b5d6425 (patch)
treead5a2ed2528e1b13e12148f97d115df9f0e6225b /src
parent864bdf7843e1ceabc824ed86d97006acad6af643 (diff)
parentc80a9fa8704a7b9e9217ae2367b8aec8640cc3e1 (diff)
downloadrust-0dd5730e0f2cb73ff673c3cd0c9897bc2b5d6425.tar.gz
rust-0dd5730e0f2cb73ff673c3cd0c9897bc2b5d6425.zip
Auto merge of #114076 - matthiaskrgr:rollup-cpqq1n9, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112995 (Check for `<&NotClone as Clone>::clone()` calls and suggest to add Clone trait appropriately)
 - #113578 (Don't say that a type is uncallable if its fn signature has errors in it)
 - #113661 (Double check that hidden types match the expected hidden type)
 - #114044 (factor out more stable impls)
 - #114062 (CI: split nested GHA groups instead of panicking)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src')
-rw-r--r--src/tools/build_helper/src/ci.rs62
-rw-r--r--src/tools/tidy/src/ui_tests.rs2
2 files changed, 44 insertions, 20 deletions
diff --git a/src/tools/build_helper/src/ci.rs b/src/tools/build_helper/src/ci.rs
index b70ea5ec113..a8505ec9596 100644
--- a/src/tools/build_helper/src/ci.rs
+++ b/src/tools/build_helper/src/ci.rs
@@ -36,25 +36,26 @@ impl CiEnv {
 }
 
 pub mod gha {
-    use std::sync::atomic::{AtomicBool, Ordering};
+    use std::sync::Mutex;
 
-    static GROUP_ACTIVE: AtomicBool = AtomicBool::new(false);
+    static ACTIVE_GROUPS: Mutex<Vec<String>> = Mutex::new(Vec::new());
 
     /// All github actions log messages from this call to the Drop of the return value
-    /// will be grouped and hidden by default in logs. Note that nesting these does
-    /// not really work.
+    /// will be grouped and hidden by default in logs. Note that since github actions doesn't
+    /// support group nesting, any active group will be first finished when a subgroup is started,
+    /// and then re-started when the subgroup finishes.
     #[track_caller]
     pub fn group(name: impl std::fmt::Display) -> Group {
-        if std::env::var_os("GITHUB_ACTIONS").is_some() {
-            eprintln!("::group::{name}");
-        } else {
-            eprintln!("{name}")
+        let mut groups = ACTIVE_GROUPS.lock().unwrap();
+
+        // A group is currently active. End it first to avoid nesting.
+        if !groups.is_empty() {
+            end_group();
         }
-        // https://github.com/actions/toolkit/issues/1001
-        assert!(
-            !GROUP_ACTIVE.swap(true, Ordering::Relaxed),
-            "nested groups are not supported by GHA!"
-        );
+
+        let name = name.to_string();
+        start_group(&name);
+        groups.push(name);
         Group(())
     }
 
@@ -64,13 +65,36 @@ pub mod gha {
 
     impl Drop for Group {
         fn drop(&mut self) {
-            if std::env::var_os("GITHUB_ACTIONS").is_some() {
-                eprintln!("::endgroup::");
+            end_group();
+
+            let mut groups = ACTIVE_GROUPS.lock().unwrap();
+            // Remove the current group
+            groups.pop();
+
+            // If there was some previous group, restart it
+            if is_in_gha() {
+                if let Some(name) = groups.last() {
+                    start_group(format!("{name} (continued)"));
+                }
             }
-            assert!(
-                GROUP_ACTIVE.swap(false, Ordering::Relaxed),
-                "group dropped but no group active!"
-            );
         }
     }
+
+    fn start_group(name: impl std::fmt::Display) {
+        if is_in_gha() {
+            eprintln!("::group::{name}");
+        } else {
+            eprintln!("{name}")
+        }
+    }
+
+    fn end_group() {
+        if is_in_gha() {
+            eprintln!("::endgroup::");
+        }
+    }
+
+    fn is_in_gha() -> bool {
+        std::env::var_os("GITHUB_ACTIONS").is_some()
+    }
 }
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 18cee7d3d5c..699559e4ba9 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
 
 const ENTRY_LIMIT: usize = 900;
 // FIXME: The following limits should be reduced eventually.
-const ISSUES_ENTRY_LIMIT: usize = 1894;
+const ISSUES_ENTRY_LIMIT: usize = 1893;
 const ROOT_ENTRY_LIMIT: usize = 870;
 
 const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[