From ee7558a83ef584eaa5fd7aed15175f686a1a20f4 Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Tue, 4 Jun 2024 23:16:55 +0300 Subject: [PATCH] ci: refactor workflows (#1629) --- .github/workflows/ci.yml | 77 ++++++++++++------- .github/workflows/main-preview.yml | 40 +++++----- .github/workflows/pr-preview-build.yml | 6 +- .github/workflows/pr-preview-deploy.yml | 14 ++-- .github/workflows/pr-storybook-tests.yml | 27 ------- ...-report.yml => pr-visual-tests-report.yml} | 17 ++-- .../{playwright.yml => pr-visual-tests.yml} | 21 ++--- .github/workflows/release.yml | 2 +- 8 files changed, 101 insertions(+), 103 deletions(-) delete mode 100644 .github/workflows/pr-storybook-tests.yml rename .github/workflows/{pr-playwright-report.yml => pr-visual-tests-report.yml} (66%) rename .github/workflows/{playwright.yml => pr-visual-tests.yml} (66%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 517c43684c..7ed99cdeda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,32 +10,57 @@ jobs: name: Verify Files runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: npm - - name: Install Packages - run: npm ci - - name: Lint Files - run: npm run lint - - name: Typecheck - run: npm run typecheck + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + - name: Install Packages + run: npm ci + - name: Lint Files + run: npm run lint + - name: Typecheck + run: npm run typecheck - tests: - name: Tests + unit_tests: + name: Unit Tests runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: npm - - name: Install Packages - run: npm ci - - name: Unit Tests - run: npm run test + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + - name: Install Packages + run: npm ci + - name: Run Tests + run: npm run test + + storybook_tests: + name: Storybook Tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + - name: Install Packages + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Build Storybook Static + run: npm run build-storybook + - name: Serve Storybook and Run Tests + run: | + npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ + "npx http-server storybook-static --port 7007 --silent" \ + "npx wait-on $PR_PREVIEW_URL && npm run test-storybook" + env: + PR_PREVIEW_URL: http://127.0.0.1:7007 diff --git a/.github/workflows/main-preview.yml b/.github/workflows/main-preview.yml index 8dce840cbb..6e2d271385 100644 --- a/.github/workflows/main-preview.yml +++ b/.github/workflows/main-preview.yml @@ -9,23 +9,23 @@ jobs: name: Build and Deploy runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: npm - - name: Install Packages - run: npm ci - shell: bash - - name: Build Storybook - run: npx sb build - shell: bash - - name: Upload to S3 - uses: gravity-ui/preview-upload-to-s3-action@v1 - with: - src-path: storybook-static - dest-path: /uikit/main/ - s3-key-id: ${{ secrets.STORYBOOK_S3_KEY_ID }} - s3-secret-key: ${{ secrets.STORYBOOK_S3_SECRET_KEY }} + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: npm + - name: Install Packages + run: npm ci + shell: bash + - name: Build Storybook + run: npx sb build + shell: bash + - name: Upload to S3 + uses: gravity-ui/preview-upload-to-s3-action@v1 + with: + src-path: storybook-static + dest-path: /uikit/main/ + s3-key-id: ${{ secrets.STORYBOOK_S3_KEY_ID }} + s3-secret-key: ${{ secrets.STORYBOOK_S3_SECRET_KEY }} diff --git a/.github/workflows/pr-preview-build.yml b/.github/workflows/pr-preview-build.yml index dff310eee7..c323cc4578 100644 --- a/.github/workflows/pr-preview-build.yml +++ b/.github/workflows/pr-preview-build.yml @@ -8,6 +8,6 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: gravity-ui/preview-build-action@v1 - with: - node-version: 18 + - uses: gravity-ui/preview-build-action@v2 + with: + node-version: 18 diff --git a/.github/workflows/pr-preview-deploy.yml b/.github/workflows/pr-preview-deploy.yml index d3a73b7ecb..84a337f14a 100644 --- a/.github/workflows/pr-preview-deploy.yml +++ b/.github/workflows/pr-preview-deploy.yml @@ -4,7 +4,7 @@ on: workflow_run: workflows: ['PR Preview Build'] types: - - completed + - completed jobs: deploy: @@ -14,9 +14,9 @@ jobs: 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 }} + - uses: gravity-ui/preview-deploy-action@v2 + 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-storybook-tests.yml b/.github/workflows/pr-storybook-tests.yml deleted file mode 100644 index 2b62c692e1..0000000000 --- a/.github/workflows/pr-storybook-tests.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: PR Storybook Tests - -on: - pull_request: - -jobs: - tests: - name: Tests - 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: Build Storybook Static - run: npm run build-storybook - - name: Serve Storybook and run tests - run: | - npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ - "npx http-server storybook-static --port 7007 --silent" \ - "npx wait-on $PR_PREVIEW_URL && npm run test-storybook" - env: - PR_PREVIEW_URL: http://127.0.0.1:7007 diff --git a/.github/workflows/pr-playwright-report.yml b/.github/workflows/pr-visual-tests-report.yml similarity index 66% rename from .github/workflows/pr-playwright-report.yml rename to .github/workflows/pr-visual-tests-report.yml index 03a81dc3a6..a07fe410c4 100644 --- a/.github/workflows/pr-playwright-report.yml +++ b/.github/workflows/pr-visual-tests-report.yml @@ -1,27 +1,26 @@ -name: PR Playwright Report +name: PR Visual Tests Report on: workflow_run: - workflows: ['Playwright Tests'] + workflows: ['PR Visual Tests'] types: - completed jobs: comment: - name: Upload Playwright report to s3 + name: Create GitHub Comment if: github.event.workflow_run.event == 'pull_request' runs-on: ubuntu-latest steps: - name: Download Artifacts - uses: dawidd6/action-download-artifact@v2 + uses: actions/download-artifact@v4 with: - workflow: ${{ github.event.workflow_run.workflow_id }} - run_id: ${{ github.event.workflow_run.id }} + run-id: ${{ github.event.workflow_run.id }} - name: Extract PR Number id: pr run: echo "::set-output name=id::$(