2024-04-20 15:06:19 +02:00
version : "3"
2018-03-10 23:34:18 +01:00
2018-04-04 22:51:37 +02:00
vars :
2024-04-20 15:06:19 +02:00
DOCKER_ORG : semaphoreui
DOCKER_SERVER : semaphore
DOCKER_RUNNER : runner
DOCKER_CMD : docker
2020-02-09 13:25:06 +01:00
2018-03-10 23:34:18 +01:00
tasks :
all :
2024-04-20 15:06:19 +02:00
desc : Install, test and build Semaphore for local architecture
2018-03-10 23:34:18 +01:00
cmds :
2018-03-12 13:27:13 +01:00
- task : deps
- task : test
2024-04-20 15:06:19 +02:00
- task : build
2022-10-26 21:32:30 +02:00
vars :
2024-04-20 15:06:19 +02:00
GOOS : ""
GOARCH : ""
2018-03-10 23:34:18 +01:00
deps :
2024-04-20 15:06:19 +02:00
desc : Install all build dependencies
2018-03-10 23:34:18 +01:00
cmds :
2022-08-21 23:45:29 +02:00
- task : deps:tools
- task : deps:be
2024-04-20 15:06:19 +02:00
- task : deps:fe
deps:tools :
desc : Installs required tools to build and publish
vars :
SWAGGER_VERSION : v0.30.5
GORELEASER_VERSION : v1.25.1
GOLINTER_VERSION : v1.57.2
cmds :
2024-05-21 21:27:19 +02:00
# - go install github.com/go-swagger/go-swagger/cmd/swagger@{{ .SWAGGER_VERSION }}
2024-04-20 15:06:19 +02:00
- go install github.com/goreleaser/goreleaser@{{ .GORELEASER_VERSION }}
2024-05-21 21:27:19 +02:00
# - go install github.com/golangci/golangci-lint/cmd/golangci-lint@{{ .GOLINTER_VERSION }}
2018-03-10 23:34:18 +01:00
deps:be :
2018-03-11 15:22:50 +01:00
desc : Vendor application dependencies
2018-03-10 23:34:18 +01:00
cmds :
2020-02-09 13:25:06 +01:00
- go mod vendor
2018-03-10 23:34:18 +01:00
2024-04-20 15:06:19 +02:00
deps:fe :
desc : Installs nodejs requirements
2022-10-29 15:37:20 +02:00
dir : web
2020-11-05 09:59:14 +01:00
cmds :
- npm install
2018-03-27 22:12:47 +02:00
2024-04-20 15:06:19 +02:00
build :
desc : Build a full set of release binaries and packages
2018-03-10 23:34:18 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- task : build:fe
- task : build:be
2018-03-10 23:34:18 +01:00
2024-06-01 15:15:17 +02:00
build:debug :
desc : Build DEBUG server binary
cmds :
- >-
env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }}
go build -o bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
-tags "netgo"
-gcflags="all=-N -l"
2024-06-01 15:30:37 +02:00
-ldflags "-X {{ .IMPORT }}/util.Ver={{ .VERSION }} -X {{ .IMPORT }}/util.Commit={{ .SHA }} -X {{ .IMPORT }}/util.Date={{ .DATE }}" ./cli
2024-06-01 15:15:17 +02:00
vars :
TAG :
sh : git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD
SHA :
sh : git log --pretty=format:'%h' -n 1
VERSION : "{{ if eq .GITHUB_REF_TYPE \"tag\" }}{{ .GITHUB_REF_NAME }}{{ else }}{{ .TAG }}{{ end }}"
DATE : "{{ now | unixEpoch }}"
IMPORT : "github.com/ansible-semaphore/semaphore"
2024-04-20 15:06:19 +02:00
build:fe :
desc : Build VueJS project
2022-10-29 15:37:20 +02:00
dir : web
2020-11-05 09:59:14 +01:00
sources :
- src/*.*
- src/**/*.*
- public/index.html
- public/favicon.ico
- package.json
- package-lock.json
- babel.config.js
- vue.config.js
generates :
2024-02-26 12:03:38 +01:00
- ../api/public/css/*.css
- ../api/public/js/*.js
- ../api/public/index.html
- ../api/public/favicon.ico
2020-11-05 09:59:14 +01:00
cmds :
- npm run build
2024-04-20 15:06:19 +02:00
build:be :
desc : Build server binary
2018-03-10 23:34:18 +01:00
cmds :
2024-04-20 18:24:42 +02:00
- >-
env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }}
go build -o bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
-tags "netgo"
-ldflags "-s -w -X {{ .IMPORT }}/util.Ver={{ .VERSION }} -X {{ .IMPORT }}/util.Commit={{ .SHA }} -X {{ .IMPORT }}/util.Date={{ .DATE }}" ./cli
2018-03-08 00:42:11 +01:00
vars :
TAG :
2024-04-20 18:24:42 +02:00
sh : git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD
2018-03-08 00:42:11 +01:00
SHA :
sh : git log --pretty=format:'%h' -n 1
2024-04-20 18:24:42 +02:00
VERSION : "{{ if eq .GITHUB_REF_TYPE \"tag\" }}{{ .GITHUB_REF_NAME }}{{ else }}{{ .TAG }}{{ end }}"
2024-04-20 15:06:19 +02:00
DATE : "{{ now | unixEpoch }}"
2024-04-20 18:24:42 +02:00
IMPORT : "github.com/ansible-semaphore/semaphore"
2018-03-13 21:57:55 +01:00
2018-03-27 22:12:47 +02:00
lint :
cmds :
2024-04-20 15:06:19 +02:00
- task : lint:fe
2024-05-21 21:27:19 +02:00
# - task: lint:be
2018-03-27 22:12:47 +02:00
2024-04-20 15:06:19 +02:00
lint:fe :
dir : web
cmds :
- npm run lint
2024-05-21 21:27:19 +02:00
# lint:be:
# cmds:
# - golangci-lint run --disable goconst --timeout 240s ./...
# - go vet ./...
# - swagger validate ./api-docs.yml
2018-03-27 22:12:47 +02:00
2018-03-10 23:34:18 +01:00
test :
2018-04-11 20:05:38 +02:00
cmds :
2024-04-28 00:22:37 +02:00
# - task: test:fe
2018-04-11 20:05:38 +02:00
- task : test:be
2024-04-20 15:06:19 +02:00
test:fe :
dir : web
cmds :
- npm run test:unit
2018-04-11 20:05:38 +02:00
test:be :
2018-03-10 23:34:18 +01:00
desc : Run go code tests
cmds :
2022-08-22 01:00:32 +02:00
- go test -v -coverprofile=coverage.out ./...
2018-03-10 23:34:18 +01:00
2024-05-04 00:06:34 +02:00
e2e:goodman :
desc : Installs goodman which is required by dredd
cmds :
- go install github.com/snikch/goodman/cmd/goodman@latest
2024-04-20 15:06:19 +02:00
e2e:deps :
desc : Installs dredd dep for integration testing
dir : web
cmds :
- npm install dredd@13.1.2
e2e:hooks :
desc : Compile required dredd hooks built
dir : ./.dredd/hooks
cmds :
- go build -o ../compiled_hooks{{ if eq OS "windows" }}.exe{{ end }}
e2e:test :
desc : Run end to end test for API with dredd
2018-04-11 20:05:38 +02:00
cmds :
2024-05-04 00:06:34 +02:00
- ./web/node_modules/.bin/dredd --config .dredd/dredd.testing.yml
2018-04-11 20:05:38 +02:00
2024-10-21 08:50:14 +02:00
e2e:test:local :
desc : Run end to end test for API with dredd
cmds :
- ./web/node_modules/.bin/dredd --config .dredd/dredd.local.yml
2024-04-20 15:06:19 +02:00
release:prod :
desc : Create and publish a release
2018-03-10 23:34:18 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- goreleaser
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
release:test :
desc : Create a local test release
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- goreleaser --auto-snapshot --clean --skip=sign
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:test :
desc : Test containers by building, running, testing and deleting them
deps :
- task : docker:deps
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- task : docker:build
2018-03-12 01:35:24 +01:00
vars :
2024-04-20 15:06:19 +02:00
tag : test
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
- task : docker:goss
- task : docker:lint
- "{{ .DOCKER_CMD }} rmi {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:test"
- "{{ .DOCKER_CMD }} rmi {{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:test"
docker:lint :
desc : Lint all dockerfiles based on Hadolint
deps :
- task : docker:deps
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- task : docker:lint:server
- task : docker:lint:runner
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:lint:server :
desc : Lint server dockerfile based on Hadolint
dir : deployment/docker/server
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- hadolint Dockerfile --ignore DL3018
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:lint:runner :
desc : Lint runner dockerfile based on Hadolint
dir : deployment/docker/runner
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- hadolint Dockerfile --ignore DL3018
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:goss :
desc : Check if container contains defined files
deps :
- task : docker:deps
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- task : docker:goss:server
- task : docker:goss:runner
docker:goss:server :
desc : Check if server contains defined files
dir : deployment/docker/server
env :
GOSS_FILES_STRATEGY : cp
cmds :
- dgoss run -it "{{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:test"
docker:goss:runner :
desc : Check if runner contains defined files
dir : deployment/docker/runner
env :
GOSS_FILES_STRATEGY : cp
cmds :
- dgoss run -it "{{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:test"
2018-03-12 01:35:24 +01:00
docker:build :
2024-04-20 15:06:19 +02:00
desc : Build all defined images for Semaphore
2018-03-12 01:35:24 +01:00
vars :
tag : "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
cmds :
2024-04-20 15:06:19 +02:00
- task : docker:build:server
vars :
tag : "{{ .tag }}"
- task : docker:build:runner
2018-03-12 01:35:24 +01:00
vars :
tag : "{{ .tag }}"
2024-06-01 15:15:17 +02:00
docker:build:debug :
desc : Build an DEBUG image for Semaphore server
vars :
tag : "debug"
cmds :
- "{{ .DOCKER_CMD }} build -f deployment/docker/debug/Dockerfile -t {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:{{ .tag }} ."
2024-04-20 15:06:19 +02:00
docker:build:server :
desc : Build an image for Semaphore server
vars :
tag : "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- "{{ .DOCKER_CMD }} build -f deployment/docker/server/Dockerfile -t {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:{{ .tag }} ."
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:build:runner :
desc : Build an image for Semaphore runner
vars :
tag : "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- "{{ .DOCKER_CMD }} build -f deployment/docker/runner/Dockerfile -t {{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:{{ .tag }} ."
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:push :
desc : Push the images to registry
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- docker push {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:{{ .tag }}
- docker push {{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:{{ .tag }}
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:deps :
desc : Install docker testing dependencies
vars :
INSTALL_PATH : '{{ .INSTALL_PATH | default "/usr/local/bin" }}'
REQUIRE_SUDO : '{{ .REQUIRE_SUDO | default "true" }}'
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- task : docker:deps:hadolint
vars :
INSTALL_PATH : "{{ .INSTALL_PATH }}"
REQUIRE_SUDO : "{{ .REQUIRE_SUDO }}"
- task : docker:deps:goss
vars :
INSTALL_PATH : "{{ .INSTALL_PATH }}"
REQUIRE_SUDO : "{{ .REQUIRE_SUDO }}"
- task : docker:deps:dgoss
vars :
INSTALL_PATH : "{{ .INSTALL_PATH }}"
REQUIRE_SUDO : "{{ .REQUIRE_SUDO }}"
docker:deps:hadolint :
platforms :
- linux/amd64
- linux/arm64
- darwin/amd64
- darwin/arm64
vars :
HADOLINT_VERSION : v2.10.0
status :
- test -f "{{ .INSTALL_PATH }}/hadolint"
cmds :
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}curl -sSL https://github.com/hadolint/hadolint/releases/download/{{ .HADOLINT_VERSION }}/hadolint-{{ if eq OS "linux" }}Linux{{ end }}{{ if eq OS "darwin" }}Darwin{{ end }}-{{ if eq ARCH "amd64" }}x86_64{{ else }}{{ ARCH }}{{ end }} -o {{ .INSTALL_PATH }}/hadolint'
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}chmod +x {{ .INSTALL_PATH }}/hadolint'
2018-03-12 01:35:24 +01:00
2024-04-20 15:06:19 +02:00
docker:deps:goss :
platforms :
- linux
- darwin
vars :
GOSS_VERSION : v0.3.5
status :
- test -f "{{ .INSTALL_PATH }}/goss"
2018-04-04 22:51:37 +02:00
cmds :
2024-04-20 15:06:19 +02:00
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}curl -sSL https://github.com/aelsabbahy/goss/releases/download/{{ .GOSS_VERSION }}/goss-{{ OS }}-{{ ARCH }} -o {{ .INSTALL_PATH }}/goss'
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}chmod +x {{ .INSTALL_PATH }}/goss'
2018-04-04 22:51:37 +02:00
2024-04-20 15:06:19 +02:00
docker:deps:dgoss :
platforms :
- linux
- darwin
2018-03-12 01:35:24 +01:00
vars :
2024-04-20 15:06:19 +02:00
GOSS_VERSION : v0.3.5
status :
- test -f "{{ .INSTALL_PATH }}/dgoss"
2018-03-12 01:35:24 +01:00
cmds :
2024-04-20 15:06:19 +02:00
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}curl -sSL https://raw.githubusercontent.com/aelsabbahy/goss/{{ .GOSS_VERSION }}/extras/dgoss/dgoss -o {{ .INSTALL_PATH }}/dgoss'
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}chmod +x {{ .INSTALL_PATH }}/dgoss'