aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-14 13:34:19 +0300
committerGravatar Vitaly Takmazov2022-12-14 16:18:06 +0300
commit560d89cb0285435f0e7c640b3fb67ab1197df808 (patch)
tree2e410bae3b5a4808c3efd16cf2a4875a68212c83
parent0c0ea8897e64461b1cfa9cd86a939b48f0bdd640 (diff)
CI: matrix tests on profile strategy
-rw-r--r--.github/workflows/ci.yml59
-rw-r--r--pom.xml6
-rw-r--r--src/test/java/com/juick/config/DataSourceAutoConfiguration.java50
-rw-r--r--src/test/resources/application-mysql.yml12
-rw-r--r--src/test/resources/application-postgres.yml12
-rw-r--r--src/test/resources/db/specific/mariadb/V1.00__schema.sql (renamed from src/test/resources/schema-mysql.sql)0
-rw-r--r--src/test/resources/db/specific/mariadb/V1.23__data.sql13
-rw-r--r--src/test/resources/db/specific/postgresql/V1.00__schema.sql (renamed from src/test/resources/schema-postgres.sql)9
-rw-r--r--src/test/resources/db/specific/postgresql/V1.23__data.sql13
9 files changed, 84 insertions, 90 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7c9166d9..3e4a1cdf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,29 +3,50 @@ name: Java CI
on:
pull_request:
push:
- branches: master
+ branches: [master]
jobs:
build:
runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ profile: [default, postgres, mysql]
name: OpenJDK
+ services:
+ postgres:
+ image: postgres
+ ports:
+ - 5432:5432
+ env:
+ POSTGRES_DB: juick
+ POSTGRES_USER: juick
+ POSTGRES_PASSWORD: secret
+ options: --health-cmd="pg_isready -U juick" --health-interval=10s --health-retries=3 --health-timeout=5s --health-start-period=15s
+ mysql:
+ image: mariadb
+ ports:
+ - 3306:3306
+ env:
+ MARIADB_DATABASE: juick
+ MARIADB_ROOT_PASSWORD: secret
+ options: --health-cmd="mysqladmin ping" --health-interval=10s --health-retries=3 --health-timeout=5s --health-start-period=15s
steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 19
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: 19
- cache: 'maven'
- - name: Setup Node.JS 18
- uses: actions/setup-node@v3
- with:
- node-version: '18'
- cache: 'npm'
- - run: npm install
- - name: Run tests
- run: mvn package
- - uses: mikepenz/action-junit-report@v2
- with:
- report_paths: '**/target/surefire-reports/TEST-*.xml'
+ - uses: actions/checkout@v2
+ - name: Set up JDK 19
+ uses: actions/setup-java@v3
+ with:
+ distribution: "temurin"
+ java-version: 19
+ cache: "maven"
+ - name: Setup Node.JS 18
+ uses: actions/setup-node@v3
+ with:
+ node-version: "18"
+ cache: "npm"
+ - run: npm install
+ - name: Run tests
+ run: mvn -P${{ matrix.profile }} clean package
+ - uses: mikepenz/action-junit-report@v2
+ with:
+ report_paths: "**/target/surefire-reports/TEST-*.xml"
github_token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/pom.xml b/pom.xml
index 0e0b6f66..46db86f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -266,12 +266,6 @@
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.0</version>
</dependency>
- <dependency>
- <groupId>ch.vorburger.mariaDB4j</groupId>
- <artifactId>mariaDB4j</artifactId>
- <version>2.6.0</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<pluginManagement>
diff --git a/src/test/java/com/juick/config/DataSourceAutoConfiguration.java b/src/test/java/com/juick/config/DataSourceAutoConfiguration.java
deleted file mode 100644
index 1b88d577..00000000
--- a/src/test/java/com/juick/config/DataSourceAutoConfiguration.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008-2019, Juick
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package com.juick.config;
-
-import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.jdbc.DataSourceBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
-
-import javax.sql.DataSource;
-
-@Configuration
-@ConfigurationProperties("spring.datasource")
-@ConditionalOnProperty(value = "spring.datasource.platform", havingValue = "mysql")
-public class DataSourceAutoConfiguration {
-
- @Bean
- MariaDB4jSpringService mariaDB4j() {
- return new MariaDB4jSpringService();
- }
-
- @Bean
- @DependsOn("mariaDB4j")
- DataSource dataSource(DataSourceProperties dataSourceProperties) {
- return DataSourceBuilder.create()
- .driverClassName(dataSourceProperties.getDriverClassName())
- .url(dataSourceProperties.getUrl())
- .username(dataSourceProperties.getUsername())
- .password(dataSourceProperties.getPassword())
- .build();
- }
-}
diff --git a/src/test/resources/application-mysql.yml b/src/test/resources/application-mysql.yml
index 2203714f..e55a292f 100644
--- a/src/test/resources/application-mysql.yml
+++ b/src/test/resources/application-mysql.yml
@@ -1,13 +1,13 @@
spring:
datasource:
- platform: mysql
- initialization-mode: always
driver-class-name: org.mariadb.jdbc.Driver
- url: jdbc:mariadb://localhost:${mariaDB4j.port}/test?zeroDateTimeBehavior=convertToNull&useMysqlMetadata=true
+ url: jdbc:mariadb://localhost:3306/juick?zeroDateTimeBehavior=convertToNull
username: root
- password:
+ password: secret
flyway:
baseline-on-migrate: true
+ sql:
+ init:
+ platform: mysql
+ mode: always
-mariaDB4j:
- port: 3307 \ No newline at end of file
diff --git a/src/test/resources/application-postgres.yml b/src/test/resources/application-postgres.yml
new file mode 100644
index 00000000..b75b1e50
--- /dev/null
+++ b/src/test/resources/application-postgres.yml
@@ -0,0 +1,12 @@
+spring:
+ datasource:
+ url: jdbc:postgresql://localhost:5432/juick?stringtype=unspecified
+ username: juick
+ password: secret
+ flyway:
+ baseline-on-migrate: true
+ sql:
+ init:
+ platform: postgresql
+ mode: always
+
diff --git a/src/test/resources/schema-mysql.sql b/src/test/resources/db/specific/mariadb/V1.00__schema.sql
index d30cd9f7..d30cd9f7 100644
--- a/src/test/resources/schema-mysql.sql
+++ b/src/test/resources/db/specific/mariadb/V1.00__schema.sql
diff --git a/src/test/resources/db/specific/mariadb/V1.23__data.sql b/src/test/resources/db/specific/mariadb/V1.23__data.sql
new file mode 100644
index 00000000..a5db173a
--- /dev/null
+++ b/src/test/resources/db/specific/mariadb/V1.23__data.sql
@@ -0,0 +1,13 @@
+INSERT INTO users(id, nick, passw) VALUES(0, 'Anonymous', 'password');
+INSERT INTO users(id, nick, passw) VALUES(2, 'juick', 'password');
+INSERT INTO users(id, nick, passw) VALUES(5, 'archive', 'password');
+INSERT INTO tags(tag_id, name) VALUES(2, 'juick');
+ALTER TABLE tags AUTO_INCREMENT = 10;
+ALTER TABLE users AUTO_INCREMENT = 10;
+INSERT INTO reactions (like_id, description) VALUES (1, 'like');
+INSERT INTO reactions (like_id, description) VALUES (2, 'love');
+INSERT INTO reactions (like_id, description) VALUES (3, 'lol');
+INSERT INTO reactions (like_id, description) VALUES (4, 'hmm');
+INSERT INTO reactions (like_id, description) VALUES (5, 'angry');
+INSERT INTO reactions (like_id, description) VALUES (6, 'uhblya');
+INSERT INTO reactions (like_id, description) VALUES (7, 'ugh');
diff --git a/src/test/resources/schema-postgres.sql b/src/test/resources/db/specific/postgresql/V1.00__schema.sql
index 7c4406f0..4909000a 100644
--- a/src/test/resources/schema-postgres.sql
+++ b/src/test/resources/db/specific/postgresql/V1.00__schema.sql
@@ -1500,15 +1500,6 @@ CREATE INDEX idx_29422_message_id ON favorites USING btree (message_id);
CREATE INDEX idx_29422_user_id ON favorites USING btree (user_id);
---
--- Name: public; Type: ACL; Schema: -; Owner: postgres
---
-
-REVOKE ALL ON SCHEMA public FROM PUBLIC;
-REVOKE ALL ON SCHEMA public FROM postgres;
-GRANT ALL ON SCHEMA public TO postgres;
-GRANT ALL ON SCHEMA public TO PUBLIC;
-
--
-- PostgreSQL database dump complete
diff --git a/src/test/resources/db/specific/postgresql/V1.23__data.sql b/src/test/resources/db/specific/postgresql/V1.23__data.sql
new file mode 100644
index 00000000..673b24d2
--- /dev/null
+++ b/src/test/resources/db/specific/postgresql/V1.23__data.sql
@@ -0,0 +1,13 @@
+INSERT INTO users(id, nick, passw) VALUES(0, 'Anonymous', 'password');
+INSERT INTO users(id, nick, passw) VALUES(2, 'juick', 'password');
+INSERT INTO users(id, nick, passw) VALUES(5, 'archive', 'password');
+INSERT INTO tags(tag_id, name) VALUES(2, 'juick');
+alter sequence tags_tag_id_seq restart with 10;
+alter sequence users_id_seq restart with 10;
+INSERT INTO reactions (like_id, description) VALUES (1, 'like');
+INSERT INTO reactions (like_id, description) VALUES (2, 'love');
+INSERT INTO reactions (like_id, description) VALUES (3, 'lol');
+INSERT INTO reactions (like_id, description) VALUES (4, 'hmm');
+INSERT INTO reactions (like_id, description) VALUES (5, 'angry');
+INSERT INTO reactions (like_id, description) VALUES (6, 'uhblya');
+INSERT INTO reactions (like_id, description) VALUES (7, 'ugh');