Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade liquibase version #801

Merged
merged 5 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
fail-fast: false
matrix:
command: [ test-ut-backend-docker, test-ut-room-docker, _test-ut-core ]
command: [ test-init-db-docker, test-ut-backend-docker, test-ut-room-docker, _test-ut-core ]
steps:
- uses: actions/checkout@v3
- name: Running Test
Expand Down
27 changes: 20 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,16 @@ SIKP_INITDB=false

_test_init_db:
@echo "${YELLOW}init-db initializing..${RESET}"
docker compose -f docker-compose.unit-test.yaml run -u $(shell id -u):$(shell id -g) --rm \
-e DB_HOST=test-mysql \
test-initdb
docker compose -f docker-compose.unit-test.yaml build test-init-db
docker compose -f docker-compose.unit-test.yaml run --rm test-init-db
@echo "${GREEN}initialize unit test db completed...${RESET}"

_test_clean: ## clean the docker in test step
docker rm -fv $$(docker ps -a --filter "name=test-.*" --format "{{.ID}}") || true

_test_docker_mysql: ## only run mysql container
docker compose -f docker-compose.unit-test.yaml up -d test-mysql

_test_dockers: ## run depends container in test step
docker compose -f docker-compose.unit-test.yaml up -d test-mysql ;\
docker compose -f docker-compose.unit-test.yaml up -d test-redis ;\
Expand Down Expand Up @@ -211,13 +213,14 @@ _clean_room_coverage:

test-ut-backend-docker:
@echo "$$(docker compose version)"
make _test_clean
docker compose -f docker-compose.ut-backend.yaml up -d
make test-ut-backend
make _test_dockers
sleep 20
make _test_init_db
make test-ut-backend-run
@echo "${GREEN}finished unit test, clean up images...${RESET}"
make _test_clean

test-ut-backend:
test-ut-backend-run:
cd backend-server ;\
DATABASE_TABLE_PREFIX=apitable_ \
MYSQL_HOST=127.0.0.1 \
Expand All @@ -236,6 +239,16 @@ test-ut-backend:

###### 【backend server unit test】 ######

###### 【init-db test】 ######
test-init-db-docker:
@echo "${LIGHTPURPLE}Working dir, $(shell pwd)${RESET}"
@echo "${LIGHTPURPLE}$$(docker compose version)${RESET}"
make _test_clean
make _test_docker_mysql
sleep 20
make _test_init_db
@echo "${GREEN}finished testing, clean up images...${RESET}"

buildpush-docker: ## build all and push all to hub.docker.io registry
echo $$APITABLE_DOCKER_HUB_TOKEN | docker login -u apitable --password-stdin || true;\
$(BUILDER) $(target) --push
Expand Down
13 changes: 5 additions & 8 deletions docker-compose.unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,13 @@ services:
retries: 5
start_period: 5s

test-initdb:
container_name: test-initdb
image: gradle:jdk8
test-init-db:
container_name: test-init-db
networks:
- unit-test
working_dir: /data
volumes:
- ./init-db:/data
build:
context: ./init-db
dockerfile: ./Dockerfile
environment:
- TZ=Asia/Singapore
- ACTION=update
Expand All @@ -85,7 +84,6 @@ services:
- DB_USERNAME=apitable
- DB_PASSWORD=password
- DATABASE_TABLE_PREFIX=apitable_
entrypoint: ./gradlew update

unit-test-room:
container_name: unit-test-room
Expand Down Expand Up @@ -148,7 +146,6 @@ services:
- RABBITMQ_PORT=5672
- RABBITMQ_USERNAME=apitable
- RABBITMQ_PASSWORD=password
entrypoint: ./gradlew testCodeCoverageReport --stacktrace

networks:
unit-test:
Expand Down
72 changes: 0 additions & 72 deletions docker-compose.ut-backend.yaml

This file was deleted.

38 changes: 25 additions & 13 deletions init-db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,34 @@
# 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/>.

FROM liquibase/liquibase:4.8
FROM liquibase/liquibase:4.22.0
RUN lpm add mysql --global
ADD src/main/resources /liquibase/changelog

ARG SEMVER_FULL
ENV SEMVER_FULL=${SEMVER_FULL}

