Skip to content

Commit 290c9aa

Browse files
committed
ci: port more pipelines to gha
1 parent 8ef32c8 commit 290c9aa

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed

.github/workflows/pr.yml

+174
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@ env:
1010
NX_PREFER_TS_NODE: true
1111
NX_VERBOSE_LOGGING: true
1212

13+
BROWSERSLIST_IGNORE_OLD_DATA: true
14+
15+
# Deploy host and URL
16+
# DEPLOY_BASE_PATH: ''
17+
DEPLOY_HOST: fluentuipr.z22.web.core.windows.net
18+
DEPLOY_URL: https://fluentuipr.z22.web.core.windows.net/${{ github.event.pull_request.number || github.ref_name }}
19+
# DEPLOYHOST: fluentuipr.z22.web.core.windows.net
20+
# DEPLOYURL: https://${{ env.DEPLOYHOST }}/
21+
22+
# GitHub Secrets for Azure access
23+
# This service principal ("subscription" is a misleading name) only has access to the fluentuipr storage account
24+
AZURE_SUBSCRIPTION: Azure PR deploy - NEW
25+
AZURE_STORAGE: fluentuipr
26+
27+
IS_PR: ${{ github.event_name == 'pull_request' }}
28+
TARGET_BRANCH: ${{ github.event.pull_request.base.ref || '' }}
29+
DEPLOY_BASE_PATH: pull/${{github.event.pull_request.number}}
30+
# DEPLOY_BASE_PATH: ${{ github.event.pull_request.number ? 'pull/' + github.event.pull_request.number : 'heads/' + github.ref_name }}
31+
# SKIP_COMPONENT_GOVERNANCE_DETECTION: true
32+
1333
jobs:
1434
main:
1535
runs-on: macos-14-xlarge
@@ -68,3 +88,157 @@ jobs:
6888
run: |
6989
git status --porcelain
7090
git diff-index --quiet HEAD -- || exit 1
91+
92+
e2e-and-deploy:
93+
runs-on: macos-14-xlarge
94+
permissions:
95+
contents: 'read'
96+
actions: 'read'
97+
98+
steps:
99+
- uses: actions/checkout@v4
100+
with:
101+
fetch-depth: 0
102+
103+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
104+
uses: nrwl/nx-set-shas@v4
105+
with:
106+
main-branch-name: 'master'
107+
108+
- uses: actions/setup-node@v4
109+
with:
110+
cache: 'yarn'
111+
node-version: '20'
112+
113+
- run: echo number of CPUs "$(getconf _NPROCESSORS_ONLN)"
114+
115+
- run: yarn install --frozen-lockfile
116+
117+
- name: Install Playwright dependencies
118+
run: yarn playwright install --with-deps
119+
120+
- name: Verify Cypress install
121+
run: yarn cypress verify
122+
123+
- name: Cypress/Playwright E2E tests
124+
if: github.event_name == 'pull_request'
125+
run: yarn nx affected -t e2e --nxBail --parallel 1
126+
127+
- name: Cypress/Playwright E2E tests (non-PR)
128+
if: github.event_name != 'pull_request'
129+
run: yarn nx run-many -t e2e --nxBail --parallel 1
130+
131+
- name: Bundle
132+
if: github.event_name == 'pull_request'
133+
run: yarn nx affected -t bundle --nxBail
134+
135+
- name: Bundle (non-PR)
136+
if: github.event_name != 'pull_request'
137+
run: yarn nx run-many -t bundle --nxBail
138+
139+
- name: Build Storybooks
140+
if: github.event_name == 'pull_request'
141+
run: yarn nx affected -t build-storybook --nxBail
142+
143+
- name: Build Storybooks (non-PR)
144+
if: github.event_name != 'pull_request'
145+
run: yarn nx run-many -t build-storybook --nxBail
146+
147+
- name: Generate PR Deploy Site
148+
if: github.event_name == 'pull_request'
149+
run: yarn nx run pr-deploy-site:generate:site
150+
151+
- name: Upload PR deploy site
152+
continue-on-error: true
153+
if: github.event_name == 'pull_request'
154+
uses: azure/cli@v2
155+
with:
156+
azcliversion: latest
157+
inlineScript: |
158+
az storage blob upload-batch \
159+
--destination '$web' \
160+
--source apps/pr-deploy-site/dist \
161+
--account-name ${{ secrets.AZURE_STORAGE }} \
162+
--destination-path ${{ env.DEPLOY_BASE_PATH }} \
163+
--auth-mode login \
164+
--overwrite
165+
166+
- name: Update PR deploy site GitHub status
167+
if: github.event_name == 'pull_request'
168+
uses: actions/github-script@v6
169+
with:
170+
script: |
171+
const { context, github } = require('@actions/github');
172+
const { owner, repo } = context.repo;
173+
const pull_request = context.payload.pull_request;
174+
175+
await github.repos.createCommitStatus({
176+
owner: 'microsoft',
177+
repo: 'fluentui',
178+
sha: pull_request.head.sha,
179+
state: 'success',
180+
context: 'Pull request demo site',
181+
description: 'Click "Details" to go to the deployed demo site for this pull request',
182+
target_url: process.env.DEPLOY_URL + '/'
183+
});
184+
env:
185+
DEPLOY_URL: ${{ env.DEPLOY_URL }}
186+
187+
bundle-size:
188+
runs-on: macos-14-xlarge
189+
permissions:
190+
pull-requests: write
191+
contents: 'read'
192+
actions: 'read'
193+
194+
steps:
195+
- uses: actions/checkout@v4
196+
with:
197+
fetch-depth: 0
198+
199+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
200+
uses: nrwl/nx-set-shas@v4
201+
with:
202+
main-branch-name: 'master'
203+
204+
- uses: actions/setup-node@v4
205+
with:
206+
cache: 'yarn'
207+
node-version: '20'
208+
209+
- run: echo number of CPUs "$(getconf _NPROCESSORS_ONLN)"
210+
211+
- run: yarn install --frozen-lockfile
212+
213+
- name: Build packages & create reports (PR only)
214+
if: github.event_name == 'pull_request'
215+
run: yarn nx affected -t bundle-size --nxBail
216+
217+
- name: Compare bundle size with base (PR only)
218+
if: github.event_name == 'pull_request'
219+
run: npx monosize compare-reports --branch=${{ github.event.pull_request.base.ref }} --output=markdown --quiet > ./monosize-report.md
220+
221+
- name: Post results to PR (PR only)
222+
if: github.event_name == 'pull_request'
223+
uses: marocchino/sticky-pull-request-comment@v2
224+
with:
225+
path: monosize-report.md
226+
227+
- name: Build all packages & create reports (non-PR)
228+
if: github.event_name != 'pull_request'
229+
run: yarn nx run-many -t bundle-size --nxBail
230+
231+
- name: Upload a report (base only)
232+
continue-on-error: true
233+
if: github.event_name != 'pull_request'
234+
uses: azure/cli@v2
235+
with:
236+
azcliversion: latest
237+
inlineScript: |
238+
yarn monosize upload-report --branch=${{ github.ref }} --commit-sha ${{ github.sha }}
239+
env:
240+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
241+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
242+
AZURE_SERVICE_CONNECTION_ID: ${{ secrets.AZURE_SERVICE_CONNECTION_ID }}
243+
BUNDLESIZE_ACCOUNT_NAME: ${{ secrets.BUNDLESIZE_ACCOUNT_NAME }}
244+
SYSTEM_ACCESSTOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)