-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci(.github): migrate infra to GHA #33070
Changes from 9 commits
579eb54
fa133c1
2fa5f8f
67910c3
a4bc401
5d556e8
6111131
c12d782
73c01d3
aa99468
e74444e
32715ff
a4e38c7
b2c5856
d159e30
1d6c82b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: 'Run and Publish VR Screenshot' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this pipeline is disabled for now |
||
description: 'Runs and publishes visual regression screenshots' | ||
inputs: | ||
fluentVersion: | ||
description: 'Fluent version' | ||
required: true | ||
default: 'v8' | ||
vrTestPackageName: | ||
description: 'VR test package name' | ||
required: true | ||
default: 'vr-tests' | ||
vrTestPackagePath: | ||
description: 'VR test package path' | ||
required: true | ||
default: 'apps/vr-tests' | ||
locationPrefix: | ||
description: 'Location prefix' | ||
required: true | ||
default: 'fluentuiv8' | ||
locationPostfix: | ||
description: 'Location postfix' | ||
required: true | ||
default: 'vrscreenshotv8' | ||
clientName: | ||
description: 'Client name' | ||
required: true | ||
default: 'fluentuiv8' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: nrwl/nx-set-shas@v4 | ||
with: | ||
main-branch-name: 'master' | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: 'yarn' | ||
node-version: '20' | ||
|
||
- run: yarn install --frozen-lockfile | ||
shell: bash | ||
|
||
- run: yarn playwright install --with-deps | ||
shell: bash | ||
|
||
- name: Check if vrTests should be skipped | ||
shell: bash | ||
run: | | ||
isPR=${{ github.event_name == 'pull_request' }} | ||
echo "isPR=$isPR" >> $GITHUB_ENV | ||
if [[ $isPR == true ]]; then | ||
packageAffected=$(yarn --silent check:affected --project ${{ inputs.vrTestPackageName }}) | ||
if [[ $packageAffected == false ]]; then | ||
echo "In PR pipeline but NOT affecting test package. Skipping test run" | ||
echo "vrTestSkip=yes" >> $GITHUB_ENV | ||
else | ||
echo "In PR pipeline and affecting test package. NOT Skipping test run" | ||
echo "vrTestSkip=no" >> $GITHUB_ENV | ||
fi | ||
else | ||
echo "Not in PR pipeline. NOT Skipping test run" | ||
echo "vrTestSkip=no" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Run VR tests | ||
if: ${{ env.vrTestSkip == 'no' }} | ||
shell: bash | ||
run: yarn nx run ${{ inputs.vrTestPackageName }}:test-vr --nxBail | ||
|
||
- name: Collate Artifacts | ||
if: ${{ env.vrTestSkip == 'no' }} | ||
shell: bash | ||
run: | | ||
mkdir -p screenshots | ||
cp -rf ${{ inputs.vrTestPackagePath }}/dist/screenshots/*.png screenshots/ | ||
|
||
- name: Upload VR screenshots | ||
if: ${{ env.vrTestSkip == 'no' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: vrscreenshot${{ inputs.fluentVersion }} | ||
path: screenshots | ||
|
||
- name: VR App - Create Policy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this and next step will fail as vrt doesn't work on GHA yet |
||
if: ${{ env.isPR == 'true' }} | ||
shell: bash | ||
run: | | ||
set -exuo pipefail | ||
npx [email protected] create-policy --nonBlockingPipelines '{"${{ env.pipelineId }}":{"pipelineStatus": "PENDING","pipelineName": "${{ env.pipelineName }}"}}' --clientType 'FLUENTUI' | ||
# env: | ||
# VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }} | ||
# TENANT_ID: ${{ secrets.TenantId }} | ||
# PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }} | ||
# SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }} | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run screenshotdiff | ||
if: ${{ env.isPR == 'true' && env.vrTestSkip == 'no' }} | ||
uses: azure/cli@v2 | ||
env: | ||
# ciDefinitionId is set to 205 because that is the ID of the baseline pipeline (https://uifabric.visualstudio.com/fabricpublic/_build?definitionId=205) used by the master branch | ||
CI_DEFINITION_ID: 205 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im not sure how this would be actually used in GHA context this is what is availabe: Note: I didn't create separate workflow for baseline as we had on ADO (https://github.com/microsoft/fluentui/blob/master/azure-pipelines.vrt-baseline.yml) to mitigate duplication. |
||
# API_TOKEN: ${{ secrets.fabric-public-pipeline-access-PAT }} | ||
# GITHUB_API_TOKEN: ${{ secrets.githubRepoStatusPAT }} | ||
# VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }} | ||
# STORAGE_ACCOUNT_ID: ${{ secrets.StorageAccountId }} | ||
# TENANT_ID: ${{ secrets.TenantId }} | ||
# PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }} | ||
# SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }} | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
azcliversion: latest | ||
inlineScript: | | ||
npx [email protected] run-diff --screenshotsDirectory ./screenshots --buildType pr --clientType "FLUENTUI" --ciDefinitionId ${{ env.CI_DEFINITION_ID }} --groupName ${{ env.pipelineName }} --locationPrefix ${{ inputs.locationPrefix }} --locationPostfix ${{ inputs.locationPostfix }} --pipelineId ${{ env.pipelineId }} --clientName ${{ inputs.clientName }} --threshold '0.04' --cumThreshold '1' | ||
|
||
- name: Run screenshotdiff - update baseline (non PR) | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: azure/cli@v2 | ||
# env: | ||
# API_TOKEN: ${{ secrets.fabric-public-pipeline-access-PAT }} | ||
# GITHUB_API_TOKEN: ${{ secrets.githubRepoStatusPAT }} | ||
# VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }} | ||
# STORAGE_ACCOUNT_ID: ${{ secrets.StorageAccountId }} | ||
# TENANT_ID: ${{ secrets.TenantId }} | ||
# PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }} | ||
# SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }} | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
azcliversion: latest | ||
inlineScript: | | ||
npx [email protected] run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix ${{ inputs.locationPrefix }} --locationPostfix ${{ inputs.locationPostfix }} --pipelineId ${{ env.pipelineId }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @ts-check | ||
|
||
/** | ||
* | ||
* @param {import('../scripts/triage-bot/src/types.ts').GithubScriptsParams} options | ||
* @returns | ||
*/ | ||
async function main(options) { | ||
const { context, github, core } = options; | ||
|
||
const report = process.env.report; | ||
|
||
if (report) { | ||
const comment = ` | ||
## Bundle Size Report | ||
Status: success | ||
|
||
${report} | ||
`; | ||
|
||
// Check if a comment already exists (using the unique ID) to update instead of posting a new one | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: Number(context.payload.pull_request?.number), | ||
}); | ||
|
||
// const existingComment = comments.find(comment => comment.body.includes('bundleSizeComment6721')); | ||
const existingComment = comments.find(comment => comment.body?.includes('## Bundle Size Report')); | ||
|
||
if (existingComment) { | ||
// Update the existing comment | ||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: existingComment.id, | ||
body: comment, | ||
}); | ||
return; | ||
} | ||
|
||
// Create a new comment | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: Number(context.payload.pull_request?.number), | ||
body: comment, | ||
}); | ||
|
||
return; | ||
} | ||
|
||
console.log('No report content found to post to PR.'); | ||
} | ||
|
||
module.exports = main; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @ts-check | ||
|
||
/** | ||
* | ||
* @param {import('../scripts/triage-bot/src/types.ts').GithubScriptsParams & {config:{websiteUrl:string;prId:string}} } options | ||
* @returns | ||
*/ | ||
async function main(options) { | ||
const { context, core, github, config } = options; | ||
|
||
const { owner, repo } = context.repo; | ||
|
||
const pull_request = await github.rest.pulls.get({ | ||
owner, | ||
repo, | ||
pull_number: Number(config.prId), | ||
}); | ||
|
||
await github.rest.repos.createCommitStatus({ | ||
// owner: 'microsoft', | ||
// repo: 'fluentui', | ||
owner, | ||
repo, | ||
sha: pull_request.data.head.sha, | ||
state: 'success', | ||
context: 'Pull request demo site', | ||
description: 'Click "Details" to go to the deployed demo site for this pull request', | ||
target_url: config.websiteUrl, | ||
}); | ||
} | ||
|
||
module.exports = main; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Bundle size | Comment on PR | ||
on: | ||
workflow_run: | ||
workflows: ['Bundle size'] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
comment: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: monosize-report | ||
path: ./results | ||
run_id: ${{ github.event.workflow_run.id }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# - name: 'Download artifact' | ||
# uses: dawidd6/action-download-artifact@v2 | ||
# with: | ||
# name: monosize-report | ||
# path: ./results | ||
# run_id: ${{ github.event.workflow_run.id }} | ||
# workflow: ${{ github.event.workflow.id }} | ||
# workflow_conclusion: success | ||
|
||
- name: Load PR number | ||
id: pr_number | ||
run: echo "::set-output name=id::$(cat pr.txt)" | ||
working-directory: ./results | ||
|
||
- name: 'Comment on PR' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
number: ${{ steps.pr_number.outputs.id }} | ||
path: ./results/monosize-report.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Bundle size | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
concurrency: | ||
# see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
env: | ||
NX_PARALLEL: 6 # ubuntu-latest = 4-core CPU / 16 GB of RAM | macos-14-xlarge (arm) = 6-core CPU / 14 GB of RAM | ||
NX_PREFER_TS_NODE: true | ||
NX_VERBOSE_LOGGING: true | ||
|
||
BROWSERSLIST_IGNORE_OLD_DATA: true | ||
|
||
# Deploy host and URL | ||
# DEPLOY_BASE_PATH: '' | ||
DEPLOY_HOST: fluentuipr.z22.web.core.windows.net | ||
DEPLOY_URL: https://fluentuipr.z22.web.core.windows.net/${{ github.event.pull_request.number || github.ref_name }} | ||
# DEPLOY_BASE_PATH: pull/${{github.event.pull_request.number}} | ||
DEPLOY_BASE_PATH: ${{ github.event.pull_request.number != '' && format('pull/{0}', github.event.pull_request.number) || format('heads/{0}', github.ref_name) }} | ||
|
||
IS_PR: ${{ github.event_name == 'pull_request' }} | ||
TARGET_BRANCH: ${{ github.event.pull_request.base.ref || '' }} | ||
|
||
# GitHub Secrets for Azure access | ||
# This service principal ("subscription" is a misleading name) only has access to the fluentuipr storage account | ||
AZURE_SUBSCRIPTION: Azure PR deploy - NEW | ||
AZURE_STORAGE: fluentuipr | ||
|
||
jobs: | ||
bundle-size: | ||
runs-on: macos-14-xlarge | ||
permissions: | ||
contents: 'read' | ||
actions: 'read' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Derive appropriate SHAs for base and head for `nx affected` commands | ||
uses: nrwl/nx-set-shas@v4 | ||
with: | ||
main-branch-name: 'master' | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
cache: 'yarn' | ||
node-version: '20' | ||
|
||
- run: echo number of CPUs "$(getconf _NPROCESSORS_ONLN)" | ||
|
||
- run: yarn install --frozen-lockfile | ||
|
||
- name: Build packages & create reports (PR only) | ||
if: github.event_name == 'pull_request' | ||
run: yarn nx affected -t bundle-size --nxBail | ||
|
||
- name: Compare bundle size with base (PR only) | ||
if: github.event_name == 'pull_request' | ||
run: npx monosize compare-reports --branch=${{ github.event.pull_request.base.ref }} --output=markdown --quiet > ./monosize-report.md | ||
|
||
- name: Save PR number | ||
run: echo ${{ github.event.number }} > pr.txt | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: ${{ github.event_name == 'pull_request' }} | ||
with: | ||
name: monosize-report | ||
if-no-files-found: error | ||
path: | | ||
monosize-report.md | ||
pr.txt | ||
|
||
# =================================== | ||
# NON PR (MASTER) WORKFLOW STEPS | ||
# =================================== | ||
|
||
- name: Build all packages & create reports (non-PR) | ||
if: github.event_name != 'pull_request' | ||
run: yarn nx run-many -t bundle-size --nxBail | ||
|
||
- name: Login via Azure CLI (non-PR) | ||
if: github.event_name != 'pull_request' | ||
uses: azure/login@v2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
||
- name: Upload a report (non-PR) | ||
if: github.event_name != 'pull_request' | ||
uses: azure/cli@v2 | ||
with: | ||
azcliversion: latest | ||
# TODO: how to set subcription? monosize has no flag for it and gha az cli doesn't support this parameter | ||
# azureSubscription: 'Bundlesize Testing' | ||
inlineScript: | | ||
yarn monosize upload-report --branch=${{ github.ref }} --commit-sha ${{ github.sha }} | ||
env: | ||
AZCOPY_AUTO_LOGIN_TYPE: 'AZCLI' | ||
SYSTEM_ACCESSTOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
# AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
# AZURE_SERVICE_CONNECTION_ID: ${{ secrets.AZURE_SERVICE_CONNECTION_ID }} | ||
# BUNDLESIZE_ACCOUNT_NAME: ${{ secrets.BUNDLESIZE_ACCOUNT_NAME }} | ||
Hotell marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migration of https://github.com/microsoft/fluentui/blob/master/.devops/templates/runpublishvrscreenshot.yml which also mitigates duplication - no need to have separate baseline pipeline https://github.com/microsoft/fluentui/blob/master/azure-pipelines.vrt-baseline.yml