Skip to content

[Proposal] Don’t parse Actions steps on Gitea side; instead, let the runner report them #24604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wolfogre opened this issue May 9, 2023 · 4 comments
Assignees
Labels
topic/gitea-actions related to the actions of Gitea type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@wolfogre
Copy link
Member

wolfogre commented May 9, 2023

Background

Gitea will parse the steps of a job from the workflow file even before running the job. It works like:

  • Gitea reads the workflow file, so it knows how many steps there are and what their names are.
  • The information of steps will be stored in the DB.
  • When a runner runs the jobs, it doesn't need to report the number and name of steps. Instead, it reports the status and log of each step with a simple index, such as "step 5 was successful.”

I have to admit, it is a design mistake. The point is that it's impossible to know the real steps based on the static content of the file.

For example:

  • Some actions may has Pre and Post step.
    image
  • A job with service will have Initialize containers and Stop containers steps
    image
  • When a job reuse another workflow, the real steps is in another file.
    image

At present, the problem is not really serious. You can find the logs of the missing steps in Set up job and Complete job. It's just a little inconvenient, Gitea doesn't lose the logs.

image

Solution

The right way could be let the runner report the steps when running them.

I have to say, it will be a huge job that requires refactoring both Gitea and act runner. Many details need to be worked out. For example, the runner should report all steps before executing them, so users can see steps waiting to be executed:

image
@yekanchi
Copy link

yekanchi commented Mar 6, 2024

this is also related to this issue on the runner side:
https://gitea.com/gitea/act_runner/issues/444#issuecomment-809931

@sahil87
Copy link

sahil87 commented Feb 10, 2025

Instead of tackling this by taking the long route of refactoring gitea and act runner interactions, which might take a very long time or never happen, maybe we can just handle this in the frontend with the same logs?

The UI could be a list of steps within another list of steps, generated using these recurring separators already present in the logs:

Image

Even if we don't know the number of steps before hand, and get to see only those steps which have already run, it is still a huge improvement over the current situation.
Because I think the problem is definitely more than serious - its enough to keep some people searching for alternatives to gitea act runners 🤷 .

@maantje
Copy link
Contributor

maantje commented Feb 23, 2025

@sahil87, it's possible to make some improvements from the frontend.

In our instance, we added a script to the footer in /templates/custom/footer.tmpl. This script adds a 🧹 icon next to the action settings icon. To use it, expand the Set up job step and click the 🧹 icon. It will then automatically scroll through the output and omit any irrelevant logs. If an error occurs, it will stop at the error. If the job has already completed, clicking the 🧹 icon will clean up the log and scroll directly to the error.

You can try it out on a job of your own by simply pasting the contents of the eventListener into the browser console while on the job page.

<script>
window.addEventListener('load', function () {
  const right = document.getElementsByClassName('job-info-header-right')[0];
  let interval = null
  if (right) {
      const div = document.createElement('div')

      div.classList.add('ui', 'top', 'right', 'dropdown', 'custom', 'jump', 'item')
      div.innerText = "🧹"

      const cleanUp = () => {
          window.scrollTo(0, document.body.scrollHeight);

          [...document.getElementsByClassName("log-msg")].forEach((el) => {
            for (let prefix of [
              "evaluating",
              "expression",
              "Writing",
              "Extracting",
              "Merged container",
              "Custom container",
              "[command]",
              "Exec command '[",
              "Working directory '/workspace",
              "  🐳  docker",
              "executing remote job container",
              "type=remote-action ",
              "Stripping prefix:",
              "run post step for",
              "::set-output::",
              "::add-matcher::",
              "/var/run/act/actions",
            ]) {
              if (el.innerText.startsWith(prefix)) {
                el.parentElement.remove();
                return;
              }
            }

            const match = el.innerText.split('\\n\\n');

            if (match.length === 3) {
             el.innerText = match[1]
            }

            if (el.innerText.startsWith("  ❌")) {
              if (interval) {
                 clearInterval(interval)
              }
              el.scrollIntoView(false);
            }

            if (el.innerText === "🏁  Job succeeded" && interval) {
                clearInterval(interval)
            }
          });
      }
      div.onclick = () => {
        if (interval) {
           clearInterval(interval)
           interval = null
           return
        }

        cleanUp()
        interval = setInterval(cleanUp, 100)
      }

      right.prepend(div)
  }
})
</script>

@sahil87
Copy link

sahil87 commented Mar 4, 2025

@maantje this is really cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/gitea-actions related to the actions of Gitea type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

5 participants