Verified Commit 854d7d49 authored by Daniel Sonck's avatar Daniel Sonck
Browse files

Add gitlab ci

parent 08e53fb3
Pipeline #36 passed with stages
in 13 minutes and 53 seconds
stages:
- build
- deploy
before_script:
- eval $(ssh-agent -s | tee ssh-agent.env)
- chmod go-rwx $SSH_PRIVATE_KEY
- ssh-add $SSH_PRIVATE_KEY
after_script:
- . ssh-agent.env
- kill $SSH_AGENT_PID
build:
stage: build
script:
- ./build-docker.sh docker2.touhou.fm
\ No newline at end of file
- ./build-docker.sh docker2.touhou.fm
artifacts:
paths:
- playlist.version.auto.tfvars
reports:
junit: target/reports/tests.xml
cobertura: target/reports/cobertura.xml
deploy:
stage: deploy
script:
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
- git clone ssh://gitlab@git.touhou.fm:7222/touhou.fm/radio-go/infra/radio.git
- cp playlist.version.auto.tfvars radio
- cd radio
- git checkout ci/update-version
- git commit -a -m "Update version"
- git push -u origin ci/update-version -f
\ No newline at end of file
......@@ -7,7 +7,9 @@ on_fail() {
VERSION=$(git describe | sed s!release/!!g)
echo "version=$VERSION" > version.txt
cat > playlist.version.auto.tfvars <<EOC
playlist_version = "$VERSION"
EOC
echo "Building version: $VERSION"
......@@ -29,7 +31,7 @@ buildah copy "${C}" "${PWD}/"go.* ./ || on_fail
buildah copy "${C}" "${PWD}/"main.go ./ || on_fail
buildah copy "${C}" "${PWD}/"internal/ ./internal/ || on_fail
buildah copy "${C}" "${PWD}/"*.do ./ || on_fail
buildah copy "${C}" "${PWD}/version.txt" ./ || on_fail
buildah copy "${C}" "${PWD}/playlist.version.auto.tfvars" ./ || on_fail
buildah run --volume "${PWD}/.redo:${BUILD_DIR}/.redo" --volume "${PWD}/target:${BUILD_DIR}/target" -- "${C}" redo all || on_fail
......
exec >&2
case $2 in
.build/test)
redo-ifchange target/reports/tests.xml target/site/clover/clover.xml
redo-ifchange target/reports/tests.xml target/reports/cobertura.xml
mkdir -p "$(dirname "$2")"
touch "$3"
;;
*/playlist)
redo-ifchange mod.dep .build/test version.txt
VERSION=$(sed -n 's/version=\(.*\)/\1/gp' < version.txt)
redo-ifchange mod.dep .build/test playlist.version.auto.tfvars
VERSION=$(sed -n 's/playlist_version = "\(.*\)"/\1/gp' < playlist.version.auto.tfvars)
CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -ldflags "-X go.touhou.fm/radio/server/playlist/internal.version=$VERSION" -o "$3" .
setcap cap_net_bind_service=+ep "$3" || true
;;
*/go-clover)
*/go-cobertura)
redo-ifchange mod.install
mkdir -p "$(dirname "$3")"
go build -o "$3" github.com/codeofthrone/goclover
go build -o "$3" github.com/t-yuki/gocover-cobertura
;;
*/go-junit-report)
redo-ifchange mod.install
......
......@@ -2,8 +2,8 @@ exec >&2
mkdir -p "$(dirname "$2")"
case $2 in
*/clover)
redo-ifchange "target/reports/coverage.txt" "tool/go-clover"
tool/go-clover -f target/reports/coverage.txt -o "$3"
redo-ifchange "target/reports/coverage.txt" "tool/go-cobertura"
tool/go-cobertura -f target/reports/coverage.txt -o "$3"
;;
*/tests)
redo-ifchange "target/reports/tests.txt" "tool/go-junit-report"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment