阿超
>
stream-query多数据库进行CI测试
把时间花费在阅读他人的著述吧,你可借他人辛苦的东西,轻易改善自己。——苏格拉底
最近针对stream-query
,使用github action | 阿超
主要是针对h2
、mysql
、postgresql
各跑一遍对应的脚本和单元测试
配置脚本为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| name: E2E Tests
on: push: branches: - e2e pull_request: branches: - e2e
jobs: test: runs-on: ubuntu-latest
services: mysql: image: mysql:8.0 env: MYSQL_ROOT_PASSWORD: stream-query MYSQL_DATABASE: stream-query ports: - 3306:3306 options: >- --health-cmd="mysqladmin ping -u stream-query --password=stream-query --silent" --health-interval=10s --health-timeout=5s --health-retries=5
postgres: image: postgres env: POSTGRES_DB: stream-query POSTGRES_USER: stream-query POSTGRES_PASSWORD: stream-query ports: - 5432:5432 options: >- --health-cmd="pg_isready -U stream-query" --health-interval=10s --health-timeout=5s --health-retries=5
steps: - uses: actions/checkout@v2
- name: Set up JDK 8 uses: actions/setup-java@v2 with: java-version: '8' distribution: 'temurin'
- name: Cache Maven packages uses: actions/cache@v2 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-m2-
- name: Build with Maven run: mvn -B -X package --file pom.xml
- name: Run H2 Tests (Default) run: mvn -B -X test
- name: Execute MySQL schema and data scripts run: | mysql -h 127.0.0.1 -P 3306 -u root --password=stream-query stream-query < ./stream-plugin/stream-plugin-mybatis-plus/src/test/resources/sql/mysql/schema.sql mysql -h 127.0.0.1 -P 3306 -u root --password=stream-query stream-query < ./stream-plugin/stream-plugin-mybatis-plus/src/test/resources/sql/mysql/data.sql if: success()
- name: Run MySQL Tests run: mvn -B -X test -Dspring.profiles.active=mysql
- name: Execute PostgreSQL schema and data scripts run: | PGPASSWORD=stream-query psql -h localhost -U stream-query -d stream-query -p 5432 -a -f ./stream-plugin/stream-plugin-mybatis-plus/src/test/resources/sql/pgsql/schema.sql PGPASSWORD=stream-query psql -h localhost -U stream-query -d stream-query -p 5432 -a -f ./stream-plugin/stream-plugin-mybatis-plus/src/test/resources/sql/pgsql/data.sql if: success()
- name: Run PostgreSQL Tests run: mvn -B -X test -Dspring.profiles.active=pgsql
|
脚本源码:
https://github.com/dromara/stream-query/blob/main/.github/workflows/maven-publish.yml
除了ci
脚本,还需要配置代码,这里是分别的dsl
和ddl
以及配置文件
执行效果:
[ci] fix pgsql dsl and ddl · dromara/stream-query@6ae46c5 · GitHub