Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Bala/Change trigger for lighthouse and smoketest (#5869)
Browse files Browse the repository at this point in the history
* chore: change workflows trigger

* revert: translations auto lint

* chore: remove pat token for adding comments
  • Loading branch information
balakrishna-deriv authored Nov 9, 2023
1 parent 60e8000 commit c6611ad
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 33 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/generate-preview-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,23 @@ jobs:
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout to repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: 'pr-${{ github.event.workflow_run.id }}'
path: .pr

- name: Retrieve pull request
id: pr_information
run: |
echo "issue_number=$(cat ./NR)" > $GITHUB_OUTPUT
echo "issue_number=$(cat .pr/NR)" >> $GITHUB_OUTPUT
- name: 'Generate action link comment'
id: generate_action_url
Expand All @@ -59,7 +64,6 @@ jobs:
- name: Post Cloudflare Pages Preview comment
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
header: Cloudflare Pages Preview Comment
number: ${{steps.pr_information.outputs.issue_number}}
message: ${{steps.generate_action_url.outputs.comment}}
Expand All @@ -72,23 +76,18 @@ jobs:
user=$(cat ./USERNAME)
response=$(curl -s -L \
-w "%{http_code}" \
-o /dev/null -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/binary-com/memberships/$user")
-o /dev/null -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/binary-com/memberships/$user")
if [ $response != "200" ]; then
echo "User is not a member of binary-com organization."
exit 1
else
echo "User is a member of binary-com organization."
echo "Proceeding to build and deploy for the pull request: https://github.com/binary-com/deriv-com/pull/$(cat ./NR)"
fi
- name: Checkout to repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_sha }}

- name: Setup node
uses: actions/setup-node@v2

Expand Down Expand Up @@ -136,15 +135,18 @@ jobs:
projectName='deriv-com-preview-links'
head_branch=${{github.event.workflow_run.head_branch}}
branch=$(echo $head_branch | head -c 20 | sed 's/[\/_\.]/-/g; s/[^a-zA-Z0-9]$/1/')
preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?)
cf_preview_url=$(wrangler pages deploy $directory --project-name=$projectName --branch=$branch > log.txt 2>&1; echo $?)
echo "------"
preview_url=https://$branch.deriv-com-preview-links.pages.dev
cat log.txt
if grep -q "Deployment complete" log.txt; then
echo "preview_url=https://$branch.deriv-com-preview-links.pages.dev" > "$GITHUB_OUTPUT"
echo "preview_url=$preview_url" >> "$GITHUB_OUTPUT"
echo $preview_url > .pr/PREVIEW_URL
else
echo "Deployment to Cloudflare Pages failed."
exit 1
fi
- name: 'Generate preview link comment'
if: success()
id: generate_preview_url
Expand Down Expand Up @@ -184,8 +186,13 @@ jobs:
if: success() || failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
header: Cloudflare Pages Preview Comment
number: ${{steps.pr_information.outputs.issue_number}}
message: ${{steps.generate_preview_url.outputs.comment || steps.generate_failure_comment.outputs.comment }}
recreate: true

- name: Upload PR information to artifact
uses: actions/upload-artifact@v2
with:
name: 'pr-${{github.run_id}}'
path: .pr
31 changes: 22 additions & 9 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,48 @@ permissions:
statuses: write

on:
issue_comment:
types: [created]
workflow_run:
workflows: ['Generate preview link']
types:
- completed

jobs:
generate_lighthouse_audit:
timeout-minutes: 30
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: 'pr-${{ github.event.workflow_run.id }}'
path: pr

- name: Retrieve pull request
id: pr_information
run: |
echo "issue_number=$(cat ./pr/NR)" >> $GITHUB_OUTPUT
echo "preview_url=$(cat ./pr/PREVIEW_URL)" >> $GITHUB_OUTPUT
- name: Add comment to PR
id: loading_comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.issue.number }}
number: ${{ steps.pr_information.outputs.issue_number }}
header: lighthouse
message: |
Running Lighthouse audit...
- name: Capture preview URL
id: capture_preview_url
uses: deriv-com/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: Audit preview URL with Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
${{ steps.capture_preview_url.outputs.url }}
${{ steps.pr_information.outputs.preview_url }}
uploadArtifacts: true
temporaryPublicStorage: true
runs: 5
Expand Down
30 changes: 21 additions & 9 deletions .github/workflows/smoketests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,35 @@ permissions:
statuses: write

on:
issue_comment:
types: [created]
workflow_run:
workflows: ['Generate preview link']
types:
- completed

jobs:
cypress-run:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5]

steps:
- name: Capture preview URL
id: capture_preview_url
uses: deriv-com/[email protected]
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: 'pr-${{ github.event.workflow_run.id }}'
path: pr

- name: Retrieve pull request
id: pr_information
run: |
echo "issue_number=$(cat ./pr/NR)" >> $GITHUB_OUTPUT
echo "preview_url=$(cat ./pr/PREVIEW_URL)" >> $GITHUB_OUTPUT
- name: Checkout external repository with Cypress tests
uses: actions/checkout@v4
Expand All @@ -50,9 +62,9 @@ jobs:
# Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
# Set Base Url from client_payload.
CYPRESS_BASE_URL: ${{ steps.capture_preview_url.outputs.url }}
CYPRESS_BASE_URL: ${{ steps.pr_information.outputs.preview_url }}
# Send PR details to Cypress test run
COMMIT_INFO_MESSAGE: PR "${{ github.event.issue.number }}" in Repo "${{ github.repository }}" (v2)
COMMIT_INFO_MESSAGE: PR "${{ steps.pr_information.outputs.issue_number }}" in Repo "${{ github.repository }}" (v2)

- name: Set comments message
id: set_msg
Expand All @@ -70,6 +82,6 @@ jobs:
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Smoke tests status update
number: ${{ github.event.issue.number }}
number: ${{ steps.pr_information.outputs.issue_number }}
message: '${{ steps.set_msg.outputs.msg }}'
recreate: true

1 comment on commit c6611ad

@vercel
Copy link

@vercel vercel bot commented on c6611ad Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-com – ./

deriv-com-git-master.binary.sx
deriv-com.binary.sx

Please sign in to comment.