ci(.github): migrate infra to GHA #59
Workflow file for this run
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
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
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 }} | |
# DEPLOYHOST: fluentuipr.z22.web.core.windows.net | |
# DEPLOYURL: https://${{ env.DEPLOYHOST }}/ | |
# 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 | |
IS_PR: ${{ github.event_name == 'pull_request' }} | |
TARGET_BRANCH: ${{ github.event.pull_request.base.ref || '' }} | |
DEPLOY_BASE_PATH: pull/${{github.event.pull_request.number}} | |
# DEPLOY_BASE_PATH: ${{ github.event.pull_request.number ? 'pull/' + github.event.pull_request.number : 'heads/' + github.ref_name }} | |
# SKIP_COMPONENT_GOVERNANCE_DETECTION: true | |
jobs: | |
main: | |
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: Workspace lint | |
run: | | |
yarn nx run workspace-plugin:check-graph | |
yarn nx g @fluentui/workspace-plugin:tsconfig-base-all --verify | |
yarn nx g @fluentui/workspace-plugin:normalize-package-dependencies --verify | |
- name: Type-check just.config.ts files | |
run: | | |
# following packages need to be build in advance: | |
# @fluentui/api-docs is used within apps/public-docsite-resources/just.config.ts, | |
# @fluentui/digest is used within packages/fluentui/perf-test-northstar/just.config.ts, thus it needs to be build in advance | |
# | |
# NOTE: we are running this via nx in order to get cache hits later on | |
yarn nx run-many -t build -p api-docs digest | |
yarn tsc -p ./tsconfig.just-scripts-configs.json | |
- name: 'check packages: installed dependencies versions' | |
run: | | |
yarn check:installed-dependencies-versions | |
- name: check formatting | |
run: | | |
yarn nx format:check --base origin/master | |
- name: v0,v8 jest test perf experiments worker 50% | |
run: | | |
yarn nx run-many -t build -p react,react-northstar | |
yarn nx run react:test | |
yarn nx run react-northstar:test | |
- name: v0,v8 jest test perf experiments worker 1 | |
run: | | |
yarn nx reset | |
yarn nx run-many -t build -p react,react-northstar | |
FLUENT_WORKER=1 yarn nx run react:test | |
FLUENT_WORKER=1 yarn nx run react-northstar:test | |
- name: build, test, lint, test-ssr (affected) | |
run: | | |
yarn nx affected -t build test lint type-check test-ssr test-integration verify-packaging --nxBail | |
- name: 'Check for unstaged changes' | |
run: | | |
git status --porcelain | |
git diff-index --quiet HEAD -- || exit 1 | |
e2e-and-deploy: | |
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: Install Playwright dependencies | |
run: yarn playwright install --with-deps | |
- name: Verify Cypress install | |
run: yarn cypress verify | |
- name: Cypress/Playwright E2E tests | |
if: github.event_name == 'pull_request' | |
run: yarn nx affected -t e2e --nxBail --parallel 1 | |
- name: Cypress/Playwright E2E tests (non-PR) | |
if: github.event_name != 'pull_request' | |
run: yarn nx run-many -t e2e --nxBail --parallel 1 | |
- name: Bundle | |
if: github.event_name == 'pull_request' | |
run: yarn nx affected -t bundle --nxBail | |
- name: Bundle (non-PR) | |
if: github.event_name != 'pull_request' | |
run: yarn nx run-many -t bundle --nxBail | |
- name: Build Storybooks | |
if: github.event_name == 'pull_request' | |
run: yarn nx affected -t build-storybook --nxBail | |
- name: Build Storybooks (non-PR) | |
if: github.event_name != 'pull_request' | |
run: yarn nx run-many -t build-storybook --nxBail | |
- name: Generate PR Deploy Site | |
if: github.event_name == 'pull_request' | |
run: yarn nx run pr-deploy-site:generate:site | |
- name: Upload PR deploy site | |
continue-on-error: true | |
if: github.event_name == 'pull_request' | |
uses: azure/cli@v2 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
az storage blob upload-batch \ | |
--destination '$web' \ | |
--source apps/pr-deploy-site/dist \ | |
--account-name ${{ secrets.AZURE_STORAGE }} \ | |
--destination-path ${{ env.DEPLOY_BASE_PATH }} \ | |
--auth-mode login \ | |
--overwrite | |
- name: Update PR deploy site GitHub status | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const run = require('./.github/deploy-pr-site-status'); | |
await run({github,context,core}); | |
env: | |
DEPLOY_URL: ${{ env.DEPLOY_URL }} |