github.com/ppphp/yayagf@v0.0.1/.gitlab-ci.yml (about) 1 image: golang:latest 2 3 variables: 4 REPO_NAME: gitlab.papegames.com/fengche/yayagf 5 6 before_script: 7 - echo $CI_PROJECT_DIR 8 - export GOPATH=/home/gitlab-runner 9 - export PATH=$PATH:/usr/local/go/bin 10 11 stages: 12 - lint 13 - test 14 - sonar 15 16 vet: 17 stage: lint 18 script: 19 - go vet -n ./... 2>&1| tee vet 20 artifacts: 21 paths: 22 - vet 23 24 golangci-lint: 25 stage: lint 26 script: 27 - golangci-lint run ./... --out-format=checkstyle > golangci-lint-report.xml || true 28 artifacts: 29 paths: 30 - golangci-lint-report.xml 31 allow_failure: true 32 33 go-test: 34 stage: test 35 script: 36 - go test -race -cover -v . ./... -json -coverprofile=covprofile | tee test.json 37 - go tool cover -func=./covprofile -o ./total.txt 38 - cat total.txt|grep total 39 artifacts: 40 paths: 41 - covprofile 42 43 sonar_analyze: 44 stage: sonar 45 script: 46 - wget -q http://192.168.0.97:8000/sonar-scanner-4.5.0.2216.tar.gz 47 - tar -xf sonar-scanner-4.5.0.2216.tar.gz 48 - "./sonar-scanner/bin/sonar-scanner \ 49 -Dsonar.host.url=http://192.168.0.97:9000 \ 50 -Dsonar.sources=. \ 51 -Dsonar.projectKey=$CI_PROJECT_NAME \ 52 -Dsonar.login=dced6e70e45d30783fda260701e8e0169b61013f \ 53 -Dsonar.tests=. \ 54 -Dsonar.exclusions=**/*_test.go,**/vendor/**,golangci-lint-report.xml,**/testdata/** \ 55 -Dsonar.go.tests.reportPaths=test.json \ 56 -Dsonar.go.coverage.reportPaths=covprofile \ 57 -Dsonar.go.govet.reportPaths=vet \ 58 -Dsonar.go.golangci-lint.reportPaths=golangci-lint-report.xml \ 59 -Dsonar.test.inclusions=**/*_test.go \ 60 -Dsonar.test.exclusions=**/vendor/** \ 61 -Dsonar.branch.name=${CI_COMMIT_REF_NAME}" 62 dependencies: 63 - vet 64 - golangci-lint 65 - go-test 66 except: 67 refs: 68 - merge_requests 69 70 sonar_analyze_decoration: 71 stage: sonar 72 script: 73 - git config --global user.email "bigcar@papegames.com" 74 - git config --global user.name "bigcar" 75 - git branch -D ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} 76 - git checkout ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} 77 - git merge origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} 78 - go vet -n ./... 2> vet 79 - go test -race -cover -v ./... -json -coverprofile=covprofile > test.json 80 - go tool cover -func=./covprofile -o ./total.txt 81 - cat total.txt|grep total 82 - golangci-lint run ./... --out-format=checkstyle > golangci-lint-report.xml || true 83 - wget -q http://192.168.0.97:8000/sonar-scanner.tar.gz 84 - tar -xf sonar-scanner.tar.gz 85 - "./sonar-scanner/bin/sonar-scanner \ 86 -Dsonar.host.url=http://192.168.0.97:9000 \ 87 -Dsonar.sources=. \ 88 -Dsonar.projectKey=$CI_PROJECT_NAME \ 89 -Dsonar.login=dced6e70e45d30783fda260701e8e0169b61013f \ 90 -Dsonar.exclusions=**/*_test.go,**/vendor/**,golangci-lint-report.xml,**/testdata/** \ 91 -Dsonar.test.inclusions=**/*_test.go \ 92 -Dsonar.test.exclusions=**/vendor/** \ 93 -Dsonar.go.tests.reportPaths=test.json \ 94 -Dsonar.go.coverage.reportPaths=covprofile \ 95 -Dsonar.go.govet.reportPaths=vet \ 96 -Dsonar.go.golangci-lint.reportPaths=golangci-lint-report.xml \ 97 -Dsonar.pullrequest.gitlab.repositorySlug=$CI_PROJECT_ID \ 98 -Dsonar.pullrequest.key=${CI_MERGE_REQUEST_IID} \ 99 -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME} \ 100 -Dsonar.projectDescription=${CI_PROJECT_TITLE} \ 101 -Dsonar.links.homepage=${CI_PROJECT_URL} \ 102 -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} \ 103 -Dsonar.gitlab.project_id=${CI_PROJECT_ID} \ 104 -Dsonar.pullrequest.branch=${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} \ 105 -Dsonar.pullrequest.base=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} \ 106 -Dsonar.test.exclusions=**/vendor/**" 107 dependencies: 108 - vet 109 - golangci-lint 110 - go-test 111 only: 112 refs: 113 - merge_requests