CMD ["sh", "-c", "echo ${ACTION}; docker-entrypoint.sh \
--classpath=/liquibase/changelog \
--changelog-file=${CHANGELOG_FILE:=db/changelog/db.changelog-master.xml} \
--log-level=warning \
--username=${DB_USERNAME} \
--password=${DB_PASSWORD} \
--driver=\"com.mysql.cj.jdbc.Driver\" \
--database-changelog-table-name=\"${DATABASE_TABLE_PREFIX:=apitable_}db_changelog\" \
--database-changelog-lock-table-name=\"${DATABASE_TABLE_PREFIX:=apitable_}db_changelog_lock\" \
--url=\"jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?characterEncoding=utf8&autoReconnect=true&useSSL=true\" \
${ACTION:=update} \
-Dtable.prefix=${DATABASE_TABLE_PREFIX:=apitable_}"]
CMD ["sh", "-c", "echo \"clearChecksums\"; \
docker-entrypoint.sh \
--classpath=/liquibase/changelog \
--changelog-file=${CHANGELOG_FILE:=db/changelog/db.changelog-master.xml} \
--log-level=warning \
--username=${DB_USERNAME} \
--password=${DB_PASSWORD} \
--driver=\"com.mysql.cj.jdbc.Driver\" \
--database-changelog-table-name=\"${DATABASE_TABLE_PREFIX:=apitable_}db_changelog\" \
--database-changelog-lock-table-name=\"${DATABASE_TABLE_PREFIX:=apitable_}db_changelog_lock\" \
--url=\"jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?characterEncoding=utf8&autoReconnect=true&useSSL=true\" \
clearChecksums; \
echo ACTION=${ACTION}; docker-entrypoint.sh \
--classpath=/liquibase/changelog \
--changelog-file=${CHANGELOG_FILE:=db/changelog/db.changelog-master.xml} \
--log-level=warning \
--username=${DB_USERNAME} \
--password=${DB_PASSWORD} \
--driver=\"com.mysql.cj.jdbc.Driver\" \
--database-changelog-table-name=\"${DATABASE_TABLE_PREFIX:=apitable_}db_changelog\" \
--database-changelog-lock-table-name=\"${DATABASE_TABLE_PREFIX:=apitable_}db_changelog_lock\" \
--url=\"jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?characterEncoding=utf8&autoReconnect=true&useSSL=true\" \
${ACTION:=update} \
-Dtable.prefix=${DATABASE_TABLE_PREFIX:=apitable_}"]
14 changes: 8 additions & 6 deletions init-db/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.liquibase.gradle' version "2.0.4"
id 'org.liquibase.gradle' version "2.2.0"
}

repositories {
Expand All @@ -9,7 +9,10 @@ repositories {

dependencies {
liquibaseRuntime 'mysql:mysql-connector-java:8.0.28'
liquibaseRuntime 'org.liquibase:liquibase-core:4.8.0'
liquibaseRuntime 'org.liquibase:liquibase-core:4.22.0'
liquibaseRuntime 'info.picocli:picocli:4.6.1'
liquibaseRuntime "ch.qos.logback:logback-core:1.2.3"
liquibaseRuntime "ch.qos.logback:logback-classic:1.2.3"
}

liquibase {
Expand All @@ -19,13 +22,12 @@ liquibase {
url "jdbc:mysql://${System.getenv("DB_HOST")}:${System.getenv("DB_PORT")}/${System.getenv("DB_NAME")}?characterEncoding=utf8&autoReconnect=true&useSSL=true"
username "${System.getenv("DB_USERNAME")}"
password "${System.getenv("DB_PASSWORD")}"
changeLogFile "src/main/resources/db/changelog/db.changelog-master.xml"
changelogFile "src/main/resources/db/changelog/db.changelog-master.xml"
logLevel "warning"
changeLogParameters(['table.prefix': "${System.getenv("DATABASE_TABLE_PREFIX")}"])
classpath "src/main/resources/"
databaseChangeLogTableName "${System.getenv("DATABASE_TABLE_PREFIX")}db_changelog"
databaseChangeLogLockTableName "${System.getenv("DATABASE_TABLE_PREFIX")}db_changelog_lock"
outputFile "update.sql"
databaseChangelogTableName "${System.getenv("DATABASE_TABLE_PREFIX")}db_changelog"
databaseChangelogLockTableName "${System.getenv("DATABASE_TABLE_PREFIX")}db_changelog_lock"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<changeSet id="V0.13-20220829-004" author="wuyitao" labels="unit">
<comment>Add space role management resource data</comment>
<sql>
BEGIN;
INSERT INTO `${table.prefix}space_resource`(id, group_code, resource_code, resource_name, resource_url, resource_desc, assignable)
VALUES (1560560432907862018, 'MANAGE_ROLE', 'CREATE_ROLE', 'Add Role', NULL, 'Roles with this resource can add role in the directory tree', 1);
INSERT INTO `${table.prefix}space_resource`(id, group_code, resource_code, resource_name, resource_url, resource_desc, assignable)
Expand All @@ -96,11 +95,8 @@
VALUES (1560560432907862027, 'MANAGE_ROLE', 'ADD_ROLE_MEMBER', 'Add role members', NULL, 'Roles with this resource can add members or departments to the role', 1);
INSERT INTO `${table.prefix}space_resource`(id, group_code, resource_code, resource_name, resource_url, resource_desc, assignable)
VALUES (1560560432907862030, 'MANAGE_ROLE', 'REMOVE_ROLE_MEMBER', 'Remove role members', NULL, 'Roles with this resource can remove members or departments from the role', 1);


INSERT INTO `${table.prefix}space_resource_group`(id, group_code, group_name, group_desc)
VALUES (1560560432907862035 , 'MANAGE_ROLE', 'Management role', 'You can add, update, and delete roles');
COMMIT;
</sql>
</changeSet>

Expand Down
Loading