Skip to content

Commit f2059ba

Browse files
Start Swarm for the Docker tests
1 parent 177adbf commit f2059ba

File tree

2 files changed

+29
-51
lines changed

2 files changed

+29
-51
lines changed

.github/workflows/unit_test.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,7 @@ jobs:
2929
- name: install docker
3030
env:
3131
DOCKER_VERSION: ${{ matrix.docker_version }}
32-
run: |
33-
set -x
34-
sudo apt-get remove -y docker docker-engine docker.io containerd runc ||:
35-
sudo apt-get update -y
36-
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
37-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
38-
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
39-
sudo apt-get update -y
40-
sudo apt-cache gencaches
41-
sudo apt-get install -y docker-ce=$( apt-cache madison docker-ce | grep -e $DOCKER_VERSION | cut -f 2 -d '|' | head -1 | sed 's/\s//g' )
42-
if [ $? -ne 0 ]; then
43-
echo "Error: Could not install ${DOCKER_VERSION}"
44-
echo "Available docker versions:"
45-
apt-cache madison docker-ce
46-
exit 1
47-
fi
48-
sudo systemctl start docker
32+
run: sudo ./script/install_docker.sh
4933
- name: spec tests
5034
run: bundle exec rake
5135

script/install_docker.sh

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
1-
#!/bin/bash
2-
set -ex
3-
4-
declare -a SEMVER
5-
6-
# argv[0]
7-
DOCKER_VERSION=$1
8-
# argv[1]
9-
DOCKER_CE=$2
10-
11-
# disable travis default installation
12-
systemctl stop docker.service
13-
apt-get -y --purge remove docker docker-engine docker.io containerd runc
14-
15-
# install gpg key for docker rpo
16-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
17-
apt-key fingerprint 0EBFCD88
18-
19-
# enable docker repo
20-
add-apt-repository \
21-
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
22-
$(lsb_release -cs) \
23-
stable"
24-
apt-get update
25-
apt-cache gencaches
1+
#!/bin/bash -ex
2+
3+
${DOCKER_VERSION:?You must set the 'DOCKER_VERSION' environment variable}
4+
5+
apt-get remove -y \
6+
docker \
7+
docker-engine \
8+
docker.io \
9+
containerd \
10+
runc
11+
12+
apt-get update -y
2613

27-
set +e
28-
# install package
29-
apt-get install docker-ce=${DOCKER_VERSION}
14+
apt-get install -y \
15+
apt-transport-https \
16+
ca-certificates \
17+
curl \
18+
gnupg-agent \
19+
software-properties-common
20+
21+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
22+
23+
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
24+
apt-get update -y
25+
apt-cache gencaches
26+
apt-get install -y \
27+
docker-ce=$( apt-cache madison docker-ce | grep -e $DOCKER_VERSION | cut -f 2 -d '|' | head -1 | sed 's/\s//g' )
3028

3129
if [ $? -ne 0 ]; then
3230
echo "Error: Could not install ${DOCKER_VERSION}"
3331
echo "Available docker versions:"
3432
apt-cache madison docker-ce
3533
exit 1
3634
fi
37-
set -e
38-
39-
systemctl stop docker.service
4035

41-
echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock --pidfile=/var/run/docker.pid"' > /etc/default/docker
42-
cat /etc/default/docker
36+
systemctl start docker
4337

44-
systemctl start docker.service
38+
docker swarm init

0 commit comments

Comments
 (0)