image: golang:latest variables: GIT_SUBMODULE_STRATEGY: recursive stages: - build - test - deploy before_script: - mkdir -p "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/" - cp -R "$CI_PROJECT_DIR" "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/" - cd "/go/src/dev.sum7.eu/$CI_PROJECT_PATH" - go get -d -t ./... build-my-project: stage: build script: - mkdir "$CI_PROJECT_DIR/bin/" - go install "dev.sum7.eu/$CI_PROJECT_PATH" - mv "/go/bin/$CI_PROJECT_NAME" "$CI_PROJECT_DIR/bin/$CI_PROJECT_NAME" artifacts: paths: - "bin/$CI_PROJECT_NAME" - config_example.toml 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 - go tool cover -func=.testCoverage.txt artifacts: paths: - .testCoverage.txt test-race-my-project: stage: test script: - go test -race ./... 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 - 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