Files
kalorienmanager/.gitlab-ci.yml
T
2022-08-28 00:36:34 +02:00

87 lines
2.3 KiB
YAML

variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- source "/home/gitlab-runner/.sdkman/bin/sdkman-init.sh"
- sdk d java 11.0.12-open
stages:
- prepare
- build
- test
- analysis
- deploy
Prepare Go dependencies:
stage: prepare
script:
- go get -u github.com/spf13/cobra
- go get -u github.com/jstemmer/go-junit-report
- go get -u github.com/inconshreveable/mousetrap
- go get -u github.com/mitchellh/go-homedir
- go get -u github.com/t-yuki/gocover-cobertura
- go get -u github.com/cryptix/wav
- go get -u golang.org/x/lint/golint
Create Documentation:
stage: build
script:
- chmod +x docs/gradlew
- cd docs; ./gradlew publish
Compile Go Application:
stage: build
script: make build
Test Go Application:
stage: test
script:
- make test
- go test -v ./... 2>&1 | /home/gitlab-runner/go/bin/go-junit-report > report.xml
- go test -coverprofile=coverage.out ./...
- /home/gitlab-runner/go/bin/gocover-cobertura < coverage.out > coverage.xml
- go vet ./...
artifacts:
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
Code analysis:
stage: analysis
script:
- go test -json ./... > test-report.out
- go test -coverprofile=coverage.out ./...
- /home/gitlab-runner/go/bin/golint ./... > golint-report.out
- go vet ./... 2> govet-report.out
- /data/sonar-scanner/bin/sonar-scanner -Dsonar.projectVersion=$(git describe --abbrev=0) -Dsonar.projectKey="$SONAR_PROJECT_KEY" -Dsonar.host.url="$SONAR_HOST_URL" -Dsonar.login="$SONAR_TOKEN"
Deploy To Staging:
stage: deploy
script:
- make build
- sudo service kalorienmanager stop
- rsync -av templates kalorienmanager:/home/kalorienmanager/staging
- rsync -av bin/kalorienmanager kalorienmanager:/home/kalorienmanager/staging
- sudo service kalorienmanager start
environment:
name: staging
only:
- master
Deploy to Production:
stage: deploy
script:
- make build
- echo "ansible-playbook kalorienmanager-ansible.yml"
- sudo service kalorienmanager stop
- rsync -av templates kalorienmanager:/home/kalorienmanager/production
- rsync -av bin/kalorienmanager kalorienmanager:/home/kalorienmanager/production
- sudo service kalorienmanager start
environment:
name: production
only:
- master
when: manual