From 7b0642d7695bfdaf185cd843b0166bac8bcb4c6e Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Tue, 14 Jun 2022 18:45:58 +0100 Subject: [PATCH] Collapse Complement CI successful jobs (or try to) --- .ci/scripts/collapse_complement_logs.py | 59 +++++++++++++++++++++++++ .github/workflows/tests.yml | 4 +- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .ci/scripts/collapse_complement_logs.py diff --git a/.ci/scripts/collapse_complement_logs.py b/.ci/scripts/collapse_complement_logs.py new file mode 100644 index 000000000000..7a35b57e2235 --- /dev/null +++ b/.ci/scripts/collapse_complement_logs.py @@ -0,0 +1,59 @@ +# Copyright 2022 The Matrix.org Foundation C.I.C. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import sys + +GROUP_START_PREFIX = "::group::" +PASSING_CI_PREFIX = "✅" +GROUP_END_PREFIX = "::endgroup::" + + +def main() -> None: + in_collapsed_block = False + first_group_name = None + last_group_name = None + buffer = [] + + def flush_buffer() -> None: + nonlocal buffer, in_collapsed_block + + sys.stdout.write(f"::group::{first_group_name} ... {last_group_name}\n") + for buffered_line in buffer: + sys.stdout.write(buffered_line) + + sys.stdout.write("::endgroup::\n") + + in_collapsed_block = False + buffer = [] + + for line in sys.stdin: + if line.startswith(GROUP_START_PREFIX): + group_name = line[len(GROUP_START_PREFIX) :] + should_skip_block = group_name.startswith(PASSING_CI_PREFIX) + + if in_collapsed_block and not should_skip_block: + flush_buffer() + elif in_collapsed_block and should_skip_block: + last_group_name = group_name + elif not in_collapsed_block and should_skip_block: + first_group_name = group_name + in_collapsed_block = True + + if not in_collapsed_block: + sys.stdout.write(line) + + flush_buffer() + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4ce27ff4130b..ebea1257ca85 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -347,7 +347,7 @@ jobs: - run: | set -o pipefail - POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt | python3 synapse/.ci/scripts/collapse_complement_logs.py shell: bash name: Run Complement Tests @@ -386,7 +386,7 @@ jobs: - run: | set -o pipefail - WORKERS=1 COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt + WORKERS=1 COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | gotestfmt | python3 synapse/.ci/scripts/collapse_complement_logs.py shell: bash name: Run Complement Tests