feat(plasma-rsc): Server components #2444
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Этот workflow нельзя запускать параллельно. | |
# Весь смысл именно запуска в одной сессии, что бы избежать сильного разброса в результатах. | |
name: Component Performance Testing | |
on: | |
pull_request: | |
branches: | |
- master | |
pull_request_target: | |
branches: | |
- dev | |
concurrency: | |
# New commit on branch cancels running workflows of the same branch | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
authorize: | |
name: Authorize external pull request | |
uses: ./.github/workflows/authorize-external-pr.yml | |
scope: | |
needs: [authorize] | |
uses: ./.github/workflows/change-detection.yml | |
with: | |
exclude-dependents: true | |
ref: refs/pull/${{github.event.pull_request.number}}/merge | |
secrets: inherit | |
perftest: | |
needs: [authorize, scope] | |
if: ${{ needs.scope.outputs.HAS_SCOPE == 'true' }} | |
runs-on: ubuntu-latest | |
env: | |
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | |
PR_NAME: pr-${{ github.event.number }} | |
steps: | |
- name: Install s3cmd | |
run: pip3 install s3cmd | |
- uses: actions/checkout@v4 | |
with: | |
path: current | |
show-progress: false | |
ref: refs/pull/${{github.event.pull_request.number}}/merge | |
- uses: actions/checkout@v4 | |
with: | |
path: baseline | |
show-progress: false | |
ref: ${{ github.event.pull_request.base.ref }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'current/.nvmrc' | |
cache: 'npm' | |
cache-dependency-path: 'current/package-lock.json' | |
- name: Cache node modules | |
id: node_modules_current | |
uses: actions/cache@v3 | |
with: | |
path: current/node_modules | |
key: node-modules-${{ hashFiles('current/package-lock.json') }} | |
restore-keys: | | |
node-modules-${{ hashFiles('current/package-lock.json') }} | |
node-modules- | |
- name: Cache node modules | |
id: node_modules_base | |
uses: actions/cache/restore@v3 | |
with: | |
path: baseline/node_modules | |
key: node-modules-${{ hashFiles('baseline/package-lock.json') }} | |
restore-keys: | | |
node-modules-${{ hashFiles('baseline/package-lock.json') }} | |
node-modules- | |
- name: Cache dependencies | |
id: cache_deps | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache | |
key: cache-${{ hashFiles('current/package-lock.json') }} | |
restore-keys: | | |
cache-${{ hashFiles('current/package-lock.json') }} | |
cache- | |
- name: Setup packages for PR | |
if: ${{ steps.cache_deps.outputs.cache-hit != 'true' || steps.node_modules_current.outputs.cache-hit != 'true' }} | |
run: | | |
cd current | |
npm ci --no-progress | |
- name: Lerna bootstrap for PR | |
run: | | |
cd current | |
npx lerna bootstrap --scope=@salutejs/plasma-{core,hope,new-hope,web,b2c,asdk,ui,icons} --scope=@salutejs/perftest-helpers | |
- name: Setup packages for ${{ github.event.pull_request.base.ref }} | |
if: ${{ steps.cache_deps.outputs.cache-hit != 'true' || steps.node_modules_base.outputs.cache-hit != 'true' }} | |
run: | | |
cd baseline | |
npm ci --no-progress | |
- name: Lerna bootstrap for ${{ github.event.pull_request.base.ref }} | |
run: | | |
cd baseline | |
npx lerna bootstrap --scope=@salutejs/plasma-{core,hope,new-hope,web,b2c,asdk,ui,icons} --scope=@salutejs/perftest-helpers | |
- name: Restore perftool cache | |
run: > | |
s3cmd | |
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }} | |
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
--host ${{ secrets.AWS_ENDPOINT }} | |
--host-bucket ${{ secrets.AWS_ENDPOINT }} | |
--bucket-location ${{ secrets.AWS_REGION }} | |
--signature-v2 | |
--no-mime-magic | |
--no-preserve | |
sync | |
s3://${{ secrets.AWS_S3_BUCKET_2 }}/perftool-cache/ | |
./current/.perftool/cache/ | |
- name: Run performance test | |
run: | | |
cd current | |
npx perftool --baselineRefDir ../baseline -o perftest/pr-result.json --baselineOutputPath perftest/base-result.json --compareOutputPath perftest/comparison.json --baseBranchRef ${{ github.event.pull_request.base.sha }} --currentBranchRef ${{ github.event.pull_request.head.sha }} | |
- name: Save perftool cache | |
run: > | |
s3cmd | |
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }} | |
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
--host ${{ secrets.AWS_ENDPOINT }} | |
--host-bucket ${{ secrets.AWS_ENDPOINT }} | |
--bucket-location ${{ secrets.AWS_REGION }} | |
--signature-v2 | |
--no-mime-magic | |
--no-preserve | |
sync | |
./current/.perftool/cache/ | |
s3://${{ secrets.AWS_S3_BUCKET_2 }}/perftool-cache/ | |
- name: Save comparison result | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Component performance comparison result | |
path: ${{ github.workspace }}/current/perftest/*.json | |
- name: Write report comment | |
if: always() | |
uses: ./current/actions/perftest-helpers/actions/write-comment | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
reportPath: ${{ github.workspace }}/current/perftest/comparison.json | |
prId: ${{ github.event.number }} | |
owner: ${{ github.repository_owner }} | |
repo: plasma | |
- name: Send report | |
if: always() | |
uses: ./current/actions/perftest-helpers/actions/send-report | |
with: | |
reportPath: ${{ github.workspace }}/current/perftest/comparison.json | |
commitHash: ${{ github.sha }} | |
subject: packages/plasma | |
referrer: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |