RandomSec/.github/workflows/pull_request.yml
Antonin Delpeuch 3e955b3f73
Migrate from Travis to GitHub Actions (#3378)
* Only keep JRE 8 and 14 in the build matrix.

For #3377.

* Run tests in GitHub Actions on each PR

* Attempt to fix Postgres configuration

* Set explicit password for Postgres on GitHub Actions

* Set explicit password for MySQL and MariaDB

* Fix credentials for postgres and mysql

* Fix duplicate id in GitHub workflow

* Fix creation of test_db on MySQL

* Revert back to GH Action MySQL service

* Populate initial test databases

* Fix syntax of workflow file

* Reorder steps to give more time for MySQL to boot

* Run MySQL database as a service, forward ports to config

* Reformat MySQL options

* Fix YAML syntax

* Add missing 'steps' field

* Fix connection to MySQL and Postgres

* Add back explicit database creation steps

* Force TCP/IP connection for postgres

* Remove explicit creation of test database for postgres

* Fix Postgres and Mariadb configs

* Fix parameter spelling for mariadb

* Display MariaDB test configuration

* Fix more inconsistent parameter names

* Fix more inconsistent parameter names

* Attempt to use Coveralls maven plugin instead of GH action

* Fix workflow file

* Enable submission to coveralls

* Supply coveralls token

* Remove Travis-specific configuration files

* Also update appveyor script after rename of SQL files

* Reintroduce packaging/test_pom.xml used by Appveyor

* Update filenames in appveyor.yml
2020-12-04 08:50:10 +01:00

72 lines
2.2 KiB
YAML

name: Java CI
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
ports:
- 5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 'postgres'
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql:
image: mysql:8
ports:
- 3306
env:
MYSQL_ROOT_PASSWORD: root
options: >-
--health-cmd "mysqladmin ping"
--health-interval 5s
--health-timeout 2s
--health-retries 3
steps:
- uses: actions/checkout@v2.3.4
- name: Restore dependency cache
uses: actions/cache@v2.1.3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Configure connections to databases
id: configure_db_connections
run: cat extensions/database/tests/conf/github_actions_tests.xml | sed -e "s/MYSQL_PORT/${{ job.services.mysql.ports[3306] }}/g" | sed -e "s/POSTGRES_PORT/${{ job.services.postgres.ports[5432] }}/g" > extensions/database/tests/conf/tests.xml
- name: Populate databases with test data
id: populate_databases_with_test_data
run: |
mysql -u root -h 127.0.0.1 -P ${{ job.services.mysql.ports[3306] }} -proot -e 'CREATE DATABASE test_db;'
mysql -u root -h 127.0.0.1 -P ${{ job.services.mysql.ports[3306] }} -proot < extensions/database/tests/conf/test-mysql.sql
psql -U postgres test_db -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} < extensions/database/tests/conf/test-pgsql.sql
env:
PGPASSWORD: postgres
- name: Build and test with Maven
run: mvn jacoco:prepare-agent test
- name: Submit test coverage to Coveralls
run: |
mvn prepare-package -DskipTests=true
mvn jacoco:report coveralls:report -DrepoToken=${{ secrets.COVERALLS_TOKEN }} -DpullRequest=${{ github.event.number }}