Skip to content

Instantly share code, notes, and snippets.

@stefanproell
Last active April 24, 2017 15:05
Show Gist options
  • Save stefanproell/53f16cdb4aca27aba1ca3639e5bbed50 to your computer and use it in GitHub Desktop.
Save stefanproell/53f16cdb4aca27aba1ca3639e5bbed50 to your computer and use it in GitHub Desktop.
Use the official Oracle MySQL 5.6 / MySQL 5.7 server version in Circle CI with Environment Variables (or any other fork).
machine:
environment:
# JVM options
_JAVA_OPTIONS: "-Xms512m -Xmx2048m -XX:MaxMetaspaceSize=256M"
TERM: dumb
java:
version: openjdk8
dependencies:
pre:
# Remove the old version
- sudo apt-get remove --purge mysql*
- sudo rm -r /var/lib/mysql
- sudo rm -r /var/log/mysql
- sudo rm -r /etc/mysql
# Obtain the key for the MySQL Ubuntu repository here: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x8C718D3B5072E1F5
- sudo apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 5072E1F5
- sudo bash -c "echo \"deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.6\" | tee -a /etc/apt/sources.list.d/mysql.list"
- sudo apt-get update
# Empty password
- echo "mysql-server mysql-server/root_password password ''" | sudo debconf-set-selections
- echo "mysql-server mysql-server/root_password_again password ''" | sudo debconf-set-selections
- DEBIAN_FRONTEND=noninteractive sudo apt-get install -y mysql-server
# Setup default database user and privs
# The variables are set in the settings page from the build on Circle CI
- echo "CREATE USER '${SPRING_DATASOURCE_USERNAME}'@'localhost'" | mysql -u root
- echo "GRANT ALL PRIVILEGES ON *.* TO '${SPRING_DATASOURCE_USERNAME}'@'localhost' WITH GRANT OPTION" | mysql -u root
- echo "CREATE USER 'circle'@'localhost'" | mysql -u root
- echo "GRANT ALL PRIVILEGES ON *.* TO 'circle'@'localhost' WITH GRANT OPTION" | mysql -u root
- echo "FLUSH PRIVILEGES" | mysql -u root
- echo "CREATE DATABASE circle_test" | mysql -u root
override:
- ./gradlew -q dependencies
database:
override:
- mysql -u ubuntu < ./src/test/resources/schema.sql
test:
override:
- ./gradlew test
post:
# copy the junit report files to the test report dir
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
- find . -type f -regex ".*build/test-results/TEST-.*.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment