From 23d3cfe7b3327407afbeaec0f5ca09a600587ebd Mon Sep 17 00:00:00 2001 From: akartasov Date: Thu, 14 Jul 2022 16:49:11 +0700 Subject: [PATCH 01/29] build a composite action --- action.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5e7162b..1570a35 100644 --- a/action.yml +++ b/action.yml @@ -62,7 +62,34 @@ inputs: outputs: response: + value: Done description: 'The result of migration checks' + runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + - name: DB migration with DLE + uses: agneum/migration-action@v0.0.13 + + - name: Post comment to PR + if: ${{ github.event_name == 'pull_request' }} + uses: peter-evans/create-or-update-comment@v2 + env: + COMMENT: | + This is a multi-line test comment + - With GitHub **Markdown** :sparkles: + - Created by [postgres-ai/migration-ci-action][1] + + [1]: https://github.com/marketplace/actions/database-lab-realistic-db-testing-in-ci + + ### Summary + | Status | Passed :heavy_check_mark: | + |:---:| --- | + | Session | #872 | + | Project | - | + | DLE version | v3.1.1-15-g1db723b-20220616-0755 | + | Data state at | 2022-06-12 00:00:06 +0000 UTC | + | Duration | 44s| + with: + issue-number: ${{ github.event.pull_request.number }} + body: ${{ env.COMMENT }} From a6b7307002c8e28741ab81107ff70539c720c9f3 Mon Sep 17 00:00:00 2001 From: akartasov Date: Thu, 14 Jul 2022 18:01:38 +0700 Subject: [PATCH 02/29] add a fake step --- action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1570a35..6802c1f 100644 --- a/action.yml +++ b/action.yml @@ -68,8 +68,11 @@ outputs: runs: using: 'composite' steps: - - name: DB migration with DLE - uses: agneum/migration-action@v0.0.13 +# - name: DB migration with DLE +# uses: agneum/migration-action@v0.0.13 + + - run: echo 'DLE checks' + shell: bash - name: Post comment to PR if: ${{ github.event_name == 'pull_request' }} From db65656748d3714e7e2e0118b4ebf23cadfad3ff Mon Sep 17 00:00:00 2001 From: akartasov Date: Fri, 15 Jul 2022 18:51:11 +0700 Subject: [PATCH 03/29] enable checker action and observe fs --- action.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 6802c1f..3850189 100644 --- a/action.yml +++ b/action.yml @@ -68,10 +68,13 @@ outputs: runs: using: 'composite' steps: -# - name: DB migration with DLE -# uses: agneum/migration-action@v0.0.13 + - name: DB migration with DLE + uses: agneum/migration-action@v0.0.13 - - run: echo 'DLE checks' + - run: cat response.json || true + shell: bash + + - run: ls artifacts || true shell: bash - name: Post comment to PR From 8d15ddc690a664d4a35c5efc181e99f9df95d72d Mon Sep 17 00:00:00 2001 From: akartasov Date: Fri, 15 Jul 2022 19:13:59 +0700 Subject: [PATCH 04/29] publish json response --- action.yml | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/action.yml b/action.yml index 3850189..2f9ad4b 100644 --- a/action.yml +++ b/action.yml @@ -74,7 +74,15 @@ runs: - run: cat response.json || true shell: bash - - run: ls artifacts || true + - run: | + echo 'JSON_RESPONSE<> $GITHUB_ENV + echo '```json' >> $GITHUB_ENV + cat response.json || true >> $GITHUB_ENV + echo '```' >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + shell: bash + + - run: ls /artifacts || true shell: bash - name: Post comment to PR @@ -82,20 +90,8 @@ runs: uses: peter-evans/create-or-update-comment@v2 env: COMMENT: | - This is a multi-line test comment - - With GitHub **Markdown** :sparkles: - - Created by [postgres-ai/migration-ci-action][1] - - [1]: https://github.com/marketplace/actions/database-lab-realistic-db-testing-in-ci - ### Summary - | Status | Passed :heavy_check_mark: | - |:---:| --- | - | Session | #872 | - | Project | - | - | DLE version | v3.1.1-15-g1db723b-20220616-0755 | - | Data state at | 2022-06-12 00:00:06 +0000 UTC | - | Duration | 44s| + ${{ env.JSON_RESPONSE }} with: issue-number: ${{ github.event.pull_request.number }} - body: ${{ env.COMMENT }} + body: ${{ env.JSON_RESPONSE }} From 41dc3ac44503032b076ca1727eabb414a515a4dd Mon Sep 17 00:00:00 2001 From: akartasov Date: Fri, 15 Jul 2022 19:17:53 +0700 Subject: [PATCH 05/29] cat response file and use markdown --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 2f9ad4b..0282aaa 100644 --- a/action.yml +++ b/action.yml @@ -77,7 +77,7 @@ runs: - run: | echo 'JSON_RESPONSE<> $GITHUB_ENV echo '```json' >> $GITHUB_ENV - cat response.json || true >> $GITHUB_ENV + cat response.json >> $GITHUB_ENV echo '```' >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash @@ -94,4 +94,4 @@ runs: ${{ env.JSON_RESPONSE }} with: issue-number: ${{ github.event.pull_request.number }} - body: ${{ env.JSON_RESPONSE }} + body: ${{ env.COMMENT }} From 1d2fb0c3f6150c3b1dd7c13b45886da4b37fbbdd Mon Sep 17 00:00:00 2001 From: akartasov Date: Fri, 15 Jul 2022 19:32:19 +0700 Subject: [PATCH 06/29] format response.json --- action.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 0282aaa..9f3db33 100644 --- a/action.yml +++ b/action.yml @@ -75,10 +75,9 @@ runs: shell: bash - run: | + sudo apt install jq echo 'JSON_RESPONSE<> $GITHUB_ENV - echo '```json' >> $GITHUB_ENV - cat response.json >> $GITHUB_ENV - echo '```' >> $GITHUB_ENV + cat response.json | jq >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash @@ -90,8 +89,10 @@ runs: uses: peter-evans/create-or-update-comment@v2 env: COMMENT: | - ### Summary - ${{ env.JSON_RESPONSE }} + ### Summary + ```json + ${{ env.JSON_RESPONSE }} + ``` with: issue-number: ${{ github.event.pull_request.number }} body: ${{ env.COMMENT }} From 9b9fba724cb3745abfeb5e90abbe0cad322ba75e Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 16:31:32 +0700 Subject: [PATCH 07/29] detach core to run Docker step --- action.yml | 3 +- core/Dockerfile | 7 ++++ core/action.yml | 68 +++++++++++++++++++++++++++++++++++ core/entrypoint.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 core/Dockerfile create mode 100644 core/action.yml create mode 100755 core/entrypoint.sh diff --git a/action.yml b/action.yml index 9f3db33..8a62c15 100644 --- a/action.yml +++ b/action.yml @@ -69,13 +69,12 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: agneum/migration-action@v0.0.13 + uses: ./core - run: cat response.json || true shell: bash - run: | - sudo apt install jq echo 'JSON_RESPONSE<> $GITHUB_ENV cat response.json | jq >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV diff --git a/core/Dockerfile b/core/Dockerfile new file mode 100644 index 0000000..63d53fb --- /dev/null +++ b/core/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.13 + +RUN apk add --no-cache curl jq + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/core/action.yml b/core/action.yml new file mode 100644 index 0000000..2714765 --- /dev/null +++ b/core/action.yml @@ -0,0 +1,68 @@ +name: 'Database Lab: realistic DB testing in CI' +branding: + icon: 'database' + color: 'orange' +description: 'Check database migrations with the Database Lab Engine' +inputs: + owner: + description: 'The owner of the repository to check' + required: true + default: ${{ github.repository_owner }} + repo: + description: 'The repo to check' + required: true + default: ${{ github.event.repository.name }} + ref: + description: 'The input represents a ref parameter, which can be a SHA, branch, or tag' + required: true + default: ${{ github.ref }} + pull_request: + description: 'Link to the pull request' + required: false + default: ${{ github.event.pull_request.html_url }} + compare: + description: 'The compare link' + required: false + default: ${{ github.event.compare }} + commit_sha: + description: 'Commit SHA' + required: false + default: ${{ github.event.after }} + author_name: + description: 'Author name' + required: false + default: ${{ github.event.head_commit.author.name }} + commands: + description: 'List of commands to run DB migrations' + required: true + dbname: + description: 'The database that the workflow is running with' + required: false + default: "" + migration_envs: + description: 'List of environment variables that will be set during migrations running' + required: false + download_artifacts: + description: 'Option to download artifacts' + required: false + default: "false" + + observation_interval: + description: 'Observation interval' + required: false + default: "10" + max_lock_duration: + description: 'Max lock duration' + required: false + default: "10" + max_duration: + description: 'Max duration' + required: false + default: "3600" + +outputs: + response: + description: 'The result of CI checks' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/core/entrypoint.sh b/core/entrypoint.sh new file mode 100755 index 0000000..d9cc420 --- /dev/null +++ b/core/entrypoint.sh @@ -0,0 +1,90 @@ +#!/bin/sh -l + +KEEP_CLONE=false + +if [[ "${INPUT_DOWNLOAD_ARTIFACTS}" == "true" ]]; then + KEEP_CLONE=true +fi + +JSON_DATA=$(jq -n -c \ + --arg owner "$INPUT_OWNER" \ + --arg repo "$INPUT_REPO" \ + --arg ref "$INPUT_REF" \ + --arg commands "$INPUT_COMMANDS" \ + --arg db_name "$INPUT_DBNAME" \ + --arg username "$GITHUB_ACTOR" \ + --arg username_full "$INPUT_AUTHOR_NAME" \ + --arg username_link "${GITHUB_SERVER_URL}/$GITHUB_ACTOR" \ + --arg branch "${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}" \ + --arg branch_link "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}" \ + --arg commit "${INPUT_COMMIT_SHA}" \ + --arg commit_link "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${INPUT_COMMIT_SHA}" \ + --arg request_link "${INPUT_PULL_REQUEST}" \ + --arg diff_link "${INPUT_COMPARE}" \ + --arg migration_envs "$INPUT_MIGRATION_ENVS" \ + --arg observation_interval "$INPUT_OBSERVATION_INTERVAL" \ + --arg max_lock_duration "$INPUT_MAX_LOCK_DURATION" \ + --arg max_duration "$INPUT_MAX_DURATION" \ + --argjson keep_clone "$KEEP_CLONE" \ + '{source: {owner: $owner, repo: $repo, ref: $ref, branch: $branch, branch_link: $branch_link, commit: $commit, commit_link: $commit_link, request_link: $request_link, diff_link: $diff_link}, username: $username, username_full: $username_full, username_link: $username_link, db_name: $db_name, commands: $commands | rtrimstr("\n") | split("\n"), migration_envs: $migration_envs | rtrimstr("\n") | split("\n"), observation_config: { observation_interval: $observation_interval|tonumber, max_lock_duration: $max_lock_duration|tonumber, max_duration: $max_duration|tonumber}, keep_clone: $keep_clone}') + +echo $JSON_DATA + +response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ +--header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ +--header 'Content-Type: application/json' \ +--output response.json \ +--data "${JSON_DATA}") + +jq . response.json + +if [[ $response_code -ne 200 ]]; then + echo "Migration status code: ${response_code}" + exit 1 +fi + +status=$(jq -r '.session.result.status' response.json) + +if [[ $status != "passed" ]]; then + echo "Migration status: ${status}" + exit 1 +fi + +echo "::set-output name=response::$(cat response.json)" + +clone_id=$(jq -r '.clone_id' response.json) +session_id=$(jq -r '.session.session_id' response.json) + +if [[ ! $KEEP_CLONE ]]; then + exit 0 +fi + +# Download artifacts +mkdir artifacts + +download_artifacts() { + artifact_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ + --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ + --header 'Content-Type: application/json' \ + --output artifacts/$1) + + if [[ $artifact_code -ne 200 ]]; then + echo "Downloading $1, invalid status code given: ${artifact_code}" + return + fi + + echo "Artifact \"$1\" has been downloaded to the artifacts directory" +} + +cat response.json | jq -c -r '.session.artifacts[]' | while read artifact; do + download_artifacts $artifact $session_id $clone_id +done + +# Stop the running clone +response_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ + --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ + --header 'Content-Type: application/json') + +if [[ $response_code -ne 200 ]]; then + echo "Invalid status code given on destroy clone: ${artifact_code}" +fi From 680de262354b89ee426e6fd6c02f6d05c7d960e2 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 16:44:33 +0700 Subject: [PATCH 08/29] refer to subdir --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8a62c15..2b5dbde 100644 --- a/action.yml +++ b/action.yml @@ -69,7 +69,7 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: ./core + uses: agneum/migration-action/core@composite-action - run: cat response.json || true shell: bash From 0a099ba1bebb5341ec0531cf8d62320981064eed Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 17:00:37 +0700 Subject: [PATCH 09/29] use context --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2b5dbde..c86e12d 100644 --- a/action.yml +++ b/action.yml @@ -69,7 +69,7 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: agneum/migration-action/core@composite-action + uses: ${{ github.action_repository }}core@${{ github.action_ref }} - run: cat response.json || true shell: bash From 7409a09326826462d931d3a5d0bb279da9c4a370 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 17:09:46 +0700 Subject: [PATCH 10/29] run without docker step --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c86e12d..9e3af89 100644 --- a/action.yml +++ b/action.yml @@ -68,8 +68,12 @@ outputs: runs: using: 'composite' steps: + - run: sudo apt install -y curl jq || true + shell: bash + - name: DB migration with DLE - uses: ${{ github.action_repository }}core@${{ github.action_ref }} + run: ${{ github.action_path }}/core/entrypoint.sh + shell: bash - run: cat response.json || true shell: bash From 95c5170b0acf3aefdf5e9f7bd79e6ba956238bd0 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 17:16:22 +0700 Subject: [PATCH 11/29] run sh --- action.yml | 5 +---- core/entrypoint.sh | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 9e3af89..b017e92 100644 --- a/action.yml +++ b/action.yml @@ -68,12 +68,9 @@ outputs: runs: using: 'composite' steps: - - run: sudo apt install -y curl jq || true - shell: bash - - name: DB migration with DLE run: ${{ github.action_path }}/core/entrypoint.sh - shell: bash + shell: sh - run: cat response.json || true shell: bash diff --git a/core/entrypoint.sh b/core/entrypoint.sh index d9cc420..029686a 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -1,5 +1,7 @@ #!/bin/sh -l +echo $INPUT_OWNER + KEEP_CLONE=false if [[ "${INPUT_DOWNLOAD_ARTIFACTS}" == "true" ]]; then From 9f94502d9836952f6ccd4d02f7e627669f51d556 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 17:29:41 +0700 Subject: [PATCH 12/29] pass input values --- action.yml | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b017e92..55a5a19 100644 --- a/action.yml +++ b/action.yml @@ -46,7 +46,6 @@ inputs: description: 'Option to download artifacts' required: false default: "false" - observation_interval: description: 'Observation interval' required: false @@ -71,6 +70,61 @@ runs: - name: DB migration with DLE run: ${{ github.action_path }}/core/entrypoint.sh shell: sh + with: + owner: + description: 'The owner of the repository to check' + required: true + default: ${{ github.repository_owner }} + repo: + description: 'The repo to check' + required: true + default: ${{ github.event.repository.name }} + ref: + description: 'The input represents a ref parameter, which can be a SHA, branch, or tag' + required: true + default: ${{ github.ref }} + pull_request: + description: 'Link to the pull request' + required: false + default: ${{ github.event.pull_request.html_url }} + compare: + description: 'The compare link' + required: false + default: ${{ github.event.compare }} + commit_sha: + description: 'Commit SHA' + required: false + default: ${{ github.event.after }} + author_name: + description: 'Author name' + required: false + default: ${{ github.event.head_commit.author.name }} + commands: + description: 'List of commands to run DB migrations' + required: true + dbname: + description: 'The database that the workflow is running with' + required: false + default: "" + migration_envs: + description: 'List of environment variables that will be set during migrations running' + required: false + download_artifacts: + description: 'Option to download artifacts' + required: false + default: "false" + observation_interval: + description: 'Observation interval' + required: false + default: "10" + max_lock_duration: + description: 'Max lock duration' + required: false + default: "10" + max_duration: + description: 'Max duration' + required: false + default: "3600" - run: cat response.json || true shell: bash From 9f0edf73ac16e6ca6bf1e03b39cb294a82fdf559 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 17:46:08 +0700 Subject: [PATCH 13/29] roll back to Docker --- action.yml | 58 +--------------------------------------------- core/entrypoint.sh | 2 -- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/action.yml b/action.yml index 55a5a19..675c2c0 100644 --- a/action.yml +++ b/action.yml @@ -68,63 +68,7 @@ runs: using: 'composite' steps: - name: DB migration with DLE - run: ${{ github.action_path }}/core/entrypoint.sh - shell: sh - with: - owner: - description: 'The owner of the repository to check' - required: true - default: ${{ github.repository_owner }} - repo: - description: 'The repo to check' - required: true - default: ${{ github.event.repository.name }} - ref: - description: 'The input represents a ref parameter, which can be a SHA, branch, or tag' - required: true - default: ${{ github.ref }} - pull_request: - description: 'Link to the pull request' - required: false - default: ${{ github.event.pull_request.html_url }} - compare: - description: 'The compare link' - required: false - default: ${{ github.event.compare }} - commit_sha: - description: 'Commit SHA' - required: false - default: ${{ github.event.after }} - author_name: - description: 'Author name' - required: false - default: ${{ github.event.head_commit.author.name }} - commands: - description: 'List of commands to run DB migrations' - required: true - dbname: - description: 'The database that the workflow is running with' - required: false - default: "" - migration_envs: - description: 'List of environment variables that will be set during migrations running' - required: false - download_artifacts: - description: 'Option to download artifacts' - required: false - default: "false" - observation_interval: - description: 'Observation interval' - required: false - default: "10" - max_lock_duration: - description: 'Max lock duration' - required: false - default: "10" - max_duration: - description: 'Max duration' - required: false - default: "3600" + uses: agneum/migration-action/core@composite-action - run: cat response.json || true shell: bash diff --git a/core/entrypoint.sh b/core/entrypoint.sh index 029686a..d9cc420 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -1,7 +1,5 @@ #!/bin/sh -l -echo $INPUT_OWNER - KEEP_CLONE=false if [[ "${INPUT_DOWNLOAD_ARTIFACTS}" == "true" ]]; then From 342d2cf216a13b39d5098cb3c84f06e55bfb8c11 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 18:20:24 +0700 Subject: [PATCH 14/29] prepare summary --- action.yml | 12 +++--------- core/entrypoint.sh | 10 ++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 675c2c0..ffd6924 100644 --- a/action.yml +++ b/action.yml @@ -74,8 +74,8 @@ runs: shell: bash - run: | - echo 'JSON_RESPONSE<> $GITHUB_ENV - cat response.json | jq >> $GITHUB_ENV + echo 'SUMMARY<> $GITHUB_ENV + cat summary.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash @@ -85,12 +85,6 @@ runs: - name: Post comment to PR if: ${{ github.event_name == 'pull_request' }} uses: peter-evans/create-or-update-comment@v2 - env: - COMMENT: | - ### Summary - ```json - ${{ env.JSON_RESPONSE }} - ``` with: issue-number: ${{ github.event.pull_request.number }} - body: ${{ env.COMMENT }} + body: ${{ env.SUMMARY }} diff --git a/core/entrypoint.sh b/core/entrypoint.sh index d9cc420..1ea275e 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -38,6 +38,16 @@ response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_ jq . response.json +export JSON_RESPONSE=$(cat response.json | jq) +echo "$(cat<<-EOL +### Summary +\`\`\`json +${JSON_RESPONSE} +\`\`\` +EOL +)" > summary.md + + if [[ $response_code -ne 200 ]]; then echo "Migration status code: ${response_code}" exit 1 From 5ee375d7a21cc57999b5880fcf79af13d37ffd99 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 18:31:33 +0700 Subject: [PATCH 15/29] prepare to PR --- Dockerfile | 7 ---- action.yml | 63 +------------------------------- core/entrypoint.sh | 1 + entrypoint.sh | 90 ---------------------------------------------- 4 files changed, 2 insertions(+), 159 deletions(-) delete mode 100644 Dockerfile delete mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 63d53fb..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM alpine:3.13 - -RUN apk add --no-cache curl jq - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index ffd6924..ecf602d 100644 --- a/action.yml +++ b/action.yml @@ -3,61 +3,6 @@ branding: icon: 'database' color: 'orange' description: 'Check database migrations with the Database Lab Engine' -inputs: - owner: - description: 'The owner of the repository to check' - required: true - default: ${{ github.repository_owner }} - repo: - description: 'The repo to check' - required: true - default: ${{ github.event.repository.name }} - ref: - description: 'The input represents a ref parameter, which can be a SHA, branch, or tag' - required: true - default: ${{ github.ref }} - pull_request: - description: 'Link to the pull request' - required: false - default: ${{ github.event.pull_request.html_url }} - compare: - description: 'The compare link' - required: false - default: ${{ github.event.compare }} - commit_sha: - description: 'Commit SHA' - required: false - default: ${{ github.event.after }} - author_name: - description: 'Author name' - required: false - default: ${{ github.event.head_commit.author.name }} - commands: - description: 'List of commands to run DB migrations' - required: true - dbname: - description: 'The database that the workflow is running with' - required: false - default: "" - migration_envs: - description: 'List of environment variables that will be set during migrations running' - required: false - download_artifacts: - description: 'Option to download artifacts' - required: false - default: "false" - observation_interval: - description: 'Observation interval' - required: false - default: "10" - max_lock_duration: - description: 'Max lock duration' - required: false - default: "10" - max_duration: - description: 'Max duration' - required: false - default: "3600" outputs: response: @@ -68,10 +13,7 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: agneum/migration-action/core@composite-action - - - run: cat response.json || true - shell: bash + uses: postgres-ai/dle-github-actions/core@composite-action - run: | echo 'SUMMARY<> $GITHUB_ENV @@ -79,9 +21,6 @@ runs: echo 'EOF' >> $GITHUB_ENV shell: bash - - run: ls /artifacts || true - shell: bash - - name: Post comment to PR if: ${{ github.event_name == 'pull_request' }} uses: peter-evans/create-or-update-comment@v2 diff --git a/core/entrypoint.sh b/core/entrypoint.sh index 1ea275e..ffd216c 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -38,6 +38,7 @@ response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_ jq . response.json +# TODO: remove after providing summary.md export JSON_RESPONSE=$(cat response.json | jq) echo "$(cat<<-EOL ### Summary diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index e3efcf4..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -l - -KEEP_CLONE=false - -if [[ "${INPUT_DOWNLOAD_ARTIFACTS}" == "true" ]]; then - KEEP_CLONE=true -fi - -JSON_DATA=$(jq -n -c \ - --arg owner "$INPUT_OWNER" \ - --arg repo "$INPUT_REPO" \ - --arg ref "$INPUT_REF" \ - --arg commands "$INPUT_COMMANDS" \ - --arg db_name "$INPUT_DBNAME" \ - --arg username "$GITHUB_ACTOR" \ - --arg username_full "$INPUT_AUTHOR_NAME" \ - --arg username_link "${GITHUB_SERVER_URL}/$GITHUB_ACTOR" \ - --arg branch "${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}" \ - --arg branch_link "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}" \ - --arg commit "${INPUT_COMMIT_SHA}" \ - --arg commit_link "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${INPUT_COMMIT_SHA}" \ - --arg request_link "${INPUT_PULL_REQUEST}" \ - --arg diff_link "${INPUT_COMPARE}" \ - --arg migration_envs "$INPUT_MIGRATION_ENVS" \ - --arg observation_interval "$INPUT_OBSERVATION_INTERVAL" \ - --arg max_lock_duration "$INPUT_MAX_LOCK_DURATION" \ - --arg max_duration "$INPUT_MAX_DURATION" \ - --argjson keep_clone "$KEEP_CLONE" \ - '{source: {owner: $owner, repo: $repo, ref: $ref, branch: $branch, branch_link: $branch_link, commit: $commit, commit_link: $commit_link, request_link: $request_link, diff_link: $diff_link}, username: $username, username_full: $username_full, username_link: $username_link, db_name: $db_name, commands: $commands | rtrimstr("\n") | split("\n"), migration_envs: $migration_envs | rtrimstr("\n") | split("\n"), observation_config: { observation_interval: $observation_interval|tonumber, max_lock_duration: $max_lock_duration|tonumber, max_duration: $max_duration|tonumber}, keep_clone: $keep_clone}') - -echo $JSON_DATA - -response_code=$(curl --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ ---header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ ---header 'Content-Type: application/json' \ ---output response.json \ ---data "${JSON_DATA}") - -jq . response.json - -if [[ $response_code -ne 200 ]]; then - echo "Migration status code: ${response_code}" - exit 1 -fi - -status=$(jq -r '.session.result.status' response.json) - -if [[ $status != "passed" ]]; then - echo "Migration status: ${status}" - exit 1 -fi - -echo "::set-output name=response::$(cat response.json)" - -clone_id=$(jq -r '.clone_id' response.json) -session_id=$(jq -r '.session.session_id' response.json) - -if [[ ! $KEEP_CLONE ]]; then - exit 0 -fi - -# Download artifacts -mkdir artifacts - -download_artifacts() { - artifact_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ - --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ - --header 'Content-Type: application/json' \ - --output artifacts/$1) - - if [[ $artifact_code -ne 200 ]]; then - echo "Downloading $1, invalid status code given: ${artifact_code}" - return - fi - - echo "Artifact \"$1\" has been downloaded to the artifacts directory" -} - -cat response.json | jq -c -r '.session.artifacts[]' | while read artifact; do - download_artifacts $artifact $session_id $clone_id -done - -# Stop the running clone -response_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ - --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ - --header 'Content-Type: application/json') - -if [[ $response_code -ne 200 ]]; then - echo "Invalid status code given on destroy clone: ${artifact_code}" -fi From 7a42c958162254b299fa33d8d7ccd410d86af042 Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 27 Jul 2022 18:35:59 +0700 Subject: [PATCH 16/29] remove insecure curl flag --- core/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/entrypoint.sh b/core/entrypoint.sh index ffd216c..08e9016 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -30,7 +30,7 @@ JSON_DATA=$(jq -n -c \ echo $JSON_DATA -response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ +response_code=$(curl --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json' \ --output response.json \ @@ -74,7 +74,7 @@ fi mkdir artifacts download_artifacts() { - artifact_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ + artifact_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json' \ --output artifacts/$1) From 958744d0fbb2174928dc417673d4c28478647cb1 Mon Sep 17 00:00:00 2001 From: akartasov Date: Thu, 28 Jul 2022 15:59:44 +0700 Subject: [PATCH 17/29] fix: try inputs in composite actions --- action.yml | 33 ++++++++++++++++++++++++++++++++- core/action.yml | 26 -------------------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/action.yml b/action.yml index ecf602d..ff935b5 100644 --- a/action.yml +++ b/action.yml @@ -3,6 +3,34 @@ branding: icon: 'database' color: 'orange' description: 'Check database migrations with the Database Lab Engine' +inputs: + commands: + description: 'List of commands to run DB migrations' + required: true + dbname: + description: 'The database that the workflow is running with' + required: false + default: "" + migration_envs: + description: 'List of environment variables that will be set during migrations running' + required: false + download_artifacts: + description: 'Option to download artifacts' + required: false + default: "false" + + observation_interval: + description: 'Observation interval' + required: false + default: "10" + max_lock_duration: + description: 'Max lock duration' + required: false + default: "10" + max_duration: + description: 'Max duration' + required: false + default: "3600" outputs: response: @@ -13,7 +41,10 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: postgres-ai/dle-github-actions/core@composite-action + uses: agneum/migration-action/core@composite-action + with: + commands: ${{ inputs.commands }} + dbname: ${{ github.inputs.dbname }} - run: | echo 'SUMMARY<> $GITHUB_ENV diff --git a/core/action.yml b/core/action.yml index 2714765..fa811af 100644 --- a/core/action.yml +++ b/core/action.yml @@ -32,33 +32,7 @@ inputs: description: 'Author name' required: false default: ${{ github.event.head_commit.author.name }} - commands: - description: 'List of commands to run DB migrations' - required: true - dbname: - description: 'The database that the workflow is running with' - required: false - default: "" - migration_envs: - description: 'List of environment variables that will be set during migrations running' - required: false - download_artifacts: - description: 'Option to download artifacts' - required: false - default: "false" - observation_interval: - description: 'Observation interval' - required: false - default: "10" - max_lock_duration: - description: 'Max lock duration' - required: false - default: "10" - max_duration: - description: 'Max duration' - required: false - default: "3600" outputs: response: From 6fdfc7fb1ac204c23aefe3341eafa5289ad90e91 Mon Sep 17 00:00:00 2001 From: akartasov Date: Thu, 28 Jul 2022 16:06:49 +0700 Subject: [PATCH 18/29] fix: try inputs in composite actions --- core/action.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/core/action.yml b/core/action.yml index fa811af..d7a10d6 100644 --- a/core/action.yml +++ b/core/action.yml @@ -33,6 +33,34 @@ inputs: required: false default: ${{ github.event.head_commit.author.name }} + commands: + description: 'List of commands to run DB migrations' + required: true + dbname: + description: 'The database that the workflow is running with' + required: false + default: "" + migration_envs: + description: 'List of environment variables that will be set during migrations running' + required: false + download_artifacts: + description: 'Option to download artifacts' + required: false + default: "false" + + observation_interval: + description: 'Observation interval' + required: false + default: "10" + max_lock_duration: + description: 'Max lock duration' + required: false + default: "10" + max_duration: + description: 'Max duration' + required: false + default: "3600" + outputs: response: From ac06e9573e108e4be8e518efc9e71ea6db872ab5 Mon Sep 17 00:00:00 2001 From: akartasov Date: Thu, 28 Jul 2022 16:10:08 +0700 Subject: [PATCH 19/29] fix: try inputs in composite actions --- action.yml | 7 ++++++- core/entrypoint.sh | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index ff935b5..e168762 100644 --- a/action.yml +++ b/action.yml @@ -44,7 +44,12 @@ runs: uses: agneum/migration-action/core@composite-action with: commands: ${{ inputs.commands }} - dbname: ${{ github.inputs.dbname }} + dbname: ${{ inputs.dbname }} + migration_envs: ${{ inputs.migration_envs }} + download_artifacts: ${{ inputs.download_artifacts }} + observation_interval: ${{ inputs.observation_interval }} + max_lock_duration: ${{ inputs.max_lock_duration }} + max_duration: ${{ inputs.max_duration }} - run: | echo 'SUMMARY<> $GITHUB_ENV diff --git a/core/entrypoint.sh b/core/entrypoint.sh index 08e9016..ffd216c 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -30,7 +30,7 @@ JSON_DATA=$(jq -n -c \ echo $JSON_DATA -response_code=$(curl --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ +response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json' \ --output response.json \ @@ -74,7 +74,7 @@ fi mkdir artifacts download_artifacts() { - artifact_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ + artifact_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json' \ --output artifacts/$1) From 09b83dddf0b44d854e3e6628760fbed7095b4abc Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 13:01:17 +0700 Subject: [PATCH 20/29] downloading summary report --- action.yml | 2 +- core/entrypoint.sh | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index e168762..57ae912 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,7 @@ runs: - run: | echo 'SUMMARY<> $GITHUB_ENV - cat summary.md >> $GITHUB_ENV + cat artifacts/report.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash diff --git a/core/entrypoint.sh b/core/entrypoint.sh index ffd216c..ce40f9a 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -54,13 +54,6 @@ if [[ $response_code -ne 200 ]]; then exit 1 fi -status=$(jq -r '.session.result.status' response.json) - -if [[ $status != "passed" ]]; then - echo "Migration status: ${status}" - exit 1 -fi - echo "::set-output name=response::$(cat response.json)" clone_id=$(jq -r '.clone_id' response.json) @@ -91,6 +84,9 @@ cat response.json | jq -c -r '.session.artifacts[]' | while read artifact; do download_artifacts $artifact $session_id $clone_id done +# Download report +download_artifacts 'report.md' $session_id $clone_id + # Stop the running clone response_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ @@ -99,3 +95,10 @@ response_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?cl if [[ $response_code -ne 200 ]]; then echo "Invalid status code given on destroy clone: ${artifact_code}" fi + +status=$(jq -r '.session.result.status' response.json) + +if [[ $status != "passed" ]]; then + echo "Migration status: ${status}" + exit 1 +fi From c10ac2a12d3a978dd866d8b2e8a80ca209c5f70e Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 15:04:42 +0700 Subject: [PATCH 21/29] always run report jobs --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 57ae912..9bdb3d0 100644 --- a/action.yml +++ b/action.yml @@ -56,9 +56,10 @@ runs: cat artifacts/report.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash + if: ${{ always() }} - name: Post comment to PR - if: ${{ github.event_name == 'pull_request' }} + if: ${{ always() && github.event_name == 'pull_request' }} uses: peter-evans/create-or-update-comment@v2 with: issue-number: ${{ github.event.pull_request.number }} From 9aeff6ac62bdc6c7d99ef0a25c446bd503af7ef3 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 15:59:13 +0700 Subject: [PATCH 22/29] debug report.md --- action.yml | 4 +++- core/entrypoint.sh | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 9bdb3d0..9aeec66 100644 --- a/action.yml +++ b/action.yml @@ -52,8 +52,10 @@ runs: max_duration: ${{ inputs.max_duration }} - run: | + pwd + ls echo 'SUMMARY<> $GITHUB_ENV - cat artifacts/report.md >> $GITHUB_ENV + cat "artifacts/report.md" >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash if: ${{ always() }} diff --git a/core/entrypoint.sh b/core/entrypoint.sh index ce40f9a..0979f6a 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -87,13 +87,18 @@ done # Download report download_artifacts 'report.md' $session_id $clone_id +pwd +ls + +cat artifacts/report.md + # Stop the running clone -response_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ +response_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json') if [[ $response_code -ne 200 ]]; then - echo "Invalid status code given on destroy clone: ${artifact_code}" + echo "Invalid status code given on destroy clone: ${response_code}" fi status=$(jq -r '.session.result.status' response.json) From 14b4edda7ccb413624c9bdf443b1ab187de88ff4 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 16:06:07 +0700 Subject: [PATCH 23/29] debug reports --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 9aeec66..b52d70c 100644 --- a/action.yml +++ b/action.yml @@ -55,9 +55,10 @@ runs: pwd ls echo 'SUMMARY<> $GITHUB_ENV - cat "artifacts/report.md" >> $GITHUB_ENV + cat report.md >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV shell: bash + working-directory: artifacts if: ${{ always() }} - name: Post comment to PR From 15625aca7d89347dbe1386802e3a8b597b3e2113 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 16:14:28 +0700 Subject: [PATCH 24/29] reformat env --- action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/action.yml b/action.yml index b52d70c..e6e45d5 100644 --- a/action.yml +++ b/action.yml @@ -52,11 +52,7 @@ runs: max_duration: ${{ inputs.max_duration }} - run: | - pwd - ls - echo 'SUMMARY<> $GITHUB_ENV - cat report.md >> $GITHUB_ENV - echo 'EOF' >> $GITHUB_ENV + echo "SUMMARY=$(cat report.md)" >> $GITHUB_ENV shell: bash working-directory: artifacts if: ${{ always() }} From 65ce348f1fef9f91530234ffae0c4363dc3fd619 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 16:49:28 +0700 Subject: [PATCH 25/29] build comment body --- action.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index e6e45d5..cdb1e53 100644 --- a/action.yml +++ b/action.yml @@ -51,8 +51,13 @@ runs: max_lock_duration: ${{ inputs.max_lock_duration }} max_duration: ${{ inputs.max_duration }} - - run: | - echo "SUMMARY=$(cat report.md)" >> $GITHUB_ENV + - id: comment-body + run: | + body="$(cat report.md)" + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo "::set-output name=body::$body" shell: bash working-directory: artifacts if: ${{ always() }} @@ -62,4 +67,4 @@ runs: uses: peter-evans/create-or-update-comment@v2 with: issue-number: ${{ github.event.pull_request.number }} - body: ${{ env.SUMMARY }} + body: ${{ steps.comment-body.outputs.body }} From e3a41855d19f0ce2c8db946c30bef6f14a249981 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 17:14:14 +0700 Subject: [PATCH 26/29] remove debug outputs --- core/entrypoint.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core/entrypoint.sh b/core/entrypoint.sh index 0979f6a..bc62857 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -38,17 +38,6 @@ response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_ jq . response.json -# TODO: remove after providing summary.md -export JSON_RESPONSE=$(cat response.json | jq) -echo "$(cat<<-EOL -### Summary -\`\`\`json -${JSON_RESPONSE} -\`\`\` -EOL -)" > summary.md - - if [[ $response_code -ne 200 ]]; then echo "Migration status code: ${response_code}" exit 1 @@ -87,11 +76,6 @@ done # Download report download_artifacts 'report.md' $session_id $clone_id -pwd -ls - -cat artifacts/report.md - # Stop the running clone response_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ From 9574d0ec671f1bf029fa39b8143489ed67520517 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 17:33:14 +0700 Subject: [PATCH 27/29] post summary report, fix description, remove debug flags --- action.yml | 4 ++-- core/action.yml | 24 ++++++++++++------------ core/entrypoint.sh | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/action.yml b/action.yml index cdb1e53..3a13cab 100644 --- a/action.yml +++ b/action.yml @@ -2,7 +2,7 @@ name: 'Database Lab: realistic DB testing in CI' branding: icon: 'database' color: 'orange' -description: 'Check database migrations with the Database Lab Engine' +description: 'Test DB migrations using DB branches provided by Database Lab Engine (DLE)' inputs: commands: description: 'List of commands to run DB migrations' @@ -41,7 +41,7 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: agneum/migration-action/core@composite-action + uses: postgres-ai/dle-github-actions/core@composite-action with: commands: ${{ inputs.commands }} dbname: ${{ inputs.dbname }} diff --git a/core/action.yml b/core/action.yml index d7a10d6..b80c595 100644 --- a/core/action.yml +++ b/core/action.yml @@ -5,23 +5,23 @@ branding: description: 'Check database migrations with the Database Lab Engine' inputs: owner: - description: 'The owner of the repository to check' + description: 'Repository owner' required: true default: ${{ github.repository_owner }} repo: - description: 'The repo to check' + description: 'Repository' required: true default: ${{ github.event.repository.name }} ref: - description: 'The input represents a ref parameter, which can be a SHA, branch, or tag' + description: 'Ref (SHA, branch, or tag) that needs to be tested' required: true default: ${{ github.ref }} pull_request: - description: 'Link to the pull request' + description: 'GitHub PR (URL)' required: false default: ${{ github.event.pull_request.html_url }} compare: - description: 'The compare link' + description: 'GitHub PR comparison URL' required: false default: ${{ github.event.compare }} commit_sha: @@ -37,34 +37,34 @@ inputs: description: 'List of commands to run DB migrations' required: true dbname: - description: 'The database that the workflow is running with' + description: 'Database name' required: false default: "" migration_envs: - description: 'List of environment variables that will be set during migrations running' + description: 'List of environment variables that will be set before testing' required: false download_artifacts: - description: 'Option to download artifacts' + description: 'Store artifacts and allow downloading them' required: false default: "false" observation_interval: - description: 'Observation interval' + description: 'Observation interval, seconds (default: 10)' required: false default: "10" max_lock_duration: - description: 'Max lock duration' + description: 'Exclusive lock duration threshold, seconds (default: 10)' required: false default: "10" max_duration: - description: 'Max duration' + description: 'DB migration duration threshold, seconds (default: 3600)' required: false default: "3600" outputs: response: - description: 'The result of CI checks' + description: 'DB migration testing results' runs: using: 'docker' image: 'Dockerfile' diff --git a/core/entrypoint.sh b/core/entrypoint.sh index bc62857..8b3ec9f 100755 --- a/core/entrypoint.sh +++ b/core/entrypoint.sh @@ -30,7 +30,7 @@ JSON_DATA=$(jq -n -c \ echo $JSON_DATA -response_code=$(curl -k --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ +response_code=$(curl --show-error --silent --location --request POST "${DLMC_CI_ENDPOINT}/migration/run" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json' \ --output response.json \ @@ -56,7 +56,7 @@ fi mkdir artifacts download_artifacts() { - artifact_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ + artifact_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/download?artifact_type=$1&session_id=$2&clone_id=$3" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json' \ --output artifacts/$1) @@ -77,7 +77,7 @@ done download_artifacts 'report.md' $session_id $clone_id # Stop the running clone -response_code=$(curl -k --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ +response_code=$(curl --show-error --silent "${DLMC_CI_ENDPOINT}/artifact/stop?clone_id=${clone_id}" --write-out "%{http_code}" \ --header "Verification-Token: ${DLMC_VERIFICATION_TOKEN}" \ --header 'Content-Type: application/json') From 92fd8b977b1716790bc03bb8c59dbe09e33fc381 Mon Sep 17 00:00:00 2001 From: akartasov Date: Tue, 6 Sep 2022 17:54:40 +0700 Subject: [PATCH 28/29] fix action description --- core/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/action.yml b/core/action.yml index b80c595..08dbdfa 100644 --- a/core/action.yml +++ b/core/action.yml @@ -2,7 +2,7 @@ name: 'Database Lab: realistic DB testing in CI' branding: icon: 'database' color: 'orange' -description: 'Check database migrations with the Database Lab Engine' +description: 'Test DB migrations using DB branches provided by Database Lab Engine (DLE)' inputs: owner: description: 'Repository owner' From 43210073246b7cd3334dfd577f8de46d6c646b0f Mon Sep 17 00:00:00 2001 From: akartasov Date: Wed, 7 Sep 2022 16:16:00 +0700 Subject: [PATCH 29/29] change the target branch version --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 3a13cab..0b744ef 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ runs: using: 'composite' steps: - name: DB migration with DLE - uses: postgres-ai/dle-github-actions/core@composite-action + uses: postgres-ai/dle-github-actions/core@master with: commands: ${{ inputs.commands }} dbname: ${{ inputs.dbname }}