Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ansible-semaphore/semaphore into…
Browse files Browse the repository at this point in the history
… feat-support-webhooks
  • Loading branch information
andreas-marschke committed Jan 2, 2024
2 parents 31b0de6 + 0f0587d commit c685999
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- uses: actions/setup-node@v3
with: { node-version: '16' }
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- run: go install github.com/go-task/task/v3/cmd/task@latest

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- uses: actions/setup-node@v3
with: { node-version: '16' }
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
needs: [test-db-migration]
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- run: go install github.com/go-task/task/v3/cmd/task@latest

Expand All @@ -97,7 +97,7 @@ jobs:
if: github.ref == 'refs/heads/develop'
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- run: go install github.com/go-task/task/v3/cmd/task@latest

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- uses: actions/setup-node@v3
with: { node-version: '16' }
Expand All @@ -36,7 +36,7 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/setup-go@v3
with: { go-version: 1.19 }
with: { go-version: '1.20' }

- run: go install github.com/go-task/task/v3/cmd/task@latest

Expand Down
8 changes: 8 additions & 0 deletions api/runners/runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func GetRunner(w http.ResponseWriter, r *http.Request) {
}

func UpdateRunner(w http.ResponseWriter, r *http.Request) {

runner := context.Get(r, "runner").(db.Runner)

var body runners.RunnerProgress

if !helpers.Bind(w, r, &body) {
Expand All @@ -126,6 +129,11 @@ func UpdateRunner(w http.ResponseWriter, r *http.Request) {
continue
}

if tsk.RunnerID != runner.ID {
// TODO: add error message
continue
}

for _, logRecord := range job.LogRecords {
tsk.Log2(logRecord.Message, logRecord.Time)
}
Expand Down
3 changes: 2 additions & 1 deletion db/sql/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ func (d *SqlDb) UpdateEnvironment(env db.Environment) error {
}

_, err = d.exec(
"update project__environment set name=?, json=?, env=? where id=?",
"update project__environment set name=?, json=?, env=?, password=? where id=?",
env.Name,
env.JSON,
env.ENV,
env.Password,
env.ID)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.18
FROM golang:1.20-alpine3.18

ENV SEMAPHORE_VERSION="development" SEMAPHORE_ARCH="linux_amd64" \
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}" \
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/ci/dredd.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.18 as golang
FROM golang:1.20-alpine3.18 as golang

RUN apk add --no-cache curl git

Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.18
FROM golang:1.20-alpine3.18

ENV SEMAPHORE_VERSION="development" SEMAPHORE_ARCH="linux_amd64" \
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}" \
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ansible-semaphore production image
FROM golang:1.19-alpine3.18 as builder
FROM golang:1.20-alpine3.18 as builder

COPY ./ /go/src/github.com/ansible-semaphore/semaphore
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/prod/buildx.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ansible-semaphore production image
FROM --platform=$BUILDPLATFORM golang:1.19-alpine3.18 as builder
FROM --platform=$BUILDPLATFORM golang:1.20-alpine3.18 as builder

COPY ./ /go/src/github.com/ansible-semaphore/semaphore
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
Expand Down
2 changes: 1 addition & 1 deletion deployment/docker/prod/runner.buildx.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ansible-semaphore production image
FROM --platform=$BUILDPLATFORM golang:1.19-alpine3.18 as builder
FROM --platform=$BUILDPLATFORM golang:1.20-alpine3.18 as builder

COPY ./ /go/src/github.com/ansible-semaphore/semaphore
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/ansible-semaphore/semaphore

go 1.19
go 1.20

require (
github.com/Sirupsen/logrus v1.0.4
Expand Down
12 changes: 12 additions & 0 deletions services/tasks/RemoteJob.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/db_lib"
"github.com/ansible-semaphore/semaphore/lib"
"github.com/ansible-semaphore/semaphore/util"
"net/http"
"time"
)
Expand Down Expand Up @@ -120,7 +121,16 @@ func (t *RemoteJob) Run(username string, incomingVersion *string) (err error) {

tsk.RunnerID = runner.ID

startTime := time.Now()

taskTimedOut := false

for {
if util.Config.MaxTaskDurationSec > 0 && int(time.Now().Sub(startTime).Seconds()) > util.Config.MaxTaskDurationSec {
taskTimedOut = true
break
}

time.Sleep(1_000_000_000)
tsk = t.taskPool.GetTask(t.Task.ID)
if tsk.Task.Status == lib.TaskSuccessStatus ||
Expand All @@ -138,6 +148,8 @@ func (t *RemoteJob) Run(username string, incomingVersion *string) (err error) {

if tsk.Task.Status == lib.TaskFailStatus {
err = fmt.Errorf("task failed")
} else if taskTimedOut {
err = fmt.Errorf("task timed out")
}

return
Expand Down
4 changes: 3 additions & 1 deletion util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type ConfigType struct {
BoltDb DbConfig `json:"bolt"`
Postgres DbConfig `json:"postgres"`

Dialect string `json:"dialect" rule:"^mysql|bolt|postgres$" env:"SEMAPHORE_DB_DIALECT"`
Dialect string `json:"dialect" default:"bolt" rule:"^mysql|bolt|postgres$" env:"SEMAPHORE_DB_DIALECT"`

// Format `:port_num` eg, :3000
// if : is missing it will be corrected
Expand Down Expand Up @@ -169,6 +169,8 @@ type ConfigType struct {
// oidc settings
OidcProviders map[string]OidcProvider `json:"oidc_providers"`

MaxTaskDurationSec int `json:"max_task_duration_sec" env:"MAX_TASK_DURATION_SEC"`

// task concurrency
MaxParallelTasks int `json:"max_parallel_tasks" default:"10" rule:"^[0-9]{1,10}$" env:"SEMAPHORE_MAX_PARALLEL_TASKS"`

Expand Down
5 changes: 0 additions & 5 deletions web/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import History from '../views/project/History.vue';
import Activity from '../views/project/Activity.vue';
import Billing from '../views/project/Billing.vue';
import Settings from '../views/project/Settings.vue';
import Templates from '../views/project/Templates.vue';
import TemplateView from '../views/project/TemplateView.vue';
Expand Down Expand Up @@ -41,10 +40,6 @@ const routes = [
path: '/project/:projectId/settings',
component: Settings,
},
{
path: '/project/:projectId/billing',
component: Billing,
},
{
path: '/project/:projectId/templates',
component: Templates,
Expand Down
63 changes: 0 additions & 63 deletions web/src/views/project/Billing.vue

This file was deleted.

0 comments on commit c685999

Please sign in to comment.