Skip to content

Commit ab663cc

Browse files
authored
Merge pull request #936 from metacpan/oalders/workflows
Test docker-compose via CircleCI
2 parents 964bbfa + 8d1e1a0 commit ab663cc

File tree

6 files changed

+80
-240
lines changed

6 files changed

+80
-240
lines changed

.circleci/config.yml

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,63 @@
11
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
22
version: 2.1
33
# Use a package of configuration called an orb.
4-
orbs:
5-
# Declare a dependency on the welcome-orb
6-
welcome: circleci/[email protected]
74
# Orchestrate or schedule a set of jobs
85
workflows:
9-
# Name the workflow "welcome"
10-
welcome:
6+
docker-compose:
117
# Run the welcome/run job in its own container
128
jobs:
13-
- welcome/run
9+
- build-and-test
10+
jobs:
11+
build-and-test:
12+
machine: true
13+
resource_class: medium
14+
steps:
15+
- run:
16+
name: Install Docker Compose
17+
command: |
18+
set -x
19+
curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
20+
sudo chmod +x ~/docker-compose
21+
- run:
22+
command: |
23+
git clone https://github.com/metacpan/metacpan-docker.git
24+
cd metacpan-docker
25+
name: metacpan-docker checkout
26+
- run:
27+
command: |
28+
pushd metacpan-docker
29+
./bin/metacpan-docker init
30+
name: clone missing repositories
31+
- run:
32+
command: |
33+
pushd metacpan-docker/src/metacpan-api
34+
git checkout -b ${CIRCLE_BRANCH} origin/${CIRCLE_BRANCH}
35+
name: metacpan-api checkout
36+
- run:
37+
command: |
38+
pushd metacpan-docker
39+
~/docker-compose build --build-arg CPM_ARGS='--with-test' api_test
40+
name: compose build
41+
- run:
42+
command: |
43+
pushd metacpan-docker
44+
./bin/metacpan-docker init
45+
~/docker-compose --verbose up -d api_test
46+
name: compose up
47+
- run:
48+
command: |
49+
pushd metacpan-docker/src/metacpan-api
50+
./wait-for-es.sh http://localhost:9200
51+
name: wait for ES
52+
- run:
53+
command: |
54+
pushd metacpan-docker
55+
~/docker-compose exec -T api_test prove -lr --jobs 2 t
56+
- run:
57+
command: |
58+
pushd metacpan-docker
59+
~/docker-compose logs
60+
docker stats --no-stream
61+
docker ps -a | head
62+
name: docker-compose logs
63+
when: on_fail

cpanfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use strict;
2+
use warnings;
3+
14
requires 'perl', '5.010';
25

36
requires 'Archive::Any', '0.0942';
@@ -130,7 +133,6 @@ requires 'Mozilla::CA';
130133
requires 'namespace::autoclean';
131134
requires 'Net::DNS::Paranoid';
132135
requires 'Net::Fastly', '1.05';
133-
requires 'Net::OpenID::Consumer';
134136
requires 'Net::Twitter', '4.01010';
135137
requires 'OrePAN2';
136138
requires 'Parse::CPAN::Packages::Fast', '0.09';
@@ -193,7 +195,6 @@ requires 'Plack::Test::Agent';
193195
requires 'Test::Code::TidyAll';
194196
requires 'Test::More', '0.99';
195197
requires 'Test::Most';
196-
requires 'Test::OpenID::Server', '0.03';
197198
requires 'Test::Perl::Critic';
198199
requires 'Test::RequiresInternet';
199200
requires 'Test::Routine', '0.012';

lib/MetaCPAN/Server/Controller/Login/OpenID.pm

Lines changed: 0 additions & 93 deletions
This file was deleted.

metacpan_server.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ minion_dsn = postgresql:///minion_queue
77
private_key 59125ffc09413eed3f2a2c07a37c7a44b95633e2
88
</controller>
99

10-
<controller Login::OpenID>
11-
secret_key 8225b1874fdc431cedb1cf7d454a92b8fde3a5e6
12-
</controller>
13-
1410
<smtp>
1511
host smtp.fastmail.com
1612
port 465

t/server/controller/login/openid.t

Lines changed: 0 additions & 110 deletions
This file was deleted.

wait-for-es.sh

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,36 @@
33
# Courtesy of @fxdgear
44
# https://github.com/elastic/elasticsearch-py/issues/778#issuecomment-384389668
55

6-
set -e
6+
set -ux
77

88
host="$1"
9-
shift
10-
cmd="$@"
11-
12-
13-
until $(curl --output /dev/null --silent --head --fail "$host"); do
14-
printf '.'
15-
sleep 1
16-
done
179

18-
# First wait for ES to start...
19-
response=$(curl $host)
10+
while true; do
11+
response=$(curl --write-out '%{http_code}' --silent --fail --output /dev/null "$host")
12+
if [[ "$response" -eq "200" ]]; then
13+
break
14+
fi
2015

21-
until [ "$response" = "200" ]; do
22-
response=$(curl --write-out %{http_code} --silent --output /dev/null "$host")
23-
>&2 echo "Elastic Search is unavailable - sleeping"
16+
echo "Elastic Search is unavailable - sleeping" >&2
2417
sleep 1
2518
done
2619

20+
# set -e now because it was causing the curl command above to exit the script
21+
# if the server was not available
22+
set -e
2723

28-
# Wait for ES status to turn to yellow.
29-
# TODO: Ideally we'd be waiting for green, but we need multiple nodes for that.
30-
31-
health="$(curl -fsSL "$host/_cat/health?h=status")"
32-
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")
33-
34-
until [ "$health" = 'yellow' ]; do
24+
while true; do
25+
## Wait for ES status to turn to yellow.
26+
## TODO: Ideally we'd be waiting for green, but we need multiple nodes for that.
3527
health="$(curl -fsSL "$host/_cat/health?h=status")"
36-
health="$(echo "$health" | sed -r 's/^[[:space:]]+|[[:space:]]+$//g')" # trim whitespace (otherwise we'll have "green ")
37-
>&2 echo "Elastic Search is unavailable ($health) - sleeping"
28+
health="$(echo "$health" | xargs)" # trim whitespace (otherwise we'll have "green ")
29+
if [[ $health == 'yellow' || $health == 'green' ]]; then
30+
break
31+
fi
32+
echo "Elastic Search is unavailable ($health) - sleeping" >&2
3833
sleep 1
3934
done
4035

41-
>&2 echo "Elastic Search is up"
42-
exec $cmd
36+
echo "Elastic Search is up" >&2
37+
shift
38+
exec "$@"

0 commit comments

Comments
 (0)