Compare commits

...

3 Commits

Author SHA1 Message Date
bd13053773
Make manually invoked runners possible
All checks were successful
Alpine 3.20 Success
This is intended for runners that are only available on request.
2024-12-22 09:02:09 +01:00
92fd2db1c1
Add Qt Creator project files to .gitignore 2024-12-21 09:37:11 +01:00
0db2ff3409
Set a time limit on runners 2024-04-19 04:26:48 +02:00
3 changed files with 45 additions and 16 deletions

8
.gitignore vendored
View File

@ -1,2 +1,10 @@
/acid
/acid.1
/acid.cflags
/acid.config
/acid.creator
/acid.creator.user
/acid.cxxflags
/acid.files
/acid.includes

49
acid.go
View File

@ -66,10 +66,11 @@ type Config struct {
}
type ConfigRunner struct {
Name string `yaml:"name"` // descriptive name
Run string `yaml:"run"` // runner executable
Setup string `yaml:"setup"` // runner setup script (SSH)
SSH struct {
Name string `yaml:"name"` // descriptive name
Manual bool `yaml:"manual"` // only run on request
Run string `yaml:"run"` // runner executable
Setup string `yaml:"setup"` // runner setup script (SSH)
SSH struct {
User string `yaml:"user"` // remote username
Address string `yaml:"address"` // TCP host:port
Identity string `yaml:"identity"` // private key path
@ -80,9 +81,22 @@ type ConfigProject struct {
Runners map[string]ConfigProjectRunner `yaml:"runners"`
}
func (cf *ConfigProject) AutomaticRunners() (runners []string) {
// We pass through unknown runner names,
// so that they can cause reference errors later.
for runner := range cf.Runners {
if r, _ := gConfig.Runners[runner]; !r.Manual {
runners = append(runners, runner)
}
}
sort.Strings(runners)
return
}
type ConfigProjectRunner struct {
Setup string `yaml:"setup"` // project setup script (SSH)
Build string `yaml:"build"` // project build script (SSH)
Setup string `yaml:"setup"` // project setup script (SSH)
Build string `yaml:"build"` // project build script (SSH)
Timeout string `yaml:"timeout"` // timeout duration
}
func parseConfig(path string) error {
@ -378,12 +392,7 @@ func handlePush(w http.ResponseWriter, r *http.Request) {
return
}
runners := []string{}
for name := range project.Runners {
runners = append(runners, name)
}
sort.Strings(runners)
runners := project.AutomaticRunners()
if err := createTasks(r.Context(),
event.Repository.Owner.Username, event.Repository.Name,
event.HeadCommit.ID, runners); err != nil {
@ -492,11 +501,8 @@ func rpcEnqueue(ctx context.Context,
runners := fs.Args()[3:]
if len(runners) == 0 {
for runner := range project.Runners {
runners = append(runners, runner)
}
runners = project.AutomaticRunners()
}
sort.Strings(runners)
for _, runner := range runners {
if _, ok := project.Runners[runner]; !ok {
@ -937,6 +943,17 @@ func executorRunTask(ctx context.Context, task Task) error {
return fmt.Errorf("script: %w", err)
}
// Lenient or not, some kind of a time limit is desirable.
timeout := time.Hour
if rt.ProjectRunner.Timeout != "" {
timeout, err = time.ParseDuration(rt.ProjectRunner.Timeout)
if err != nil {
return fmt.Errorf("timeout: %w", err)
}
}
ctx, cancelTimeout := context.WithTimeout(ctx, timeout)
defer cancelTimeout()
privateKey, err := os.ReadFile(rt.Runner.SSH.Identity)
if err != nil {
return fmt.Errorf(

View File

@ -62,3 +62,7 @@ projects:
build: |
echo Computing line count...
find . -not -path '*/.*' -type f -print0 | xargs -0 cat | wc -l
# Time limit in time.ParseDuration format.
# The default of one hour should suffice.
timeout: 1h