cleanup ci
This commit is contained in:
parent
aa0316d13f
commit
53c54bc49f
79
Jenkinsfile
vendored
79
Jenkinsfile
vendored
@ -1,79 +0,0 @@
|
||||
pipeline {
|
||||
agent {
|
||||
label 't2medium'
|
||||
}
|
||||
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
}
|
||||
|
||||
environment {
|
||||
HUB_URL = credentials('docker_hub_url')
|
||||
HUB_PATH = credentials('docker_hub_path')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Prepare') {
|
||||
steps {
|
||||
sh 'cp config_test.yml.dist config_test.yml'
|
||||
compose 'up -d --build postgres_test'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Tests') {
|
||||
steps {
|
||||
compose 'run --rm mg_telegram_test make jenkins_test'
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'cat ./test-report.xml'
|
||||
junit 'test-report.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Docker Images') {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
steps {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'docker-hub-credentials',
|
||||
usernameVariable: 'HUB_USER',
|
||||
passwordVariable: 'HUB_PASS'
|
||||
)]) {
|
||||
sh 'echo ${HUB_PASS} | docker login -u ${HUB_USER} --password-stdin ${HUB_URL}'
|
||||
}
|
||||
|
||||
sh 'docker build -t ${HUB_URL}${HUB_PATH} ./'
|
||||
sh 'docker push ${HUB_URL}${HUB_PATH}'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh 'docker rmi ${HUB_URL}${HUB_PATH}:latest'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
compose 'down -v'
|
||||
deleteDir ()
|
||||
}
|
||||
aborted {
|
||||
echo "Aborted."
|
||||
}
|
||||
success {
|
||||
echo "Success."
|
||||
}
|
||||
failure {
|
||||
echo "Failure."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def compose(cmd) {
|
||||
sh "docker-compose --no-ansi -f docker-compose-test.yml ${cmd}"
|
||||
}
|
11
Makefile
11
Makefile
@ -2,7 +2,6 @@ ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
SRC_DIR=$(ROOT_DIR)/src
|
||||
MIGRATIONS_DIR=$(ROOT_DIR)/migrations
|
||||
CONFIG_FILE=$(ROOT_DIR)/config.yml
|
||||
CONFIG_TEST_FILE=$(ROOT_DIR)/config_test.yml
|
||||
BIN=$(ROOT_DIR)/bin/transport
|
||||
REVISION=$(shell git describe --tags 2>/dev/null || git log --format="v0.0-%h" -n 1 || echo "v0.0-unknown")
|
||||
|
||||
@ -18,13 +17,6 @@ run: migrate
|
||||
test: deps fmt
|
||||
@echo "==> Running tests"
|
||||
@cd $(ROOT_DIR) && go test ./... -v -cpu 2
|
||||
|
||||
jenkins_test: migrate_test
|
||||
@echo "==> Running tests (result in test-report.xml)"
|
||||
@go get -v -u github.com/jstemmer/go-junit-report
|
||||
@go test ./... -v -cpu 2 -race | /go/bin/go-junit-report -set-exit-code > ./test-report.xml
|
||||
@go mod tidy
|
||||
|
||||
fmt:
|
||||
@echo "==> Running gofmt"
|
||||
@gofmt -l -s -w $(ROOT_DIR)
|
||||
@ -36,8 +28,5 @@ deps:
|
||||
migrate: build
|
||||
${BIN} --config $(CONFIG_FILE) migrate -p $(MIGRATIONS_DIR)
|
||||
|
||||
migrate_test: build
|
||||
@${BIN} --config $(CONFIG_TEST_FILE) migrate -p $(MIGRATIONS_DIR)
|
||||
|
||||
migrate_down: build
|
||||
@${BIN} --config $(CONFIG_FILE) migrate -v down
|
||||
|
@ -1,29 +0,0 @@
|
||||
version: ~
|
||||
|
||||
database:
|
||||
connection: postgres://mg_telegram_test:mg_telegram_test@postgres_test:5432/mg_telegram_test?sslmode=disable
|
||||
|
||||
http_server:
|
||||
host: ~
|
||||
listen: :3002
|
||||
|
||||
transport_info:
|
||||
name: Telegram
|
||||
code: mg-telegram
|
||||
logo_path: /static/telegram_logo.svg
|
||||
|
||||
sentry_dsn: ~
|
||||
|
||||
log_level: 5
|
||||
|
||||
debug: false
|
||||
|
||||
update_interval: 24
|
||||
|
||||
config_aws:
|
||||
access_key_id: ~
|
||||
secret_access_key: ~
|
||||
region: ~
|
||||
bucket: ~
|
||||
folder_name: ~
|
||||
content_type: image/jpeg
|
@ -1,25 +0,0 @@
|
||||
version: '2.1'
|
||||
|
||||
services:
|
||||
postgres_test:
|
||||
image: postgres:9.6
|
||||
environment:
|
||||
POSTGRES_USER: mg_telegram_test
|
||||
POSTGRES_PASSWORD: mg_telegram_test
|
||||
POSTGRES_DATABASE: mg_telegram_test
|
||||
ports:
|
||||
- ${POSTGRES_ADDRESS:-127.0.0.1:5434}:${POSTGRES_PORT:-5432}
|
||||
|
||||
mg_telegram_test:
|
||||
image: golang:1.11-stretch
|
||||
working_dir: /mgtg
|
||||
user: ${UID:-1000}:${GID:-1000}
|
||||
environment:
|
||||
GOCACHE: /go
|
||||
volumes:
|
||||
- ./:/mgtg
|
||||
- ./static:/static/
|
||||
links:
|
||||
- postgres_test
|
||||
ports:
|
||||
- ${MG_TELEGRAM_ADDRESS:-3002}:3002
|
Loading…
Reference in New Issue
Block a user