quarkusio / quarkusio/quarkus-github-bot

Detect long delays in CI tasks

Open
#554 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
30
Forks
30
PR merge metrics
No merged PRs in 30d

Description

This is an idea for quarkus-github-bot to build a report for any CI task that exceeds a configured time limit (let's say 4h).

Here is a sample implementation:

import java.io.BufferedReader;
import java.io.FileReader;
import java.time.Duration;
import java.time.Instant;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class GithubActionLogDelaysDetector {

    record LineData(long durationSeconds, String lineContent){}

    private static final Pattern TIMESTAMP_PATTERN =
        Pattern.compile("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{1,9}Z");

    public static void main(String[] args) throws Exception {
        String logFilePath = args[0];
        Map<Integer, LineData> lineToData = new TreeMap<>();

        try (var reader = new BufferedReader(new FileReader(logFilePath))) {
            String line;
            Instant previousTimestamp = null;
            int previousLineNumber = 0;
            int lineNumber = 0;

            while ((line = reader.readLine()) != null) {
                lineNumber++;
                if (!TIMESTAMP_PATTERN.matcher(line).find()) {
                    continue; // Skip lines without a valid timestamp
                }

                // Extract and parse timestamp
                String timestampStr = line.substring(0, line.indexOf('Z') + 1);
                Instant currentTimestamp = Instant.parse(timestampStr);
                String lineContent = line.substring(timestampStr.length()).trim(); // Extract content after timestamp

                if (previousTimestamp != null && previousLineNumber > 0) {
                    // Calculate duration in seconds between consecutive valid lines
                    long durationSeconds = Duration.between(previousTimestamp, currentTimestamp).getSeconds();
                    lineToData.put(previousLineNumber, new LineData(durationSeconds, lineContent));
                }
                previousTimestamp = currentTimestamp;
                previousLineNumber = lineNumber;
            }
        }

        // Sort by duration, limit to 100, and print
        Map<Integer, LineData> sortedMap = lineToData.entrySet().stream()
                .sorted(Map.Entry.comparingByValue(Comparator.comparingLong(LineData::durationSeconds).reversed()))
                .limit(100)
                .collect(Collectors.toMap(
                        Map.Entry::getKey,
                        Map.Entry::getValue,
                        (e1, e2) -> e1,
                        LinkedHashMap::new
                ));

        // Print results
        System.out.println("Line Number | Duration (seconds) | Line Content");
        System.out.println("------------|--------------------|-------------");
        sortedMap.forEach((lineNum, data) ->
                System.out.printf("%11d | %18d | %s%n", lineNum, data.durationSeconds(), data.lineContent()));
    }
}

Output Sample:

Line Number | Duration (seconds) | Line Content
------------|--------------------|-------------
      76209 |                116 | 2025-06-24 10:16:05,712 INFO  [tc.icr.io/.1.0.0] (build-11) Container icr.io/db2_community/db2:12.1.0.0 started in PT1M57.788383587S
      63580 |                 32 | [INFO]
      10889 |                 30 | 2025-06-24 08:53:25,840 INFO  [io.quarkus] (main) quarkus-undertow-deployment stopped in 0.010s
      63706 |                 30 | 2025-06-24 10:11:20,063 INFO  [tc.doc.io/gvenzl/oracle-free:23-slim-faststart] (build-4) Container docker.io/gvenzl/oracle-free:23-slim-faststart started in PT31.172087664S

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files, tests, or entry points. Start by locating CI-task or reporting code in quarkus-github-bot and checking how GitHub Actions logs are accessed. The sample Java detector and four-hour threshold suggest a direction, but the integration point and completion criteria need maintainer clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, java
Domain
ci-cd, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.