Skip to content

Commit

Permalink
Move GIT credentials to Organization level (#954)
Browse files Browse the repository at this point in the history
- replaced project_id to organization_id in table git
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
nulls authored Jul 25, 2022
1 parent 688579b commit 490fb3e
Show file tree
Hide file tree
Showing 38 changed files with 1,588 additions and 886 deletions.
18 changes: 18 additions & 0 deletions db/v-1/insert-test-data/execution-insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@
<column name="sdk" value="ubuntu:latest" />
<column name="additional_files" value="null" />
</insert>
<insert dbms="mysql" tableName="execution">
<column name="id" value="5" />
<column name="project_id" value="2" />
<column name="start_time" value="2021-01-01 00:00:00" />
<column name="end_time" value="2021-02-01 00:00:00" />
<column name="status" value="RUNNING" />
<column name="test_suite_ids" value="11" />
<column name="resources_root_path" value="resources_root_path" />
<column name="batch_size" value="20" />
<column name="type" value="STANDARD" />
<column name="version" value="0.0.1" />
<column name="running_tests" value="0" />
<column name="passed_tests" value="0" />
<column name="failed_tests" value="0" />
<column name="skipped_tests" value="0" />
<column name="sdk" value="ubuntu:latest" />
<column name="additional_files" value="null" />
</insert>
</changeSet>

</databaseChangeLog>
1 change: 1 addition & 0 deletions db/v-2/insert-test-data/db.changelog-insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<include file="contest-insert.xml" relativeToChangelogFile="true"/>
<include file="lnk-contest-project-insert.xml" relativeToChangelogFile="true"/>
<include file="lnk-contest-execution-insert.xml" relativeToChangelogFile="true"/>
<include file="git-insert.xml" relativeToChangelogFile="true"/>

<changeSet id="02-petertrr" author="petertrr">
<tagDatabase tag="v2.0-insert"/>
Expand Down
13 changes: 13 additions & 0 deletions db/v-2/insert-test-data/git-insert.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet id="organization_id-old-project" author="nulls" context="dev">
<update dbms="mysql" tableName="git">
<column name="organization_id" value="1"/>
<where>id = 1 OR id = 2</where>
</update>
</changeSet>
</databaseChangeLog>
13 changes: 13 additions & 0 deletions db/v-2/insert-test-data/test-suite-insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,18 @@
<column name="language" value="C++"/>
<column name="tags" value="security,NPE,hardcode"/>
</insert>

<insert dbms="mysql" tableName="test_suite">
<column name="id" value="11" />
<column name="name" value="test" />
<column name="type" value="STANDARD" />
<column name="project_id" value="2" />
<column name="date_added" value="2021-01-01 00:00:00"/>
<column name="test_root_path" value=""/>
<column name="description" value="description"/>
<column name="test_suite_repo_url" value="https://github.com/saveourtool/save-cloud"/>
<column name="language" value="Java"/>
<column name="tags" value="NPE,security"/>
</insert>
</changeSet>
</databaseChangeLog>
20 changes: 20 additions & 0 deletions db/v-2/tables/git.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,24 @@
<addUniqueConstraint tableName="git" columnNames="project_id" constraintName="uq_project_id"/>
</changeSet>

<changeSet id="move-git-to-organization" author="nulls">
<addColumn tableName="git">
<column name="organization_id" type="bigint" />
</addColumn>
<update tableName="git">
<column name="organization_id" valueComputed="(select organization_id from project where id = project_id)"/>
</update>
<dropForeignKeyConstraint baseTableName="git" constraintName="fk_git_project"/>
<dropUniqueConstraint tableName="git" constraintName="uq_project_id"/>
<dropColumn tableName="git">
<column name="branch"/>
<column name="project_id"/>
</dropColumn>
<addForeignKeyConstraint baseTableName="git" baseColumnNames="organization_id"
constraintName="fk_git_organization"
referencedTableName="organization"
referencedColumnNames="id"/>
<addUniqueConstraint tableName="git" columnNames="organization_id,url" constraintName="uq_git_organization_url"/>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ class SaveCloudClient(
url = evaluatedToolProperties.gitUrl,
username = evaluatedToolProperties.gitUserName,
password = evaluatedToolProperties.gitPassword,
branch = evaluatedToolProperties.branch,
hash = evaluatedToolProperties.commitHash
)

// executionId will be calculated at the server side
Expand All @@ -126,6 +124,7 @@ class SaveCloudClient(
return ExecutionRequest(
project = project,
gitDto = gitDto,
branchOrCommit = evaluatedToolProperties.branch ?: evaluatedToolProperties.commitHash,
testRootPath = evaluatedToolProperties.testRootPath,
sdk = evaluatedToolProperties.sdk.toSdk(),
executionId = executionId,
Expand Down
Loading

0 comments on commit 490fb3e

Please sign in to comment.