From 9f95341e03ef1576ec2edb248274a554d222b8e8 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 09:56:16 +0200 Subject: [PATCH 01/32] ci: testing merged workflow --- .github/workflows/playwright.yml | 41 -------- .github/workflows/pr-playwright-report.yml | 38 -------- .github/workflows/pr-preview-build.yml | 13 --- .github/workflows/pr-preview-deploy.yml | 22 ----- .github/workflows/pr-preview.yml | 105 +++++++++++++++++++++ .github/workflows/pr-storybook-tests.yml | 25 ----- 6 files changed, 105 insertions(+), 139 deletions(-) delete mode 100644 .github/workflows/playwright.yml delete mode 100644 .github/workflows/pr-playwright-report.yml delete mode 100644 .github/workflows/pr-preview-build.yml delete mode 100644 .github/workflows/pr-preview-deploy.yml create mode 100644 .github/workflows/pr-preview.yml delete mode 100644 .github/workflows/pr-storybook-tests.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml deleted file mode 100644 index a6402a74f5..0000000000 --- a/.github/workflows/playwright.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Playwright Tests - -on: - pull_request: - -jobs: - test: - name: Test component - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npm run playwright - env: - CI: 'true' - - name: Upload Playwright playwright report to GitHub Actions Artifacts - if: always() - uses: actions/upload-artifact@v3 - with: - name: playwright-report - path: ./playwright-report - retention-days: 1 - - name: Save PR ID - if: always() - run: | - pr="${{ github.event.pull_request.number }}" - echo $pr > ./pr-id.txt - shell: bash - - name: Create PR Artifact - if: always() - uses: actions/upload-artifact@v3 - with: - name: pr - path: ./pr-id.txt diff --git a/.github/workflows/pr-playwright-report.yml b/.github/workflows/pr-playwright-report.yml deleted file mode 100644 index 03a81dc3a6..0000000000 --- a/.github/workflows/pr-playwright-report.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: PR Playwright Report - -on: - workflow_run: - workflows: ['Playwright Tests'] - types: - - completed - -jobs: - comment: - name: Upload Playwright report to s3 - if: github.event.workflow_run.event == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Download Artifacts - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - run_id: ${{ github.event.workflow_run.id }} - - name: Extract PR Number - id: pr - run: echo "::set-output name=id::$( - github.event.workflow_run.event == 'pull_request' && - github.event.workflow_run.conclusion == 'success' - runs-on: ubuntu-latest - steps: - - uses: gravity-ui/preview-deploy-action@v1 - with: - project: uikit - github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} - s3-key-id: ${{ secrets.STORYBOOK_S3_KEY_ID }} - s3-secret-key: ${{ secrets.STORYBOOK_S3_SECRET_KEY }} diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 0000000000..473cf26f3b --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,105 @@ +name: PR Preview + +on: + pull_request: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: gravity-ui/preview-build-action@v1 + with: + node-version: 18 + deploy: + name: Deploy + needs: build + runs-on: ubuntu-latest + steps: + - uses: gravity-ui/preview-deploy-action@v1 + with: + project: uikit + github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} + s3-key-id: ${{ secrets.STORYBOOK_S3_KEY_ID }} + s3-secret-key: ${{ secrets.STORYBOOK_S3_SECRET_KEY }} + storybook-tests: + name: Storybook Tests + needs: deploy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Storybook Tests + env: + PR_PREVIEW_URL: "https://preview.gravity-ui.com/uikit/${{github.event.pull_request.number}}" + run: npm run test-storybook + playwright-tests: + name: Test component + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npm run playwright + env: + CI: 'true' + - name: Upload Playwright playwright report to GitHub Actions Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: playwright-report + path: ./playwright-report + retention-days: 1 + - name: Save PR ID + if: always() + run: | + pr="${{ github.event.pull_request.number }}" + echo $pr > ./pr-id.txt + shell: bash + - name: Create PR Artifact + if: always() + uses: actions/upload-artifact@v3 + with: + name: pr + path: ./pr-id.txt + playwright-report: + name: Upload Playwright report to s3 + needs: playwright-tests + runs-on: ubuntu-latest + steps: + - name: Download Artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + run_id: ${{ github.event.workflow_run.id }} + - name: Extract PR Number + id: pr + run: echo "::set-output name=id::$( Date: Tue, 23 Apr 2024 10:05:36 +0200 Subject: [PATCH 02/32] Revert "ci: testing merged workflow" This reverts commit 9f95341e03ef1576ec2edb248274a554d222b8e8. --- .github/workflows/playwright.yml | 41 ++++++++ .github/workflows/pr-playwright-report.yml | 38 ++++++++ .github/workflows/pr-preview-build.yml | 13 +++ .github/workflows/pr-preview-deploy.yml | 22 +++++ .github/workflows/pr-preview.yml | 105 --------------------- .github/workflows/pr-storybook-tests.yml | 25 +++++ 6 files changed, 139 insertions(+), 105 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 .github/workflows/pr-playwright-report.yml create mode 100644 .github/workflows/pr-preview-build.yml create mode 100644 .github/workflows/pr-preview-deploy.yml delete mode 100644 .github/workflows/pr-preview.yml create mode 100644 .github/workflows/pr-storybook-tests.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000000..a6402a74f5 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,41 @@ +name: Playwright Tests + +on: + pull_request: + +jobs: + test: + name: Test component + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npm run playwright + env: + CI: 'true' + - name: Upload Playwright playwright report to GitHub Actions Artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: playwright-report + path: ./playwright-report + retention-days: 1 + - name: Save PR ID + if: always() + run: | + pr="${{ github.event.pull_request.number }}" + echo $pr > ./pr-id.txt + shell: bash + - name: Create PR Artifact + if: always() + uses: actions/upload-artifact@v3 + with: + name: pr + path: ./pr-id.txt diff --git a/.github/workflows/pr-playwright-report.yml b/.github/workflows/pr-playwright-report.yml new file mode 100644 index 0000000000..03a81dc3a6 --- /dev/null +++ b/.github/workflows/pr-playwright-report.yml @@ -0,0 +1,38 @@ +name: PR Playwright Report + +on: + workflow_run: + workflows: ['Playwright Tests'] + types: + - completed + +jobs: + comment: + name: Upload Playwright report to s3 + if: github.event.workflow_run.event == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Download Artifacts + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + run_id: ${{ github.event.workflow_run.id }} + - name: Extract PR Number + id: pr + run: echo "::set-output name=id::$( + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + steps: + - uses: gravity-ui/preview-deploy-action@v1 + with: + project: uikit + github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} + s3-key-id: ${{ secrets.STORYBOOK_S3_KEY_ID }} + s3-secret-key: ${{ secrets.STORYBOOK_S3_SECRET_KEY }} diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml deleted file mode 100644 index 473cf26f3b..0000000000 --- a/.github/workflows/pr-preview.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: PR Preview - -on: - pull_request: - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - uses: gravity-ui/preview-build-action@v1 - with: - node-version: 18 - deploy: - name: Deploy - needs: build - runs-on: ubuntu-latest - steps: - - uses: gravity-ui/preview-deploy-action@v1 - with: - project: uikit - github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} - s3-key-id: ${{ secrets.STORYBOOK_S3_KEY_ID }} - s3-secret-key: ${{ secrets.STORYBOOK_S3_SECRET_KEY }} - storybook-tests: - name: Storybook Tests - needs: deploy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Storybook Tests - env: - PR_PREVIEW_URL: "https://preview.gravity-ui.com/uikit/${{github.event.pull_request.number}}" - run: npm run test-storybook - playwright-tests: - name: Test component - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npm run playwright - env: - CI: 'true' - - name: Upload Playwright playwright report to GitHub Actions Artifacts - if: always() - uses: actions/upload-artifact@v3 - with: - name: playwright-report - path: ./playwright-report - retention-days: 1 - - name: Save PR ID - if: always() - run: | - pr="${{ github.event.pull_request.number }}" - echo $pr > ./pr-id.txt - shell: bash - - name: Create PR Artifact - if: always() - uses: actions/upload-artifact@v3 - with: - name: pr - path: ./pr-id.txt - playwright-report: - name: Upload Playwright report to s3 - needs: playwright-tests - runs-on: ubuntu-latest - steps: - - name: Download Artifacts - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - run_id: ${{ github.event.workflow_run.id }} - - name: Extract PR Number - id: pr - run: echo "::set-output name=id::$( Date: Tue, 23 Apr 2024 09:57:17 +0200 Subject: [PATCH 03/32] docs: test comment --- .../ActionTooltip/__stories__/ActionTooltip.stories.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx b/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx index edd23e7e25..8c558bb719 100644 --- a/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx +++ b/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx @@ -12,6 +12,7 @@ export default { }; const DefaultTemplate: StoryFn = (args) => ; +// test comment export const Default = DefaultTemplate.bind({}); From 9c016d5f375740118044c1011ef3554f9833d0b5 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 10:17:12 +0200 Subject: [PATCH 04/32] ci: testing merged workflow --- .../ActionTooltip/__stories__/ActionTooltip.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx b/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx index 8c558bb719..e15125d0bd 100644 --- a/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx +++ b/src/components/ActionTooltip/__stories__/ActionTooltip.stories.tsx @@ -12,7 +12,7 @@ export default { }; const DefaultTemplate: StoryFn = (args) => ; -// test comment +// test comment 2 export const Default = DefaultTemplate.bind({}); From 0aa4cfbfd4cf255443a483e8085fd212a600ac3c Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 10:27:14 +0200 Subject: [PATCH 05/32] ci: testing merged workflow --- .github/workflows/pr-storybook-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-storybook-tests.yml b/.github/workflows/pr-storybook-tests.yml index 7198f7d67a..6bebe014ec 100644 --- a/.github/workflows/pr-storybook-tests.yml +++ b/.github/workflows/pr-storybook-tests.yml @@ -22,4 +22,4 @@ jobs: - name: Storybook Tests env: PR_PREVIEW_URL: "https://preview.gravity-ui.com/uikit/${{github.event.pull_request.number}}" - run: npm run test-storybook + run: exit 0 From 965b73a5e4d3e08860ab7269238e86ce7502cb26 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:11:44 +0200 Subject: [PATCH 06/32] ci: using waiter --- .github/workflows/playwright.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a6402a74f5..c5d92d938d 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -39,3 +39,18 @@ jobs: with: name: pr path: ./pr-id.txt + storybook-tests: + name: Storybook Tests result + runs-on: ubuntu-latest + steps: + - name: Wait for workflow with Storybook Tests + uses: kamilchodola/wait-for-workflow-action@1.1.0 + with: + GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} + workflow_id: 'gravity-ui/uikit/.github/workflows/pr-storybook-tests.yml' + max_wait_minutes: '10' + interval: '1' + timeout: '600' + org_name: 'gravity-ui' + repo_name: 'uikit' + ref: '${{ github.ref }}' From eeb739ae00b36c170192532852225f004611c4e3 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:17:02 +0200 Subject: [PATCH 07/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index c5d92d938d..ce79fa0dc5 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -40,7 +40,7 @@ jobs: name: pr path: ./pr-id.txt storybook-tests: - name: Storybook Tests result + name: Storybook Tests runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests From 55474b62c8a4d622c6f8d6a09b37fb04c2f0397c Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:18:10 +0200 Subject: [PATCH 08/32] ci: using waiter --- .github/workflows/pr-storybook-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-storybook-tests.yml b/.github/workflows/pr-storybook-tests.yml index 6bebe014ec..6fd181d3ca 100644 --- a/.github/workflows/pr-storybook-tests.yml +++ b/.github/workflows/pr-storybook-tests.yml @@ -19,7 +19,7 @@ jobs: run: npm ci - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Storybook Tests + - name: Run Storybook Tests env: PR_PREVIEW_URL: "https://preview.gravity-ui.com/uikit/${{github.event.pull_request.number}}" run: exit 0 From 2c41d7a1d60f7464eb483a1d79b01fcb517b76f3 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:19:22 +0200 Subject: [PATCH 09/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ce79fa0dc5..998d95ea8b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -51,6 +51,6 @@ jobs: max_wait_minutes: '10' interval: '1' timeout: '600' - org_name: 'gravity-ui' + org_name: 'Kyzyl-ool' repo_name: 'uikit' ref: '${{ github.ref }}' From e0b12eef1477ed5fca32760e70fdc51cc2ff859a Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:21:29 +0200 Subject: [PATCH 10/32] ci: using waiter --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 998d95ea8b..e1597331a9 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -47,10 +47,10 @@ jobs: uses: kamilchodola/wait-for-workflow-action@1.1.0 with: GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} - workflow_id: 'gravity-ui/uikit/.github/workflows/pr-storybook-tests.yml' + workflow_id: 'pr-storybook-tests.yml' max_wait_minutes: '10' interval: '1' timeout: '600' - org_name: 'Kyzyl-ool' + org_name: 'gravity-ui' repo_name: 'uikit' ref: '${{ github.ref }}' From 86070164b85a9385cb9b68fe93509d6b85f34aa2 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:28:21 +0200 Subject: [PATCH 11/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e1597331a9..a10f91eea2 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - uses: kamilchodola/wait-for-workflow-action@1.1.0 + uses: kamilchodola/wait-for-workflow-action with: GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} workflow_id: 'pr-storybook-tests.yml' From 95ef33f9a33bd1c94f16f34c788ed3874aeab5cf Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:29:13 +0200 Subject: [PATCH 12/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a10f91eea2..e1597331a9 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - uses: kamilchodola/wait-for-workflow-action + uses: kamilchodola/wait-for-workflow-action@1.1.0 with: GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} workflow_id: 'pr-storybook-tests.yml' From fb76fdecbc789ed263a8dc96333a70edd19e0904 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:35:35 +0200 Subject: [PATCH 13/32] ci: using waiter --- .github/workflows/playwright.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e1597331a9..e8ad7ca3b4 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,13 +44,4 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - uses: kamilchodola/wait-for-workflow-action@1.1.0 - with: - GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }} - workflow_id: 'pr-storybook-tests.yml' - max_wait_minutes: '10' - interval: '1' - timeout: '600' - org_name: 'gravity-ui' - repo_name: 'uikit' - ref: '${{ github.ref }}' + run: curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/gravity-ui/uikit/actions/workflows/pr-storybook-tests.yml/runs" From 95470054112fd5625f8e54ed1c988f276f212df3 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:35:51 +0200 Subject: [PATCH 14/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e8ad7ca3b4..a6ee1b8835 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,4 +44,4 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - run: curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/gravity-ui/uikit/actions/workflows/pr-storybook-tests.yml/runs" + run: 'curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/gravity-ui/uikit/actions/workflows/pr-storybook-tests.yml/runs"' From e00b4c20af32c9b7ab405b6b2cca525bcd389e68 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:44:50 +0200 Subject: [PATCH 15/32] ci: using waiter --- .github/workflows/playwright.yml | 13 ++++- scripts/wait-for-workflow.sh | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100755 scripts/wait-for-workflow.sh diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a6ee1b8835..c043844c84 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,4 +44,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - run: 'curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/gravity-ui/uikit/actions/workflows/pr-storybook-tests.yml/runs"' + run: './scripts/wait-for-workflow.sh' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_ID: 'pr-storybook-tests.yml' + MAX_WAIT_MINUTES: 10 + INTERVAL: 30 + TIMEOUT: 600 + ORG_NAME: gravity-ui + REPO_NAME: uikit + REF: ${{ github.ref }} + + diff --git a/scripts/wait-for-workflow.sh b/scripts/wait-for-workflow.sh new file mode 100755 index 0000000000..b91ffee823 --- /dev/null +++ b/scripts/wait-for-workflow.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +# Set the maximum waiting time (in minutes) and initialize the counter +max_wait_minutes="${MAX_WAIT_MINUTES}" +timeout="${TIMEOUT}" +interval="${INTERVAL}" +counter=0 + +# Get the current time in ISO 8601 format +current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + +# Check if REF has the prefix "refs/heads/" and append it if not +if [[ ! "$REF" =~ ^refs/heads/ ]]; then + REF="refs/heads/$REF" +fi + +echo "ℹ️ Organization: ${ORG_NAME}" +echo "ℹ️ Repository: ${REPO_NAME}" +echo "ℹ️ Reference: $REF" +echo "ℹ️ Maximum wait time: ${max_wait_minutes} minutes" +echo "ℹ️ Timeout for the workflow to complete: ${timeout} minutes" +echo "ℹ️ Interval between checks: ${interval} seconds" + +# If RUN_ID is not empty, use it directly +if [ -n "${RUN_ID}" ]; then + run_id="${RUN_ID}" + echo "ℹ️ Using provided Run ID: $run_id" +else + workflow_id="${WORKFLOW_ID}" # Id of the target workflow + echo "ℹ️ Workflow ID: $workflow_id" + + # Wait for the workflow to be triggered + while true; do + echo "⏳ Waiting for the workflow to be triggered..." + response=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/actions/workflows/${workflow_id}/runs") + if echo "$response" | grep -q "API rate limit exceeded"; then + echo "❌ API rate limit exceeded. Please try again later." + exit 1 + elif echo "$response" | grep -q "Not Found"; then + echo "❌ Invalid input provided (organization, repository, or workflow ID). Please check your inputs." + exit 1 + fi + run_id=$(echo "$response" | \ + jq -r --arg ref "$(echo "$REF" | sed 's/refs\/heads\///')" --arg current_time "$current_time" \ + '.workflow_runs[] | select(.head_branch == $ref and .created_at >= $current_time) | .id') + if [ -n "$run_id" ]; then + echo "🎉 Workflow triggered! Run ID: $run_id" + break + fi + + # Increment the counter and check if the maximum waiting time is reached + counter=$((counter + 1)) + if [ $((counter * $interval)) -ge $((max_wait_minutes * 60)) ]; then + echo "❌ Maximum waiting time for the workflow to be triggered has been reached. Exiting." + exit 1 + fi + + sleep $interval + done +fi + +# Wait for the triggered workflow to complete and check its conclusion +timeout_counter=0 +while true; do + echo "⌛ Waiting for the workflow to complete..." + run_data=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/actions/runs/$run_id") + status=$(echo "$run_data" | jq -r '.status') + + if [ "$status" = "completed" ]; then + conclusion=$(echo "$run_data" | jq -r '.conclusion') + if [ "$conclusion" != "success" ]; then + echo "❌ The workflow has not completed successfully. Exiting." + exit 1 + else + echo "✅ The workflow completed successfully! Exiting." + break + fi + fi + + # Increment the timeout counter and check if the timeout has been reached + timeout_counter=$((timeout_counter + 1)) + if [ $((timeout_counter * interval)) -ge $((timeout * 60)) ]; then + echo "❌ Timeout waiting for the workflow to complete. Exiting." + exit 1 + fi + + sleep $interval +done From 8f221f133d631b7524c3f5bb11d794ae42d1412a Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:45:38 +0200 Subject: [PATCH 16/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index c043844c84..92e5ac589e 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - run: './scripts/wait-for-workflow.sh' + run: 'scripts/wait-for-workflow.sh' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From 48bbc63cc3637d87bc487db70ab877b7ffb676c3 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:46:49 +0200 Subject: [PATCH 17/32] ci: using waiter --- .github/workflows/playwright.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 92e5ac589e..e5c5386e43 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - run: 'scripts/wait-for-workflow.sh' + run: 'wait-for-workflow.sh' + shell: bash + working-directory: ./scripts env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From 6026b3b424f52096b09f07b3b3ad0dc2e9e60445 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:47:29 +0200 Subject: [PATCH 18/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e5c5386e43..d4fe13fa25 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -46,7 +46,7 @@ jobs: - name: Wait for workflow with Storybook Tests run: 'wait-for-workflow.sh' shell: bash - working-directory: ./scripts + working-directory: scripts env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From e6ef1124dca8c2a392da70befa4924241bd11f2f Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:49:37 +0200 Subject: [PATCH 19/32] ci: using waiter --- .github/workflows/playwright.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d4fe13fa25..77197f5c6f 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,9 +44,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - run: 'wait-for-workflow.sh' + run: 'scripts/wait-for-workflow.sh' shell: bash - working-directory: scripts env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From b8dfbdbd0856c03c83d5613e573cf9fb7a624dec Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:50:26 +0200 Subject: [PATCH 20/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 77197f5c6f..a22b5cc220 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Wait for workflow with Storybook Tests - run: 'scripts/wait-for-workflow.sh' + run: '${{ github.action_path }}/scripts/wait-for-workflow.sh' shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ebb63890c7eaa4cb150d764bf25982586b8e95a6 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:53:01 +0200 Subject: [PATCH 21/32] ci: using waiter --- .github/workflows/playwright.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a22b5cc220..1fa6028cc8 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -43,6 +43,10 @@ jobs: name: Storybook Tests runs-on: ubuntu-latest steps: + - name: Test Step + run: 'pwd' + - name: Test Step 2 + run: 'ls' - name: Wait for workflow with Storybook Tests run: '${{ github.action_path }}/scripts/wait-for-workflow.sh' shell: bash From 132b96fe17f85502a0c8afec9ab65acb4efe5fe7 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:53:55 +0200 Subject: [PATCH 22/32] ci: using waiter --- .github/workflows/playwright.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1fa6028cc8..0d8507a5a8 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -46,7 +46,8 @@ jobs: - name: Test Step run: 'pwd' - name: Test Step 2 - run: 'ls' + shell: bash + run: 'ls -l' - name: Wait for workflow with Storybook Tests run: '${{ github.action_path }}/scripts/wait-for-workflow.sh' shell: bash From ec09af0cd0d134e070509faef9c1d77d16e904ef Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:56:05 +0200 Subject: [PATCH 23/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 0d8507a5a8..94b4a5f870 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Test Step - run: 'pwd' + run: 'cd ${{github.workspace}}' - name: Test Step 2 shell: bash run: 'ls -l' From 6365ee5bb5cfec3da5a49c4004b62fb3b67848e6 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:57:08 +0200 Subject: [PATCH 24/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 94b4a5f870..9561c0ae4a 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Test Step - run: 'cd ${{github.workspace}}' + run: 'cd ${{github.action_path}}' - name: Test Step 2 shell: bash run: 'ls -l' From b43d4b3ece1c81df7ff29cc5e230958e75146501 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 11:59:44 +0200 Subject: [PATCH 25/32] ci: using waiter --- .github/workflows/playwright.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 9561c0ae4a..7a6c3b3713 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -43,11 +43,9 @@ jobs: name: Storybook Tests runs-on: ubuntu-latest steps: - - name: Test Step - run: 'cd ${{github.action_path}}' - - name: Test Step 2 + - name: Set execute permissions for script + run: chmod +x ${{ github.action_path }}/scripts/wait-for-workflow.sh shell: bash - run: 'ls -l' - name: Wait for workflow with Storybook Tests run: '${{ github.action_path }}/scripts/wait-for-workflow.sh' shell: bash From b155692bf8dfc9a08343bf2f0b3ae0e23058d0b1 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:01:35 +0200 Subject: [PATCH 26/32] ci: using waiter --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7a6c3b3713..7be6070856 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,10 +44,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Set execute permissions for script - run: chmod +x ${{ github.action_path }}/scripts/wait-for-workflow.sh + run: chmod +x scripts/wait-for-workflow.sh shell: bash - name: Wait for workflow with Storybook Tests - run: '${{ github.action_path }}/scripts/wait-for-workflow.sh' + run: 'scripts/wait-for-workflow.sh' shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 779070624211e6ad830b493ee0b530a80ca0f155 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:02:38 +0200 Subject: [PATCH 27/32] ci: using waiter --- .github/workflows/playwright.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7be6070856..5ad64d5668 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,11 +44,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Set execute permissions for script - run: chmod +x scripts/wait-for-workflow.sh + run: 'chmod +x $GITHUB_WORKSPACE/scripts/wait-for-workflow.sh' shell: bash - name: Wait for workflow with Storybook Tests - run: 'scripts/wait-for-workflow.sh' - shell: bash + run: 'bash $GITHUB_WORKSPACE/scripts/wait-for-workflow.sh' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From 805dced070fb87c50e0c8668f0b6ab2e4608e080 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:03:15 +0200 Subject: [PATCH 28/32] ci: using waiter --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 5ad64d5668..ac9d6f040a 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -44,10 +44,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Set execute permissions for script - run: 'chmod +x $GITHUB_WORKSPACE/scripts/wait-for-workflow.sh' + run: 'chmod +x $GITHUB_WORKSPACE/../scripts/wait-for-workflow.sh' shell: bash - name: Wait for workflow with Storybook Tests - run: 'bash $GITHUB_WORKSPACE/scripts/wait-for-workflow.sh' + run: 'bash $GITHUB_WORKSPACE/../scripts/wait-for-workflow.sh' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From 29baaeed5dc7f7b6a86db0489c4a46adf5595bee Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:04:14 +0200 Subject: [PATCH 29/32] ci: using waiter --- .github/workflows/playwright.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ac9d6f040a..f0549e73e5 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -43,11 +43,10 @@ jobs: name: Storybook Tests runs-on: ubuntu-latest steps: - - name: Set execute permissions for script - run: 'chmod +x $GITHUB_WORKSPACE/../scripts/wait-for-workflow.sh' - shell: bash + - uses: actions/checkout@v3 - name: Wait for workflow with Storybook Tests - run: 'bash $GITHUB_WORKSPACE/../scripts/wait-for-workflow.sh' + run: 'scripts/wait-for-workflow.sh' + shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_ID: 'pr-storybook-tests.yml' From ff6209e05ff1e76cccb200435b030d6f26cde614 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:11:39 +0200 Subject: [PATCH 30/32] ci: using waiter --- scripts/wait-for-workflow.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/wait-for-workflow.sh b/scripts/wait-for-workflow.sh index b91ffee823..761514edf6 100755 --- a/scripts/wait-for-workflow.sh +++ b/scripts/wait-for-workflow.sh @@ -56,6 +56,7 @@ else exit 1 fi + echo $response sleep $interval done fi From a31c7d2eb4a23ddf0261f20a1e2c79d47c90c883 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:12:09 +0200 Subject: [PATCH 31/32] ci: using waiter --- .github/workflows/playwright.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index f0549e73e5..1c0882e09b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -40,7 +40,7 @@ jobs: name: pr path: ./pr-id.txt storybook-tests: - name: Storybook Tests + name: Storybook Tests Wait runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 4671d59c8c0119c1aa2165fe209132f11d302da3 Mon Sep 17 00:00:00 2001 From: Kezhik Kyzyl-ool Date: Tue, 23 Apr 2024 12:17:09 +0200 Subject: [PATCH 32/32] ci: using waiter --- scripts/wait-for-workflow.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/wait-for-workflow.sh b/scripts/wait-for-workflow.sh index 761514edf6..1152f55932 100755 --- a/scripts/wait-for-workflow.sh +++ b/scripts/wait-for-workflow.sh @@ -56,7 +56,7 @@ else exit 1 fi - echo $response + echo $response | jq '.workflow_runs[].head_branch' sleep $interval done fi