Skip to content

Commit af37a93

Browse files
committed
ci: port running of integration tests with PostgreSQL from TravisCI to GitHub Actions
This change also equals PostgreSQL versions between docker compose and CI and hence fixes #1141 Part of #1154
1 parent 5bc4e2d commit af37a93

File tree

5 files changed

+80
-22
lines changed

5 files changed

+80
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Integration Tests (PostgreSQL)
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
8+
permissions:
9+
# NOTE: actions/upload-artifact makes no use of permissions
10+
# See https://github.com/actions/upload-artifact/issues/197#issuecomment-832279436
11+
contents: read # for "git clone"
12+
13+
defaults:
14+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
15+
run:
16+
# Enable fail-fast behavior using set -eo pipefail
17+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
18+
shell: bash
19+
20+
jobs:
21+
run-integration-tests:
22+
name: Integration Tests
23+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
24+
runs-on: ubuntu-20.04
25+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservices
26+
services:
27+
# NB: The hostname of the service container is automatically mapped to the label name
28+
db:
29+
# https://github.com/docker-library/postgres/blob/ad464b0375fc64e70e01305bf93183428a2ef0ec/11/Dockerfile
30+
# NOTE: it's better to have the same as in infra/docker/postgres.yml
31+
image: postgres:11.3
32+
env:
33+
# NOTE: it's better to have credentials the same as in infra/docker/postgres.yml
34+
POSTGRES_USER: mystamps
35+
POSTGRES_PASSWORD: secret
36+
POSTGRES_DATABASE: mystamps
37+
# https://docs.github.com/en/actions/using-containerized-services/about-service-containers#mapping-docker-host-and-service-container-ports
38+
ports:
39+
# <host port>:<container port>
40+
- "5432:5432"
41+
steps:
42+
- name: Clone source code
43+
uses: actions/[email protected] # https://github.com/actions/checkout
44+
with:
45+
# Whether to configure the token or SSH key with the local git config. Default: true
46+
persist-credentials: false
47+
- name: Install JDK
48+
uses: actions/[email protected] # https://github.com/actions/setup-java
49+
with:
50+
distribution: 'adopt' # https://github.com/actions/setup-java#supported-distributions
51+
java-version: '8' # https://github.com/actions/setup-java#supported-version-syntax
52+
cache: 'maven' # https://github.com/actions/setup-java#caching-packages-dependencies
53+
- name: Run integration tests
54+
env:
55+
SPRING_PROFILES_ACTIVE: postgres
56+
run: ./src/main/scripts/execute-command.sh integration-tests
57+
- name: Save RobotFramework reports
58+
if: ${{ failure() }}
59+
uses: actions/[email protected] # https://github.com/actions/upload-artifact
60+
with:
61+
name: robotframework-reports
62+
path: target/robotframework-reports/

.travis.yml

-8
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,24 @@ language: java
44
env:
55
matrix:
66
- SPRING_PROFILES_ACTIVE=travis
7-
- SPRING_PROFILES_ACTIVE=postgres
87
global:
98
- MAVEN_OPTS='-Xss256k'
109
- secure: "fBav56BzY+A+Vs1g9YSfo1oLDCO1rFrXl49lJkOA5/XpnsKEEs4lI2RcOzz0wiJKXFNgcliiAJWoYMI8Esqz+lkyFWan4ij5Co0UzJcytDuY+2o+jaqwx45DuDYPogABzT+hWjLCxQLLG46gUkChzT8kcvOOn6JxC7Ff8q5MnoM="
1110

1211
# travis_terminate is used for getting a fail-fast behavior and don't abort the execution of the Travis scripts.
1312
# See https://travis-ci.community/t/log-are-truncated-when-my-script-exits-abnormally/5878
14-
#
15-
# @todo #1054 Unify PostgreSQL version/configuration between Travis and docker-compose
1613
before_script:
1714
- trap 'travis_terminate 1' ERR;
1815
if [ "$SPRING_PROFILES_ACTIVE" = 'travis' ]; then
1916
mysql -u root -e 'CREATE DATABASE mystamps CHARACTER SET utf8;';
2017
mkdir -p /tmp/uploads /tmp/preview;
2118
cp src/main/resources/test/test.png /tmp/uploads/1.png;
2219
pip install --user ansible==2.9.27;
23-
elif [ "$SPRING_PROFILES_ACTIVE" = 'postgres' ]; then
24-
psql -U postgres -c 'create database mystamps;';
2520
fi
2621

