-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathconfig.yml
152 lines (150 loc) · 5.54 KB
/
config.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Setup in CircleCI account the following ENV variables:
# IS_PRODUCTION (default: 0)
# PACKAGECLOUD_ORGANIZATION (default: stackstorm)
# PACKAGECLOUD_TOKEN
# SLACK_TOKEN
version: 2
jobs:
build:
machine:
image: "ubuntu-2204:2023.04.2"
working_directory: ~/StackStorm/st2chatops
parallelism: 3
shell: /bin/bash --login
environment:
DISTROS: focal el8 el9
ST2_PACKAGES_REPO: https://github.com/StackStorm/st2-packages
ST2_TEST_ENVIRONMENT: https://github.com/StackStorm/st2-docker
DEPLOY_PACKAGES: 1
steps:
- checkout
- run:
name: Get repos and dependencies
command: |
set -e
echo "Cloning ${ST2_PACKAGES_BRANCH:-master} branch of st2-packages"
git clone --branch ${ST2_PACKAGES_BRANCH:-master} --depth 1 ${ST2_PACKAGES_REPO} ~/st2-packages
# Use DEPRECATED/all-in-one for now, we'll have to circle back around
# and fix this to use the master branch
echo "Cloning ${ST2_DOCKER_BRANCH:-DEPRECATED/all-in-one} branch of st2-docker"
git clone --branch ${ST2_DOCKER_BRANCH:-DEPRECATED/all-in-one} --depth 1 ${ST2_TEST_ENVIRONMENT} ~/st2-docker
make -C ~/st2-docker env
sudo apt-get update -qq && sudo apt-get install -y rpm jq nodejs net-tools
gem install package_cloud
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
rm -rf node_modules
# print versions
docker-compose version
nodejs -v
jq --version
- run:
name: Ensure Docker running
command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
# - run:
# name: Set up Ruby 2.0
# command: rvm use ruby-2.0.0-p645 --default
- run:
name: Get PackageCloud variables
command: |
set -e
distros=($DISTROS)
DISTRO=${distros[$CIRCLE_NODE_INDEX]}
PKG_VERSION=$(nodejs -e "console.log(require('./package.json').st2_version);")
if [ -n "$PACKAGECLOUD_TOKEN" ]; then
PKG_RELEASE=$(~/st2-packages/.circle/packagecloud.sh next-revision ${DISTRO} ${PKG_VERSION} st2chatops)
else
PKG_RELEASE=1
fi
echo "export PKG_VERSION=${PKG_VERSION}" >> ~/.circlerc
echo "export PKG_RELEASE=${PKG_RELEASE}" >> ~/.circlerc
echo "export DISTRO=${DISTRO}" >> ~/.circlerc
# Create required dirs
mkdir -p ~/packages/${DISTRO}/log /tmp/st2chatops
- run:
name: Pull Docker build images
command: |
set -e
docker-compose run ${DISTRO} pull
docker-compose run ${DISTRO}-test pull
- run:
name: Build packages
command: |
source ~/.circlerc
set -eu
docker-compose run \
-e PKG_VERSION=${PKG_VERSION} \
-e PKG_RELEASE=${PKG_RELEASE} \
${DISTRO} build
# Collect artifacts
cp -r /tmp/st2chatops/* ~/packages/${DISTRO}
# TODO: The tests need to look for ERROR logs, e.g. due to /stream not reachable
- run:
name: Pull & launch Docker st2-docker images
command: |
set -eu
docker-compose -f ~/st2-docker/docker-compose.yml pull
docker-compose -f ~/st2-docker/docker-compose.yml up -d
# sleep 10 is needed to allow the st2-docker test containers time to start up.
# Otherwise st2api is not ready when the tests run.
sleep 10 && echo 'Sleeping for 10 sec ...'
docker-compose -f ~/st2-docker/docker-compose.yml exec stackstorm st2 action-alias list
- run:
name: Run tests
command: |
source ~/.circlerc
set -eu
sleep 10
export ST2_HOSTNAME=$(ifconfig docker0 | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')
docker-compose run \
-e ST2_HOSTNAME=${ST2_HOSTNAME} \
-e ST2_USERNAME=${ST2_USER} \
-e ST2_PASSWORD=${ST2_PASSWORD} \
-e SLACK_TOKEN=${SLACK_TOKEN} \
${DISTRO}-test test
- run:
name: Collect logs
command: for name in $(docker ps -a --format "{{.Names}}"); do docker logs ${name} > ~/packages/${DISTRO}/log/${name}.log 2>&1; done
- store_artifacts:
path: ~/packages
destination: packages
- persist_to_workspace:
root: ~/
paths:
- st2-packages
- packages
# Deploy produced deb/rpm packages to PackageCloud staging
deploy:
docker:
# The primary container is an instance of the first list image listed. Your build commands run in this container.
- image: circleci/ruby:2.7
working_directory: ~/packages
environment:
DISTROS: "focal el8 el9"
steps:
- attach_workspace:
at: /home/circleci
- run:
name: List packages
command: find . | sed 's|[^/]*/| |g'
- run:
name: Install dependencies
command: gem install package_cloud
- run:
name: Deploy deb/rpm packages to PackageCloud
command: |
parallel -v -j0 --line-buffer ~/st2-packages/.circle/packagecloud.sh deploy {} ~/packages/{} ::: ${DISTROS}
workflows:
version: 2
package-test-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only:
- master
- /v[0-9]+\.[0-9]+/
- debug/circleci