hook2xmpp/.gitlab-ci.yml

58 lines
1.7 KiB
YAML
Raw Normal View History

2019-02-14 01:32:27 +01:00
image: golang:latest
2020-03-11 23:31:27 +01:00
variables:
GIT_SUBMODULE_STRATEGY: recursive
2019-02-14 01:32:27 +01:00
stages:
- build
- test
2019-02-28 15:16:30 +01:00
- deploy
2019-02-14 01:32:27 +01:00
before_script:
2019-02-28 15:16:30 +01:00
- mkdir -p "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/"
2019-06-18 01:16:46 +02:00
- cp -R "$CI_PROJECT_DIR" "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/"
2019-02-28 15:16:30 +01:00
- cd "/go/src/dev.sum7.eu/$CI_PROJECT_PATH"
2019-02-14 01:32:27 +01:00
- go get -d -t ./...
build-my-project:
stage: build
script:
2019-06-20 10:17:46 +02:00
- mkdir "$CI_PROJECT_DIR/bin/"
2019-02-28 15:16:30 +01:00
- go install "dev.sum7.eu/$CI_PROJECT_PATH"
2019-06-20 10:17:46 +02:00
- mv "/go/bin/$CI_PROJECT_NAME" "$CI_PROJECT_DIR/bin/$CI_PROJECT_NAME"
2019-02-14 01:32:27 +01:00
artifacts:
paths:
2019-06-20 10:17:46 +02:00
- "bin/$CI_PROJECT_NAME"
- config_example.toml
2019-02-14 01:32:27 +01:00
test-my-project:
stage: test
script:
- go get github.com/client9/misspell/cmd/misspell
- misspell -error .
- ./.ci/check-gofmt
- ./.ci/check-testfiles
- go test $(go list ./... | grep -v /vendor/) -v -coverprofile .testCoverage.txt
2019-06-18 01:16:46 +02:00
- go tool cover -func=.testCoverage.txt
2019-02-14 01:32:27 +01:00
artifacts:
paths:
- .testCoverage.txt
test-race-my-project:
stage: test
script:
- go test -race ./...
2019-02-28 15:16:30 +01:00
deploy:
stage: deploy
only:
- master
script:
- go install "dev.sum7.eu/$CI_PROJECT_PATH"
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
2019-06-18 01:16:46 +02:00
- ssh -o StrictHostKeyChecking=no -p $SSH_PORT "$CI_PROJECT_NAME@$SSH_HOST" sudo /usr/bin/systemctl stop $CI_PROJECT_NAME
- scp -o StrictHostKeyChecking=no -P $SSH_PORT "/go/bin/$CI_PROJECT_NAME" "$CI_PROJECT_NAME@$SSH_HOST":/opt/$CI_PROJECT_NAME/bin
- ssh -o StrictHostKeyChecking=no -p $SSH_PORT "$CI_PROJECT_NAME@$SSH_HOST" sudo /usr/bin/systemctl start $CI_PROJECT_NAME