From 3e955b3f73441bd5f248ef3d8c61ebb0e12f8cb3 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Fri, 4 Dec 2020 08:50:10 +0100 Subject: [PATCH] Migrate from Travis to GitHub Actions (#3378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- .github/workflows/pull_request.yml | 71 ++++++++++++++++ .../{maven.yml => snapshot_release.yml} | 6 +- .travis.yml | 85 ------------------- appveyor.yml | 6 +- .../database/tests/conf/appveyor_tests.xml | 10 +-- .../tests/conf/github_actions_tests.xml | 55 ++++++++++++ .../{travis-mariadb.sql => test-mariadb.sql} | 0 .../conf/{travis-mysql.sql => test-mysql.sql} | 0 .../conf/{travis-pgsql.sql => test-pgsql.sql} | 0 .../{travis-sqlite.sql => test-sqlite.sql} | 0 extensions/database/tests/conf/tests.xml | 10 +-- .../database/tests/conf/travis_tests.xml | 57 ------------- .../database/DatabaseTestConfig.java | 6 +- .../mariadb/MariaDBConnectionManagerTest.java | 2 +- .../mariadb/MariaDBDatabaseServiceTest.java | 2 +- packaging/{travis_pom.xml => test_pom.xml} | 0 16 files changed, 147 insertions(+), 163 deletions(-) create mode 100644 .github/workflows/pull_request.yml rename .github/workflows/{maven.yml => snapshot_release.yml} (97%) delete mode 100644 .travis.yml create mode 100644 extensions/database/tests/conf/github_actions_tests.xml rename extensions/database/tests/conf/{travis-mariadb.sql => test-mariadb.sql} (100%) rename extensions/database/tests/conf/{travis-mysql.sql => test-mysql.sql} (100%) rename extensions/database/tests/conf/{travis-pgsql.sql => test-pgsql.sql} (100%) rename extensions/database/tests/conf/{travis-sqlite.sql => test-sqlite.sql} (100%) delete mode 100644 extensions/database/tests/conf/travis_tests.xml rename packaging/{travis_pom.xml => test_pom.xml} (100%) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..a9509f2a5 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,71 @@ +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 }} diff --git a/.github/workflows/maven.yml b/.github/workflows/snapshot_release.yml similarity index 97% rename from .github/workflows/maven.yml rename to .github/workflows/snapshot_release.yml index ffdb8f251..76eb2972e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/snapshot_release.yml @@ -1,4 +1,4 @@ -name: Java CI +name: Snapshot release on: push: @@ -31,8 +31,8 @@ jobs: - name: Install genisoimage and jq run: sudo apt-get install genisoimage jq - - name: Build with Maven - run: ./refine build + - name: Build and test with Maven + run: ./refine test - name: Get the OpenRefine snapshot version run: echo ::set-env name=OR_VERSION::$(cat ./main/webapp/WEB-INF/classes/git.properties | jq -r '.["git.commit.id.describe"]') diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f5b2f39eb..000000000 --- a/.travis.yml +++ /dev/null @@ -1,85 +0,0 @@ -os: linux -language: java -dist: bionic - -jobs: - include: - - dist: trusty # Fastest build first & for all builds - jdk: oraclejdk8 # Trusty default - # Full matrix only for merges to master or anything to do with release branches e.g. v3.5 - - if: (branch = master AND type != pull_request) OR branch ~= /^v\d\.\d.*/ - jdk: openjdk11 # Bionic default - - if: branch = master AND type != pull_request OR branch ~= /^v\d\.\d.*/ - jdk: openjdk12 - dist: xenial # just for a little variety - - if: branch = master AND type != pull_request OR branch ~= /^v\d\.\d.*/ - jdk: openjdk13 - - if: branch = master AND type != pull_request OR branch ~= /^v\d\.\d.*/ - jdk: openjdk14 # replacement for OS X Java 14 build - - if: branch = master AND type != pull_request OR branch ~= /^v\d\.\d.*/ - os: osx - osx_image: xcode11.6 # macOS 10.15.4, Oracle JDK 14.0.1 - language: java - services: # not supported on os x - addons: - homebrew: - packages: - - mysql - - mariadb@10.3 - before_script: - - brew services start mysql - - brew services start postgresql - - brew services start mariadb@10.3 - - sleep 15 # wait for databases to start up - # Homebrew postgres workaround - create expected user postgres - - /usr/local/opt/postgres/bin/createuser -s postgres - # FIXME this is duplicated from linux config, but don't know a better way to do it - - mysql -u root -e 'CREATE DATABASE test_db;' - - mysql -u root test_db < extensions/database/tests/conf/travis-mysql.sql - - psql -c 'CREATE DATABASE test_db;' -U postgres - - psql -U postgres test_db < extensions/database/tests/conf/travis-pgsql.sql - - cp extensions/database/tests/conf/travis_tests.xml extensions/database/tests/conf/tests.xml - - if: branch = master AND type != pull_request OR branch ~= /^v\d\.\d.*/ - jdk: oraclejdk-ea - - if: branch = master AND type != pull_request OR branch ~= /^v\d\.\d.*/ - jdk: openjdk-ea - allow_failures: - - os: osx - - jdk: openjdk-ea - - jdk: oraclejdk-ea - -addons: - mariadb: '10.3' - -services: - - mysql - - postgresql - -env: - # encrypted Codacy key, see https://docs.travis-ci.com/user/encryption-keys/ - - secure: "VmS4He99YlI6rdmw8Q25OZ9kUp11sRbt0W1QMBvA5lzNSmhN1Q1KtaMj9AGwpCZWcyGWri4AQxEmloARxACxQHXRmNE7ro2DESGw46RAocBAf+RfBxYTifIyUGu5TnSCQhz56SkgpyWpedZAZWyah9ZxgUMfet4KXFUfeiUgYQA=" - -before_install: - # Fake out packaging for Travis builds before mvn install - - cp packaging/travis_pom.xml packaging/pom.xml - - mvn process-resources - -before_script: - # create test databases for mysql, mariadb and postgresql - - mysql -u root -e 'CREATE DATABASE test_db;' - - mysql -u root test_db < extensions/database/tests/conf/travis-mysql.sql - - psql -c 'CREATE DATABASE test_db;' -U postgres - - psql -U postgres test_db < extensions/database/tests/conf/travis-pgsql.sql - - cp extensions/database/tests/conf/travis_tests.xml extensions/database/tests/conf/tests.xml - -script: - - mvn jacoco:prepare-agent test - -after_success: - - mvn prepare-package -DskipTests=true - - mvn jacoco:report coveralls:report - -cache: - directories: - - $HOME/.m2 - diff --git a/appveyor.yml b/appveyor.yml index 4d121e259..cc7c369fb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,7 +26,7 @@ before_test: PATH=C:\Program Files\PostgreSQL\9.6\bin\;C:\Program Files\MySQL\MySQL Server 5.7\bin\;%PATH% SET MYSQL_PWD=Password12! mysql -u root --password=Password12! -e "create database test_db;" - mysql -u root test_db --password=Password12! < extensions\database\tests\conf\travis-mysql.sql + mysql -u root test_db --password=Password12! < extensions\database\tests\conf\test-mysql.sql echo "localhost:*:test_db:postgres:Password12!" > C:\Program Files\PostgreSQL\9.6\pgpass.conf echo "localhost:*:test_db:postgres:Password12!" > pgpass.conf echo "localhost:*:test_db:postgres:Password12!" > %userprofile%\pgpass.conf @@ -34,10 +34,10 @@ before_test: SET PGPASSWORD=Password12! SET PGUSER=postgres createdb test_db - psql -U postgres test_db < extensions\database\tests\conf\travis-pgsql.sql + psql -U postgres test_db < extensions\database\tests\conf\test-pgsql.sql copy extensions\database\tests\conf\appveyor_tests.xml extensions\database\tests\conf\tests.xml - copy packaging\travis_pom.xml packaging\pom.xml + copy packaging\test_pom.xml packaging\pom.xml - cmd: |- mvn process-resources mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V diff --git a/extensions/database/tests/conf/appveyor_tests.xml b/extensions/database/tests/conf/appveyor_tests.xml index c913efbed..ecb767fca 100644 --- a/extensions/database/tests/conf/appveyor_tests.xml +++ b/extensions/database/tests/conf/appveyor_tests.xml @@ -18,12 +18,12 @@ - - + + - - - + + + diff --git a/extensions/database/tests/conf/github_actions_tests.xml b/extensions/database/tests/conf/github_actions_tests.xml new file mode 100644 index 000000000..3e508e567 --- /dev/null +++ b/extensions/database/tests/conf/github_actions_tests.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/database/tests/conf/travis-mariadb.sql b/extensions/database/tests/conf/test-mariadb.sql similarity index 100% rename from extensions/database/tests/conf/travis-mariadb.sql rename to extensions/database/tests/conf/test-mariadb.sql diff --git a/extensions/database/tests/conf/travis-mysql.sql b/extensions/database/tests/conf/test-mysql.sql similarity index 100% rename from extensions/database/tests/conf/travis-mysql.sql rename to extensions/database/tests/conf/test-mysql.sql diff --git a/extensions/database/tests/conf/travis-pgsql.sql b/extensions/database/tests/conf/test-pgsql.sql similarity index 100% rename from extensions/database/tests/conf/travis-pgsql.sql rename to extensions/database/tests/conf/test-pgsql.sql diff --git a/extensions/database/tests/conf/travis-sqlite.sql b/extensions/database/tests/conf/test-sqlite.sql similarity index 100% rename from extensions/database/tests/conf/travis-sqlite.sql rename to extensions/database/tests/conf/test-sqlite.sql diff --git a/extensions/database/tests/conf/tests.xml b/extensions/database/tests/conf/tests.xml index 726ccf615..1bce40929 100644 --- a/extensions/database/tests/conf/tests.xml +++ b/extensions/database/tests/conf/tests.xml @@ -22,12 +22,12 @@ - - + + - - - + + + diff --git a/extensions/database/tests/conf/travis_tests.xml b/extensions/database/tests/conf/travis_tests.xml deleted file mode 100644 index ee5c9c6eb..000000000 --- a/extensions/database/tests/conf/travis_tests.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/extensions/database/tests/src/com/google/refine/extension/database/DatabaseTestConfig.java b/extensions/database/tests/src/com/google/refine/extension/database/DatabaseTestConfig.java index 5f1c3d225..c9c9a46c3 100644 --- a/extensions/database/tests/src/com/google/refine/extension/database/DatabaseTestConfig.java +++ b/extensions/database/tests/src/com/google/refine/extension/database/DatabaseTestConfig.java @@ -21,7 +21,7 @@ public class DatabaseTestConfig extends DBExtensionTests { @BeforeSuite @Parameters({ "mySqlDbName", "mySqlDbHost", "mySqlDbPort", "mySqlDbUser", "mySqlDbPassword", "mySqlTestTable", "pgSqlDbName", "pgSqlDbHost", "pgSqlDbPort", "pgSqlDbUser", "pgSqlDbPassword", "pgSqlTestTable", - "mariadbDbName", "mariadbDbHost", "mariadbDbPort", "mariadbyDbUser", "mariadbDbPassword", "mariadbTestTable", + "mariadbDbName", "mariadbDbHost", "mariadbDbPort", "mariadbDbUser", "mariadbDbPassword", "mariadbTestTable", "sqliteDbName", "sqliteTestTable"}) public void beforeSuite( @Optional(DEFAULT_MYSQL_DB_NAME) String mySqlDbName, @Optional(DEFAULT_MYSQL_HOST) String mySqlDbHost, @@ -33,7 +33,7 @@ public class DatabaseTestConfig extends DBExtensionTests { @Optional(DEFAULT_PGSQL_PASSWORD) String pgSqlDbPassword, @Optional(DEFAULT_TEST_TABLE) String pgSqlTestTable, @Optional(DEFAULT_MARIADB_NAME) String mariadbDbName, @Optional(DEFAULT_MARIADB_HOST) String mariadbDbHost, - @Optional(DEFAULT_MARIADB_PORT) String mariadbDbPort, @Optional(DEFAULT_MARIADB_USER) String mariadbyDbUser, + @Optional(DEFAULT_MARIADB_PORT) String mariadbDbPort, @Optional(DEFAULT_MARIADB_USER) String mariadbDbUser, @Optional(DEFAULT_MARIADB_PASSWORD) String mariadbDbPassword, @Optional(DEFAULT_TEST_TABLE) String mariadbTestTable, @Optional(DEFAULT_SQLITE_DB_NAME) String sqliteDbName, @Optional(DEFAULT_TEST_TABLE) String sqliteTestTable) @@ -64,7 +64,7 @@ public class DatabaseTestConfig extends DBExtensionTests { mariadbDbConfig.setDatabasePassword(mariadbDbPassword); mariadbDbConfig.setDatabasePort(Integer.parseInt(mariadbDbPort)); mariadbDbConfig.setDatabaseType(MariaDBDatabaseService.DB_NAME); - mariadbDbConfig.setDatabaseUser(mariadbyDbUser); + mariadbDbConfig.setDatabaseUser(mariadbDbUser); mariadbDbConfig.setUseSSL(false); sqliteDbConfig = new DatabaseConfiguration(); diff --git a/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBConnectionManagerTest.java b/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBConnectionManagerTest.java index ba1aeb849..b63875abd 100644 --- a/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBConnectionManagerTest.java +++ b/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBConnectionManagerTest.java @@ -24,7 +24,7 @@ public class MariaDBConnectionManagerTest extends DBExtensionTests { @BeforeTest - @Parameters({ "mariaDbName", "mariaDbHost", "mariaDbPort", "mariaDbUser", "mariaDbPassword", "mariaDbTestTable"}) + @Parameters({ "mariadbDbName", "mariadbDbHost", "mariadbDbPort", "mariadbDbUser", "mariadbDbPassword", "mariaTestTable"}) public void beforeTest(@Optional(DEFAULT_MARIADB_NAME) String mariaDbName, @Optional(DEFAULT_MARIADB_HOST) String mariaDbHost, @Optional(DEFAULT_MARIADB_PORT) String mariaDbPort, @Optional(DEFAULT_MARIADB_USER) String mariaDbUser, @Optional(DEFAULT_MARIADB_PASSWORD) String mariaDbPassword, @Optional(DEFAULT_TEST_TABLE) String mariaDbTestTable) { diff --git a/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBDatabaseServiceTest.java b/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBDatabaseServiceTest.java index dc1373401..3debead77 100644 --- a/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBDatabaseServiceTest.java +++ b/extensions/database/tests/src/com/google/refine/extension/database/mariadb/MariaDBDatabaseServiceTest.java @@ -30,7 +30,7 @@ public class MariaDBDatabaseServiceTest extends DBExtensionTests{ @BeforeTest - @Parameters({ "mariaDbName", "mariaDbHost", "mariaDbPort", "mariaDbUser", "mariaDbPassword", "mariaDbTestTable"}) + @Parameters({ "mariadbDbName", "mariadbDbHost", "mariadbDbPort", "mariadbDbUser", "mariadbDbPassword", "mariadbTestTable"}) public void beforeTest(@Optional(DEFAULT_MARIADB_NAME) String mariaDbName, @Optional(DEFAULT_MARIADB_HOST) String mariaDbHost, @Optional(DEFAULT_MARIADB_PORT) String mariaDbPort, @Optional(DEFAULT_MARIADB_USER) String mariaDbUser, @Optional(DEFAULT_MARIADB_PASSWORD) String mariaDbPassword, @Optional(DEFAULT_TEST_TABLE) String mariaDbTestTable) { diff --git a/packaging/travis_pom.xml b/packaging/test_pom.xml similarity index 100% rename from packaging/travis_pom.xml rename to packaging/test_pom.xml