Skip to content

Commit

Permalink
ci: refactor workflows (#1629)
Browse files Browse the repository at this point in the history
  • Loading branch information
amje authored Jun 4, 2024
1 parent 6ab7379 commit ee7558a
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 103 deletions.
77 changes: 51 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 20 additions & 20 deletions .github/workflows/main-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
6 changes: 3 additions & 3 deletions .github/workflows/pr-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions .github/workflows/pr-preview-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_run:
workflows: ['PR Preview Build']
types:
- completed
- completed

jobs:
deploy:
Expand All @@ -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 }}
27 changes: 0 additions & 27 deletions .github/workflows/pr-storybook-tests.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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::$(<pr/pr-id.txt)"
shell: bash
- name: Upload
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.STORYBOOK_S3_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.STORYBOOK_S3_SECRET_KEY }}
Expand All @@ -34,5 +33,5 @@ jobs:
with:
GITHUB_TOKEN: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
number: ${{ steps.pr.outputs.id }}
header: playwright test
message: '[Playwright Test Component](https://storage.yandexcloud.net/playwright-reports/uikit/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'
header: visual tests report
message: '[Visual Tests Report](https://storage.yandexcloud.net/playwright-reports/uikit/pulls/${{ steps.pr.outputs.id }}/index.html) is ready.'
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: Playwright Tests
name: PR Visual Tests

on:
pull_request:

jobs:
test:
name: Test component
visual_tests:
name: Visual Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
cache: npm
- name: Install Packages
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
- name: Run Visual Tests
run: npm run playwright
env:
CI: 'true'
- name: Upload Playwright playwright report to GitHub Actions Artifacts
- name: Upload Playwright Report
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: ./playwright-report
Expand All @@ -35,7 +36,7 @@ jobs:
shell: bash
- name: Create PR Artifact
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: pr
path: ./pr-id.txt
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
default-branch: ${{ github.ref_name != 'main' && github.ref_name || null }}
npm-dist-tag: ${{ github.ref_name != 'main' && 'untagged' || 'latest' }}
npm-dist-tag: ${{ github.ref_name != 'main' && 'untagged' || 'latest' }}

0 comments on commit ee7558a

Please sign in to comment.