Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Collapse Complement CI successful jobs (or try to)
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed Jun 14, 2022
1 parent c99b511 commit 7b0642d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .ci/scripts/collapse_complement_logs.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7b0642d

Please sign in to comment.