-
-
Notifications
You must be signed in to change notification settings - Fork 24
169 lines (165 loc) · 5.41 KB
/
ci.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: ci
on:
push:
workflow_dispatch:
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DB_NAME: kaui_test
DOCKER_BUILDKIT: 1
JRUBY_OPTS: -J-Xmx1024M --debug
KB_ADDRESS: 127.0.0.1
KB_PORT: 8080
RAILS_ENV: test
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- ruby-version: '3.2.2'
database-adapter: 'mysql2'
database-user: 'root'
database-password: 'root'
database-port: '3306'
docker-compose-file: 'docker-compose.ci.mysql.yml'
- ruby-version: 'jruby-9.4.2.0'
database-adapter: 'mariadb'
database-user: 'root'
database-password: 'root'
database-port: '3306'
docker-compose-file: 'docker-compose.ci.mysql.yml'
- ruby-version: '3.2.2'
database-adapter: 'postgresql'
database-user: 'postgres'
database-password: 'postgres'
database-port: '5432'
docker-compose-file: 'docker-compose.ci.postgresql.yml'
- ruby-version: 'jruby-9.4.2.0'
database-adapter: 'postgresql'
database-user: 'postgres'
database-password: 'postgres'
database-port: '5432'
docker-compose-file: 'docker-compose.ci.postgresql.yml'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up JDK
uses: actions/setup-java@v2.5.0
with:
java-version: '11'
distribution: 'temurin'
#cache: 'maven'
- name: Configure Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Start stack
run: |
cd docker
docker-compose -p it -f ${{ matrix.docker-compose-file }} up --no-start
docker start it_db_1
- name: Wait for MySQL
if: ${{ matrix.docker-compose-file == 'docker-compose.ci.mysql.yml' }}
run: |
set +e
count=0
until mysqladmin ping -h 127.0.0.1 -u root --password=root --silent; do
if [[ "$count" == "25" ]]; then
exit 1
fi
(( count++ ))
printf '.'
sleep 5
done
set -e
- name: Wait for PostgreSQL
if: ${{ matrix.docker-compose-file == 'docker-compose.ci.postgresql.yml' }}
run: |
set +e
count=0
until $(psql -h 127.0.0.1 -U postgres -p 5432 -l > /dev/null); do
if [[ "$count" == "25" ]]; then
exit 1
fi
(( count++ ))
printf '.'
sleep 5
done
set -e
- name: Start Kill Bill
# Sometimes it gets stuck (if Kill Bill starts when the DB isn't ready?)
timeout-minutes: 4
run: |
docker start it_killbill_1
count=0
until $(curl --connect-timeout 10 --max-time 30 --output /dev/null --silent --fail http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck); do
if [[ "$count" == "180" ]]; then
exit 64
fi
count=$(( count + 1 ))
sleep 1
done
curl --connect-timeout 10 --max-time 30 -v \
-X POST \
-u admin:password \
-H 'Content-Type: application/json' \
-H 'X-Killbill-CreatedBy: GitHub' \
-d '{"apiKey": "bob", "apiSecret": "lazar"}' \
"http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/tenants"
- name: Run tests
env:
DB_ADAPTER: ${{ matrix.database-adapter }}
DB_USER: ${{ matrix.database-user }}
DB_PASSWORD: ${{ matrix.database-password }}
DB_PORT: ${{ matrix.database-port }}
run: |
# DB_URL is for MariaDB (or we get kaui_test database not found)
DB_URL="jdbc:mariadb://localhost:3306" bundle exec rails db:create
bundle exec rails db:migrate
# Some flakiness unfortunately
./bin/retry bundle exec rails t -w -f
- name: Debugging after failure
if: failure()
run: |
echo "[DEBUG] killbill healthcheck"
curl --connect-timeout 10 --max-time 30 -v http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck || true
echo "[DEBUG] hostname"
hostname
echo "[DEBUG] netstat -tulpn"
sudo netstat -tulpn
echo "[DEBUG] docker network ls"
docker network ls
echo "[DEBUG] docker ps -a"
docker ps -a
echo "[DEBUG] killbill env"
docker exec it_killbill_1 env || true
echo "[DEBUG] db env"
docker exec it_db_1 env || true
echo "[DEBUG] killbill logs"
docker logs -t --details it_killbill_1 || true
echo "[DEBUG] db logs"
docker logs -t --details it_db_1 || true
build-war:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up JDK
uses: actions/setup-java@v2.5.0
with:
java-version: '11'
distribution: 'temurin'
#cache: 'maven'
- name: Configure Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 'jruby-9.4.2.0'
bundler-cache: false
- name: Build war
run: |
mvn package