Skip to content

Commit 83b4c2f

Browse files
Hotelltudorpopams
andauthored
ci(.github): migrate infra to GHA (#33070)
Co-authored-by: Tudor Popa <[email protected]>
1 parent 2aca49d commit 83b4c2f

File tree

17 files changed

+779
-5
lines changed

17 files changed

+779
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: 'Run and Publish VR Screenshot'
2+
description: 'Runs and publishes visual regression screenshots'
3+
inputs:
4+
fluentVersion:
5+
description: 'Fluent version'
6+
required: true
7+
default: 'v8'
8+
vrTestPackageName:
9+
description: 'VR test package name'
10+
required: true
11+
default: 'vr-tests'
12+
vrTestPackagePath:
13+
description: 'VR test package path'
14+
required: true
15+
default: 'apps/vr-tests'
16+
locationPrefix:
17+
description: 'Location prefix'
18+
required: true
19+
default: 'fluentuiv8'
20+
locationPostfix:
21+
description: 'Location postfix'
22+
required: true
23+
default: 'vrscreenshotv8'
24+
clientName:
25+
description: 'Client name'
26+
required: true
27+
default: 'fluentuiv8'
28+
29+
runs:
30+
using: 'composite'
31+
steps:
32+
- uses: nrwl/nx-set-shas@v4
33+
with:
34+
main-branch-name: 'master'
35+
36+
- uses: actions/setup-node@v4
37+
with:
38+
cache: 'yarn'
39+
node-version: '20'
40+
41+
- run: yarn install --frozen-lockfile
42+
shell: bash
43+
44+
- run: yarn playwright install --with-deps
45+
shell: bash
46+
47+
- name: Check if vrTests should be skipped
48+
shell: bash
49+
run: |
50+
isPR=${{ github.event_name == 'pull_request' }}
51+
echo "isPR=$isPR" >> $GITHUB_ENV
52+
if [[ $isPR == true ]]; then
53+
packageAffected=$(yarn --silent check:affected --project ${{ inputs.vrTestPackageName }})
54+
if [[ $packageAffected == false ]]; then
55+
echo "In PR pipeline but NOT affecting test package. Skipping test run"
56+
echo "vrTestSkip=yes" >> $GITHUB_ENV
57+
else
58+
echo "In PR pipeline and affecting test package. NOT Skipping test run"
59+
echo "vrTestSkip=no" >> $GITHUB_ENV
60+
fi
61+
else
62+
echo "Not in PR pipeline. NOT Skipping test run"
63+
echo "vrTestSkip=no" >> $GITHUB_ENV
64+
fi
65+
66+
- name: Run VR tests
67+
if: ${{ env.vrTestSkip == 'no' }}
68+
shell: bash
69+
run: yarn nx run ${{ inputs.vrTestPackageName }}:test-vr --nxBail
70+
71+
- name: Collate Artifacts
72+
if: ${{ env.vrTestSkip == 'no' }}
73+
shell: bash
74+
run: |
75+
mkdir -p screenshots
76+
cp -rf ${{ inputs.vrTestPackagePath }}/dist/screenshots/*.png screenshots/
77+
78+
- name: Upload VR screenshots
79+
if: ${{ env.vrTestSkip == 'no' }}
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: vrscreenshot${{ inputs.fluentVersion }}
83+
path: screenshots
84+
85+
# ==========================================================
86+
# STEPS BELOW WILL FAIL TO RUN ON GITHUB ACTIONS - see TODOs
87+
# ==========================================================
88+
89+
# TODO: will need Federated Identity to be added to tool similarly like we have for monosize azure plugin https://github.com/microsoft/monosize/blob/main/packages/monosize-storage-azure/src/createTableClient.mts#L27
90+
- name: VR App - Create Policy
91+
if: ${{ env.isPR == 'true' }}
92+
shell: bash
93+
run: |
94+
set -exuo pipefail
95+
npx [email protected] create-policy --nonBlockingPipelines '{"${{ env.pipelineId }}":{"pipelineStatus": "PENDING","pipelineName": "${{ env.pipelineName }}"}}' --clientType 'FLUENTUI'
96+
env:
97+
VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }}
98+
TENANT_ID: ${{ secrets.TenantId }}
99+
PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }}
100+
SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }}
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
103+
# TODO: will need azure/login@v2 to be added to the workflow {@ling file://./../../workflows/pr-website-deploy-comment.yml#49}
104+
- name: Run screenshotdiff
105+
if: ${{ env.isPR == 'true' && env.vrTestSkip == 'no' }}
106+
uses: azure/cli@v2
107+
env:
108+
# 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
109+
# TODO: not sure how this will be used on GHA cc @evancharlton @TristanWatanabe
110+
CI_DEFINITION_ID: 205
111+
API_TOKEN: ${{ secrets.fabric-public-pipeline-access-PAT }}
112+
GITHUB_API_TOKEN: ${{ secrets.githubRepoStatusPAT }}
113+
VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }}
114+
STORAGE_ACCOUNT_ID: ${{ secrets.StorageAccountId }}
115+
TENANT_ID: ${{ secrets.TenantId }}
116+
PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }}
117+
SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }}
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
with:
120+
azcliversion: latest
121+
inlineScript: |
122+
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'
123+
124+
# TODO: will need azure/login@v2 to be added to the workflow {@ling file://./../../workflows/pr-website-deploy-comment.yml#49}
125+
- name: Run screenshotdiff - update baseline (non PR)
126+
if: ${{ github.event_name != 'pull_request' }}
127+
uses: azure/cli@v2
128+
env:
129+
API_TOKEN: ${{ secrets.fabric-public-pipeline-access-PAT }}
130+
GITHUB_API_TOKEN: ${{ secrets.githubRepoStatusPAT }}
131+
VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }}
132+
STORAGE_ACCOUNT_ID: ${{ secrets.StorageAccountId }}
133+
TENANT_ID: ${{ secrets.TenantId }}
134+
PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }}
135+
SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }}
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
with:
138+
azcliversion: latest
139+
inlineScript: |
140+
npx [email protected] run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix ${{ inputs.locationPrefix }} --locationPostfix ${{ inputs.locationPostfix }} --pipelineId ${{ env.pipelineId }}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Bundle size | Comment on PR
2+
on:
3+
workflow_run:
4+
workflows: ['Bundle size']
5+
types:
6+
- completed
7+
8+
jobs:
9+
comment:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
12+
permissions:
13+
pull-requests: write
14+
steps:
15+
- name: Download artifact
16+
uses: actions/download-artifact@v4
17+
with:
18+
name: monosize-report
19+
path: ./results
20+
run_id: ${{ github.event.workflow_run.id }}
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Load PR number
24+
id: pr_number
25+
run: echo "::set-output name=id::$(cat pr.txt)"
26+
working-directory: ./results
27+
28+
- name: 'Comment on PR'
29+
uses: marocchino/sticky-pull-request-comment@v2
30+
with:
31+
number: ${{ steps.pr_number.outputs.id }}
32+
path: ./results/monosize-report.md

.github/workflows/bundle-size.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Bundle size
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
8+
concurrency:
9+
# 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
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
env:
15+
NX_PARALLEL: 6 # ubuntu-latest = 4-core CPU / 16 GB of RAM | macos-14-xlarge (arm) = 6-core CPU / 14 GB of RAM
16+
NX_PREFER_TS_NODE: true
17+
NX_VERBOSE_LOGGING: true
18+
19+
BROWSERSLIST_IGNORE_OLD_DATA: true
20+
21+
jobs:
22+
bundle-size:
23+
runs-on: macos-14-xlarge
24+
permissions:
25+
contents: 'read'
26+
actions: 'read'
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
34+
uses: nrwl/nx-set-shas@v4
35+
with:
36+
main-branch-name: 'master'
37+
38+
- uses: actions/setup-node@v4
39+
with:
40+
cache: 'yarn'
41+
node-version: '20'
42+
43+
- run: echo number of CPUs "$(getconf _NPROCESSORS_ONLN)"
44+
45+
- run: yarn install --frozen-lockfile
46+
47+
- name: Build packages & create reports (PR only)
48+
if: github.event_name == 'pull_request'
49+
run: yarn nx affected -t bundle-size --nxBail
50+
51+
- name: Compare bundle size with base (PR only)
52+
if: github.event_name == 'pull_request'
53+
run: npx monosize compare-reports --branch=${{ github.event.pull_request.base.ref }} --output=markdown --quiet > ./monosize-report.md
54+
55+
- name: Save PR number
56+
run: echo ${{ github.event.number }} > pr.txt
57+
58+
- uses: actions/upload-artifact@v4
59+
if: ${{ github.event_name == 'pull_request' }}
60+
with:
61+
name: monosize-report
62+
if-no-files-found: error
63+
path: |
64+
monosize-report.md
65+
pr.txt
66+
67+
# ===================================
68+
# NON PR (MASTER) WORKFLOW STEPS
69+
# ===================================
70+
71+
- name: Build all packages & create reports (non-PR)
72+
if: github.event_name != 'pull_request'
73+
run: yarn nx run-many -t bundle-size --nxBail
74+
75+
- name: Login via Azure CLI (non-PR)
76+
if: github.event_name != 'pull_request'
77+
uses: azure/login@v2
78+
with:
79+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
80+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
81+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
82+
83+
- name: Upload a report (non-PR)
84+
if: github.event_name != 'pull_request'
85+
uses: azure/cli@v2
86+
with:
87+
azcliversion: latest
88+
inlineScript: |
89+
yarn monosize upload-report --branch=${{ github.ref }} --commit-sha ${{ github.sha }}
90+
env:
91+
AZCOPY_AUTO_LOGIN_TYPE: 'AZCLI'
92+
SYSTEM_ACCESSTOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
BUNDLESIZE_ACCOUNT_NAME: ${{ secrets.BUNDLESIZE_ACCOUNT_NAME }}

.github/workflows/pr-vrt.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: VRT CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
# 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
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
NX_PARALLEL: 4 # ubuntu-latest = 4-core CPU / 16 GB of RAM | macos-14-xlarge (arm) = 6-core CPU / 14 GB of RAM
16+
NX_PREFER_TS_NODE: true
17+
NX_VERBOSE_LOGGING: true
18+
19+
permissions:
20+
contents: 'read'
21+
actions: 'read'
22+
23+
jobs:
24+
web_components:
25+
runs-on: ubuntu-latest
26+
env:
27+
pipelineId: '315'
28+
pipelineName: 'fluent-ui_VRT_Pipeline_web-components'
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
- name: Run and publish VR screenshot
34+
uses: ./.github/actions/run-publish-vr-screenshot
35+
with:
36+
fluentVersion: webcomponents
37+
vrTestPackageName: 'vr-tests-web-components'
38+
vrTestPackagePath: 'apps/vr-tests-web-components'
39+
locationPrefix: 'FluentUI-web-components'
40+
locationPostfix: 'vrscreenshotwebcomponents'
41+
clientName: 'fluentui-web-components-v3'
42+
43+
react_components:
44+
runs-on: ubuntu-latest
45+
env:
46+
pipelineId: '311'
47+
pipelineName: 'fluent-ui_VRT_Pipeline_v9'
48+
steps:
49+
- uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
- name: Run and publish VR screenshot
53+
uses: ./.github/actions/run-publish-vr-screenshot
54+
with:
55+
fluentVersion: v9
56+
vrTestPackageName: 'vr-tests-react-components'
57+
vrTestPackagePath: 'apps/vr-tests-react-components'
58+
locationPrefix: 'fluentuiv9'
59+
locationPostfix: 'vrscreenshotv9'
60+
clientName: 'fluentuiv9'
61+
62+
react:
63+
runs-on: ubuntu-latest
64+
env:
65+
pipelineId: '312'
66+
pipelineName: 'fluent-ui_VRT_Pipeline_v8'
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
- name: Run and publish VR screenshot
72+
uses: ./.github/actions/run-publish-vr-screenshot
73+
with:
74+
fluentVersion: v8
75+
vrTestPackageName: 'vr-tests'
76+
vrTestPackagePath: 'apps/vr-tests'
77+
locationPrefix: 'fluentuiv8'
78+
locationPostfix: 'vrscreenshotv8'
79+
clientName: 'fluentuiv8'
80+
81+
react_northstar:
82+
runs-on: ubuntu-latest
83+
env:
84+
pipelineId: '313'
85+
pipelineName: 'fluent-ui_VRT_Pipeline_v0'
86+
steps:
87+
- uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0
90+
- name: Run and publish VR screenshot
91+
uses: ./.github/actions/run-publish-vr-screenshot
92+
with:
93+
fluentVersion: v0
94+
vrTestPackageName: 'docs'
95+
vrTestPackagePath: 'packages/fluentui/docs'
96+
locationPrefix: 'FluentUI-v0'
97+
locationPostfix: 'vrscreenshotv0'
98+
clientName: 'FluentUIV0'

0 commit comments

Comments
 (0)