js-data-sql icon indicating copy to clipboard operation
js-data-sql copied to clipboard

Setup CI to test against Postgres

Open techniq opened this issue 9 years ago • 6 comments

Need to configure Circle CI to test not just MySQL but also Postgres (and possibly others)

https://circleci.com/docs/configuration#services

techniq avatar Jan 22 '16 19:01 techniq

https://github.com/js-data/js-data-sql/commit/a10acf585d5515adb5e97c2613664521196e3c54 made the following changes:

  • Allow specifying the database/knex client using DB_CLIENT env variable
  • Switch from a MySQL-specific .sql schema file to using knex migrations, and create npm run migrate-db script
  • Setup docker/docker-compose to easily startup up database instances for testing
    • Updated README to document how environment is setup
    • Tried best to mimic the Circle CI environment, although the official docker MySQL image does not allow setting an empty password (MYSQL_PASSWORD) for a custom user (MYSQL_USER), only for root (MYSQL_ALLOW_EMPTY_PASSWORD=yes). Circle CI uses the user: ubuntu with no password, and the configuration uses this as the default, which requires overriding the user (DB_USER=root) when performing some commands/scripts locally against the docker containers
  • Fixed some tests that expected MySQL backtick escaping or were not escaping reserved Postgres tables/keywords (ex. user)

techniq avatar Jan 25 '16 05:01 techniq

Still need to determine how best to configure Circle CI to run both MySQL and Postgres. Currently the MySQL tests are ran as part of npm run cover. Also need to determine how best to handle npm run test (related to CI, but also for local development for users submitting PRs.

techniq avatar Jan 25 '16 06:01 techniq

I was thinking CircleCi supported setting up a test matrix like Travis, but my first skim of the docs didn't turn anything up

jmdobry avatar Jan 25 '16 06:01 jmdobry

Yeah, I didn't see anything either. Found this hack/workaround - https://github.com/michaelcontento/circleci-matrix

On Mon, Jan 25, 2016, 1:58 AM Jason Dobry [email protected] wrote:

I was thinking CircleCi supported setting up a test matrix like Travis, but my first skim of the docs didn't turn anything up

— Reply to this email directly or view it on GitHub https://github.com/js-data/js-data-sql/issues/59#issuecomment-174420251.

techniq avatar Jan 25 '16 13:01 techniq

Would be nice to run against different versions of Node (0.10, 0.12, 4.x, 5.x) but not sure if it would be overkill to also run all the different databases against all major versions of node (take a while without parallelism).

techniq avatar Jan 25 '16 14:01 techniq

I've got the "Free and Open Source" setting turned on for js-data-sql, which apparently means that it gets 3 additional containers for a total of 4. Perhaps with that the parallelism can be configured to run the tests against different databases, versions of Node.js, etc.

https://circleci.com/docs/parallel-manual-setup

jmdobry avatar Jan 25 '16 17:01 jmdobry