mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-12 19:03:45 +00:00
Closes differences from GitHub's runner that common workflows hit:
- `ACTIONS_STEP_DEBUG` set as a repository variable enables debug output as on GitHub, where a secret of the same name still takes precedence. `runner.debug` and `RUNNER_DEBUG` are now also set inside composite actions, which lost the secret.
- `github.env` and `github.path` hold the file-command paths instead of being empty, so `echo "A=1" >> "${{ github.env }}"` works.
- Remote composite actions only get a pre stage when they nest actions. That stage evaluated `with:` before earlier steps ran, so an input like `${{ fromJSON(steps.meta.outputs.json).v }}` failed the job.
- `ports` on a job container are published, they were ignored while service ports worked.
- Dockerfile action build output reaches the job log. It was logged at debug and dropped, so a failing `RUN` showed only the final error.
- Local Docker actions honor their `.dockerignore`, as `docker build` does.
- Cancelling or timing out a host-mode step sends SIGINT, then SIGTERM after 7.5 seconds and SIGKILL after 2.5 more, as GitHub's runner does, so `trap` handlers and shutdown hooks run.
- `.sh` job hooks fall back to `sh` where bash is missing, and `.ps1` hooks to `powershell` where pwsh is missing, as on GitHub.
_Written by Claude (Opus 5.5)._
Reviewed-on: https://gitea.com/gitea/runner/pulls/1413
Reviewed-by: bircni <[email protected]>
Co-authored-by: silverwind <[email protected]>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// Copyright 2020 The nektos/act Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build !(WITHOUT_DOCKER || !(linux || darwin || windows || netbsd || freebsd))
|
|
|
|
package container
|
|
|
|
import (
|
|
"bufio"
|
|
"cmp"
|
|
"encoding/json/v2"
|
|
"errors"
|
|
"io"
|
|
|
|
"gitea.com/gitea/runner/act/common/logging"
|
|
)
|
|
|
|
type dockerMessage struct {
|
|
ID string `json:"id"`
|
|
Stream string `json:"stream"`
|
|
Error string `json:"error"`
|
|
ErrorDetail struct {
|
|
Message string `json:"message"`
|
|
} `json:"errorDetail"`
|
|
Status string `json:"status"`
|
|
Progress string `json:"progress"`
|
|
}
|
|
|
|
func logDockerResponse(logger *logging.Logger, dockerResponse io.ReadCloser, log func(string, ...any)) error {
|
|
defer dockerResponse.Close()
|
|
|
|
scanner := bufio.NewScanner(dockerResponse)
|
|
scanner.Buffer(nil, 64*1024*1024) // a build echoes long instructions in one record
|
|
for scanner.Scan() {
|
|
line := scanner.Bytes()
|
|
var msg dockerMessage
|
|
if err := json.Unmarshal(line, &msg); err != nil {
|
|
logger.Debugf("Unable to unmarshal line [%s] ==> %v", string(line), err)
|
|
continue
|
|
}
|
|
|
|
if message := cmp.Or(msg.Error, msg.ErrorDetail.Message); message != "" {
|
|
log("%s", message)
|
|
return errors.New(message)
|
|
}
|
|
|
|
switch {
|
|
case msg.Status != "":
|
|
if msg.Progress != "" {
|
|
log("%s :: %s :: %s\n", msg.Status, msg.ID, msg.Progress)
|
|
} else {
|
|
log("%s :: %s\n", msg.Status, msg.ID)
|
|
}
|
|
case msg.Stream != "":
|
|
log("%s", msg.Stream)
|
|
default:
|
|
logger.Debugf("Unable to handle line: %s", string(line))
|
|
}
|
|
}
|
|
|
|
return scanner.Err()
|
|
}
|