73 lines
1.9 KiB
YAML
73 lines
1.9 KiB
YAML
stages:
|
|
- build
|
|
- test
|
|
- analysis
|
|
- deploy
|
|
|
|
before_script:
|
|
- go get -u github.com/jstemmer/go-junit-report
|
|
- go get -u github.com/t-yuki/gocover-cobertura
|
|
|
|
Create Documentation:
|
|
stage: build
|
|
script:
|
|
- chmod +x docs/gradlew
|
|
- cd docs; ./gradlew asciidoctor
|
|
artifacts:
|
|
paths:
|
|
- docs/build/asciidoc/pdf/kalorienmanager.pdf
|
|
|
|
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
|
|
cobertura: 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
|