diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 1abff81..81fa81b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -3,19 +3,19 @@ name: Java CI with Maven +#only test when push to main or pull_request to main on: - [push] -# push: -# branches: [ main ] -# pull_request: -# branches: [ main ] + push: + branches: [ main ] + pull_request: + branches: [ main ] #Build't job jobs: #Test's job tests: - name: Unit tests + name: Integration tests #Run on Ubuntu using the latest version runs-on: ubuntu-latest @@ -32,6 +32,30 @@ jobs: distribution: 'adopt' cache: maven + - name: Setup MySQL + # You may pin to the exact commit or the version. + # uses: mirromutth/mysql-action@de1fba8b3f90ce8db80f663a7043be3cf3231248 + uses: mirromutth/mysql-action@v1.1 + with: + # The port of host + host port: 3306 + # The port of container + container port: 3306 + # --character-set-server - The character set of MySQL server + character set server: utf8mb4 + # --collation-server - The character collation of MySQL server + collation server: utf8mb4_general_ci + # Version of MySQL to use + mysql version: 8 + # MYSQL_ROOT_PASSWORD - root superuser password + mysql root password: 415623 + # MYSQL_DATABASE - name for the default database that is created + mysql database: testdb + # MYSQL_USER - create the specified user with superuser power for created database + mysql user: root + # MYSQL_PASSWORD - specified superuser password which user is power for created database + mysql password: 415623 + #Run Tests - name: Run Tests run: mvn -B test diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 9d8739a..c5d9d1d 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -1,9 +1,9 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://mydb.mysql.database.azure.com:3306/testdb?reconnect=true - username: yyds - password: comp30022- + url: jdbc:mysql://localhost:3306/testdb + username: root + password: 415623 schema: classpath:db/schema-test.sql data: classpath:db/data-test.sql initialization-mode: always