2722
script:
2823
- if [ "$SPRING_PROFILES_ACTIVE" = 'travis' ]; then
2924
./src/main/scripts/ci/check-build-and-verify.sh;
30-
else
31-
./src/main/scripts/ci/check-build-and-verify.sh --only-integration-tests;
3225
fi
3326
# Travis CI may miss a part of the huge output if we'll exit immediately
3427
# See: https://github.com/travis-ci/travis-ci/issues/6018
@@ -69,7 +62,6 @@ cache:
6962

7063
services:
7164
- mysql
72-
- postgresql
7365

7466
branches:
7567
except:

docs/external-dependencies.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# External Dependencies
22

3-
| Component | Production | GitHub Actions | docker-compose |
4-
| ------- | ------------------------ | ---------------------------- | ---------------------------------------- |
5-
| OS | Ubuntu 16.04.07 (Xenial) | Ubuntu 20.04.5 (Focal Fossa) | |
6-
| JDK | OracleJDK 8u151 | Adopt OpenJDK 8u292 | OpenJDK 8u121-jre on Debian 8.11 (Jessy) |
7-
| MySQL | 5.7.27 | | 5.7.20 on Debian 8.11 (Jessy) |
8-
| PostgreSQL | | | 11.3 on Debian 9.13 (Stretch) |
9-
| Python | 2.7.12, 3.5.2 | 3.8.10 | |
10-
| bash | 4.3.14 | | |
11-
| duplicity | 0.7.06 | | |
12-
| maven | | 3.8.6 | |
13-
| ansible | | | |
3+
| Component | Production | GitHub Actions | docker-compose |
4+
| ------- | ------------------------ | ----------------------------- | ---------------------------------------- |
5+
| OS | Ubuntu 16.04.07 (Xenial) | Ubuntu 20.04.5 (Focal Fossa) | |
6+
| JDK | OracleJDK 8u151 | Adopt OpenJDK 8u292 | OpenJDK 8u121-jre on Debian 8.11 (Jessy) |
7+
| MySQL | 5.7.27 | | 5.7.20 on Debian 8.11 (Jessy) |
8+
| PostgreSQL | | 11.3 on Debian 9.13 (Stretch) | 11.3 on Debian 9.13 (Stretch) |
9+
| Python | 2.7.12, 3.5.2 | 3.8.10 | |
10+
| bash | 4.3.14 | | |
11+
| duplicity | 0.7.06 | | |
12+
| maven | | 3.8.6 | |
13+
| ansible | | | |
14+
| Docker API | | 1.41 | |

infra/docker/postgres.yml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ version: '3'
1111
services:
1212
web:
1313
environment:
14+
# NOTE: it's better to have credentials the same as in src/main/resources/application-postgres.properties
1415
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/mystamps
1516
- SPRING_DATASOURCE_USERNAME=mystamps
1617
- SPRING_DATASOURCE_PASSWORD=secret
@@ -26,8 +27,10 @@ services:
2627
- db
2728
db:
2829
# https://github.com/docker-library/postgres/blob/ad464b0375fc64e70e01305bf93183428a2ef0ec/11/Dockerfile
30+
# NOTE: it's better to have the same as in .github/workflows/integration-tests-postgres.yml
2931
image: postgres:11.3
3032
environment:
33+
# NOTE: it's better to have credentials the same as in .github/workflows/integration-tests-postgres.yml
3134
- POSTGRES_USER=mystamps
3235
- POSTGRES_PASSWORD=secret
3336
- POSTGRES_DATABASE=mystamps

src/main/resources/application-postgres.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
spring.profiles: postgres
22

3-
# Details about PostgreSQL configuration on Travis CI: https://docs.travis-ci.com/user/database-setup/#postgresql
3+
# NOTE: it's better to have credentials the same as in infra/docker/postgres.yml
44
spring.datasource.url: jdbc:postgresql://localhost:5432/mystamps
5-
spring.datasource.username: postgres
6-
spring.datasource.password:
5+
spring.datasource.username: mystamps
6+
spring.datasource.password: secret
77
spring.datasource.driver-class-name: org.postgresql.Driver
88
spring.datasource.initialization-mode: NEVER
99

0 commit comments

Comments
 (0)