forked from hanchuanchuan/goInception
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
114 lines (99 loc) · 4.49 KB
/
circle.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
version: 2
general:
branches:
ignore:
- gh-pages
jobs:
build:
branches:
ignore:
- gh-pages
docker:
- image: cimg/go:1.22.1
- image: circleci/mysql:5.7.31
command: mysqld --lower_case_table_names=1 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin --innodb-large-prefix=true --log-bin=on --server_id=111
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
working_directory: /home/circleci/go/src/github.com/hanchuanchuan/goInception
steps:
- checkout
- run:
name: Install mysql-client
# command: sudo apt install default-mysql-client
command: sudo apt-get update -y --allow-releaseinfo-change && sudo apt upgrade -y && sudo apt-get install default-mysql-client libdbi-perl libdbd-mysql-perl && sudo apt-get install --reinstall ca-certificates libgnutls30 -y
- run:
name: Waiting for MySQL to be ready
command: |
for i in `seq 1 10`;
do
nc -z localhost 3306 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for MySQL && exit 1
- run:
name: mysql init
command: mysql -h 127.0.0.1 -u root -e "select version();create database if not exists test DEFAULT CHARACTER SET utf8;create database if not exists test_inc DEFAULT CHARACTER SET utf8;grant all on *.* to test@'127.0.0.1' identified by 'test';FLUSH PRIVILEGES;show databases;show variables like 'explicit_defaults_for_timestamp';"
# - run: rm -f go.sum
# - run: sudo wget -O /usr/local/bin/pt-online-schema-change percona.com/get/pt-online-schema-change
- run: sudo cp ./bin/pt-online-schema-change /usr/local/bin/pt-online-schema-change
- run: sudo wget -O gh-ost.tar.gz https://github.com/github/gh-ost/releases/download/v1.1.0/gh-ost-binary-linux-20200828140552.tar.gz
- run: sudo tar -zxvf gh-ost.tar.gz -C /usr/local/bin/
- run: sudo chmod +x /usr/local/bin/pt-online-schema-change
- run: sudo chmod +x /usr/local/bin/gh-ost
- run: sudo chmod +x cmd/explaintest/run-tests.sh
- restore_cache:
keys:
- pkg-cache-{{ checksum "go.mod" }}
- run:
name: "Build & Test"
command: make dev
no_output_timeout: 1800
- save_cache: # Store cache in the /go/pkg directory
key: pkg-cache-{{ checksum "go.mod" }}
paths:
- /go/pkg/
- setup_remote_docker:
docker_layer_caching: false
version: 19.03.13
- run:
name: Publish Docker Image to Docker Hub
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo "$DOCKERHUB_USERNAME"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
make docker
make docker-push
fi
- run:
name: Check OR Publish Release on GitHub
command: |
GIT_COMMIT_DESC=$(git log --format=oneline -n 1 ${CIRCLE_SHA1} | sed -E 's/^[^ ]+ (.*)$/\1/g')
echo 'commit message:' "$GIT_COMMIT_DESC"
if [[ "$GIT_COMMIT_DESC" =~ ^[vV][0123456789]+\.[0123456789]+.* ]] || [[ "$GIT_COMMIT_DESC" =~ ^[mM]erge.* ]]; then
make release2
ls -l release
echo "Publish Release on GitHub"
CIRCLE_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo 'TAG:' "$CIRCLE_TAG"
if [ -n "${CIRCLE_TAG}" ]; then
GO111MODULE=on go get github.com/tcnksm/[email protected]
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -replace -c ${CIRCLE_SHA1} -b "### $GIT_COMMIT_DESC" -n ${CIRCLE_TAG} ${CIRCLE_TAG} ./release
else
echo '无效$CIRCLE_TAG!'
fi
else
echo "不符合发版格式,跳过Release!"
fi
- run:
name: Upload coverage
command: |
GIT_COMMIT_DESC=$(git log --format=oneline -n 1 ${CIRCLE_SHA1} | sed -E 's/^[^ ]+ (.*)$/\1/g')
echo 'commit message:' "$GIT_COMMIT_DESC"
if [[ "$GIT_COMMIT_DESC" =~ ^[vV][0123456789]+\.[0123456789]+.* ]] || [[ "$GIT_COMMIT_DESC" =~ ^[mM]erge.* ]]; then
echo "merged! ignore coverage"
else
make dev upload-coverage
fi
environment:
TRAVIS_COVERAGE: 1