-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
72 lines (68 loc) · 2.28 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
.gobuildenv: &gobuildenv
image: golang:1.10-stretch
before_script:
- BUILD_DIR=$GOPATH/src/$CI_PROJECT_PATH
- mkdir -p $BUILD_DIR && rmdir $BUILD_DIR
- ln -s `pwd` $BUILD_DIR
- cd $BUILD_DIR
build:
stage: build
<<: *gobuildenv
script:
# check everything builds well
- go build ./...
# unit tests
# - ./code-coverage.sh
# create package
- go build -o ./cibuild/cxdig .
- go build -o ./cibuild/dumbtool ./test_suite/dumbtool
artifacts:
expire_in: 1 week
paths:
- cibuild/
test_cmake:
stage: test
image: buildpack-deps:xenial-scm
before_script:
- git clone https://github.com/Kitware/CMake --depth 120
script:
- ./cibuild/cxdig scan -q CMake
- if [ ! -f "CMake.cxray/commits.json" ]; then echo "commits JSON file is missing" && exit 1; fi
- if [ ! -f "CMake.cxray/referential.json" ]; then echo "referential JSON file is missing" && exit 1; fi
- ./cibuild/cxdig sample -q --cmd "./cibuild/dumbtool --id {commit.id} --name {name} {path}" CMake --limit 100 | tee test-output.log
#- NBRETURN=$(cat test-output.log | wc -l)
#- if [ "$NBRETURN" != "100" ]; then echo "Found $NBRETURN lines, expected 100" && exit 1; fi
build_dist:
stage: test
<<: *gobuildenv
dependencies: []
script:
# build without debugging symbols
- LDFLAGS="-s"
# inject version info and build date
- LDFLAGS="$LDFLAGS -X $CI_PROJECT_PATH/cmd.softwareVersion=$CI_COMMIT_REF_NAME"
- LDFLAGS="$LDFLAGS -X $CI_PROJECT_PATH/cmd.buildDate=`date +%Y.%m.%d`"
# multiple builds
- go get github.com/mitchellh/gox
- gox -arch "amd64 arm" -os="!netbsd" -ldflags "$LDFLAGS" -output "dist/${CI_PROJECT_NAME}_{{.OS}}_{{.Arch}}"
- ./dist/cxdig_linux_amd64 version
artifacts:
expire_in: 1 week
paths:
- dist/
upload_github:
stage: deploy
<<: *gobuildenv
dependencies:
- build_dist
script:
# check version is OK
- VERSION=$(./dist/cxdig_linux_amd64 version -q)
- '[[ "$VERSION" =~ ^[0-9.]+$ ]] || (echo "Invalid version: $VERSION"; exit 1)'
- '[ "$VERSION" == "$CI_COMMIT_REF_NAME" ]'
# publish on GitHub
- '[ ! -z "$GITHUB_TOKEN" ]'
- go get github.com/tcnksm/ghr
- ghr -t $GITHUB_TOKEN -u $CI_PROJECT_NAMESPACE -r $CI_PROJECT_NAME --replace $VERSION dist/
only:
- tags