2020-05-27 19:56:30 +01:00
|
|
|
name: CI
|
2020-05-26 20:44:36 +01:00
|
|
|
on:
|
|
|
|
push:
|
2020-07-28 21:13:48 +01:00
|
|
|
branches:
|
|
|
|
- master
|
2020-09-25 22:44:15 +01:00
|
|
|
- hotfix/**
|
|
|
|
- release/**
|
2020-05-26 20:44:36 +01:00
|
|
|
pull_request:
|
2020-07-28 21:13:48 +01:00
|
|
|
branches:
|
|
|
|
- master
|
2024-04-09 18:55:08 +01:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
contents: read
|
2020-05-26 20:44:36 +01:00
|
|
|
jobs:
|
2021-01-26 19:13:13 +00:00
|
|
|
codemetrics:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: "Log Code Metrics"
|
|
|
|
if: github.ref == 'refs/heads/master'
|
|
|
|
steps:
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
2021-01-26 19:13:13 +00:00
|
|
|
with:
|
2023-12-13 18:24:40 +00:00
|
|
|
node-version: 18.x
|
2021-01-26 19:13:13 +00:00
|
|
|
- run: npm ci
|
|
|
|
- run: node utils/codeMetrics.js
|
|
|
|
env:
|
|
|
|
CODE_METRICS_APP_ID: ${{ secrets.CODE_METRICS_APP_ID }}
|
2020-06-15 16:08:54 +01:00
|
|
|
compile:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: "Compile TypeScript"
|
|
|
|
steps:
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
2020-06-15 16:08:54 +01:00
|
|
|
with:
|
2023-12-13 18:24:40 +00:00
|
|
|
node-version: 18.x
|
2020-06-15 16:08:54 +01:00
|
|
|
- run: npm ci
|
|
|
|
- run: npm run compile
|
|
|
|
- run: npm run compile:strict
|
|
|
|
format:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: "Check Format"
|
|
|
|
steps:
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
2020-06-15 16:08:54 +01:00
|
|
|
with:
|
2023-12-13 18:24:40 +00:00
|
|
|
node-version: 18.x
|
2020-06-15 16:08:54 +01:00
|
|
|
- run: npm ci
|
|
|
|
- run: npm run format:check
|
|
|
|
lint:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: "Lint"
|
|
|
|
steps:
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
2020-06-15 16:08:54 +01:00
|
|
|
with:
|
2023-12-13 18:24:40 +00:00
|
|
|
node-version: 18.x
|
2020-06-15 16:08:54 +01:00
|
|
|
- run: npm ci
|
|
|
|
- run: npm run lint
|
2020-06-15 17:25:59 +01:00
|
|
|
unittest:
|
2020-05-26 20:44:36 +01:00
|
|
|
runs-on: ubuntu-latest
|
2020-05-27 19:56:30 +01:00
|
|
|
name: "Unit Tests"
|
2020-05-26 20:44:36 +01:00
|
|
|
steps:
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
2020-05-27 19:56:30 +01:00
|
|
|
with:
|
2023-12-13 18:24:40 +00:00
|
|
|
node-version: 18.x
|
2020-05-27 19:56:30 +01:00
|
|
|
- run: npm ci
|
|
|
|
- run: npm run test
|
2020-05-26 20:44:36 +01:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2020-05-27 19:56:30 +01:00
|
|
|
name: "Build"
|
2020-05-26 20:44:36 +01:00
|
|
|
steps:
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
2020-05-27 19:56:30 +01:00
|
|
|
with:
|
2023-12-13 18:24:40 +00:00
|
|
|
node-version: 18.x
|
2020-05-27 19:56:30 +01:00
|
|
|
- run: npm ci
|
2020-05-30 02:14:09 +01:00
|
|
|
- run: npm run build:contracts
|
|
|
|
- name: Restore Build Cache
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: .cache
|
|
|
|
key: ${{ runner.os }}-build-cache
|
|
|
|
- run: npm run pack:prod
|
2023-09-15 16:33:27 +01:00
|
|
|
env:
|
2023-12-13 18:24:40 +00:00
|
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
2020-06-12 18:33:00 +01:00
|
|
|
- run: cp -r ./Contracts ./dist/contracts
|
2020-06-30 19:49:14 +01:00
|
|
|
- run: cp -r ./configs ./dist/configs
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
2020-05-30 02:14:09 +01:00
|
|
|
with:
|
|
|
|
name: dist
|
|
|
|
path: dist/
|
2021-04-02 18:24:01 +01:00
|
|
|
- name: Upload build to preview blob storage
|
2023-02-17 00:23:24 +00:00
|
|
|
run: az storage blob upload-batch -d '$web' -s 'dist' --account-name cosmosexplorerpreview --destination-path "${{github.event.pull_request.head.sha || github.sha}}" --account-key="${PREVIEW_STORAGE_KEY}" --overwrite true
|
2021-04-02 18:24:01 +01:00
|
|
|
env:
|
|
|
|
PREVIEW_STORAGE_KEY: ${{ secrets.PREVIEW_STORAGE_KEY }}
|
|
|
|
- name: Upload preview config to blob storage
|
2023-02-17 00:23:24 +00:00
|
|
|
run: az storage blob upload -c '$web' -f ./preview/config.json --account-name cosmosexplorerpreview --name "${{github.event.pull_request.head.sha || github.sha}}/config.json" --account-key="${PREVIEW_STORAGE_KEY}" --overwrite true
|
2021-04-02 18:24:01 +01:00
|
|
|
env:
|
|
|
|
PREVIEW_STORAGE_KEY: ${{ secrets.PREVIEW_STORAGE_KEY }}
|
2020-05-30 02:14:09 +01:00
|
|
|
nuget:
|
|
|
|
name: Publish Nuget
|
2020-07-28 21:13:48 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
2021-03-04 18:24:43 +00:00
|
|
|
needs: [build]
|
2020-05-30 02:14:09 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
|
|
|
AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
|
|
|
|
steps:
|
|
|
|
- uses: nuget/setup-nuget@v1
|
|
|
|
with:
|
|
|
|
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
|
|
|
|
- name: Download Dist Folder
|
2023-12-13 18:24:40 +00:00
|
|
|
uses: actions/download-artifact@v3
|
2020-05-30 02:14:09 +01:00
|
|
|
with:
|
|
|
|
name: dist
|
2020-06-30 19:49:14 +01:00
|
|
|
- run: cp ./configs/prod.json config.json
|
2023-02-17 01:51:57 +00:00
|
|
|
- run: nuget sources add -Name "ADO" -Source "$NUGET_SOURCE" -UserName "jawelton@microsoft.com" -Password "$AZURE_DEVOPS_PAT"
|
2020-05-30 02:14:09 +01:00
|
|
|
- run: nuget pack -Version "2.0.0-github-${GITHUB_SHA}"
|
2021-03-05 04:49:52 +00:00
|
|
|
- run: nuget push -SkipDuplicate -Source "$NUGET_SOURCE" -ApiKey Az *.nupkg
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
2020-07-02 15:58:36 +01:00
|
|
|
name: packages
|
2020-05-30 02:14:09 +01:00
|
|
|
with:
|
|
|
|
path: "*.nupkg"
|
|
|
|
nugetmpac:
|
|
|
|
name: Publish Nuget MPAC
|
2020-07-28 21:13:48 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
2021-03-04 18:24:43 +00:00
|
|
|
needs: [build]
|
2020-05-30 02:14:09 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
NUGET_SOURCE: ${{ secrets.NUGET_SOURCE }}
|
|
|
|
AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
|
|
|
|
steps:
|
|
|
|
- uses: nuget/setup-nuget@v1
|
|
|
|
with:
|
|
|
|
nuget-api-key: ${{ secrets.NUGET_API_KEY }}
|
|
|
|
- name: Download Dist Folder
|
2023-12-13 19:44:46 +00:00
|
|
|
uses: actions/download-artifact@v3
|
2020-05-30 02:14:09 +01:00
|
|
|
with:
|
|
|
|
name: dist
|
2020-06-30 19:49:14 +01:00
|
|
|
- run: cp ./configs/mpac.json config.json
|
2020-05-30 02:14:09 +01:00
|
|
|
- run: sed -i 's/Azure.Cosmos.DB.Data.Explorer/Azure.Cosmos.DB.Data.Explorer.MPAC/g' DataExplorer.nuspec
|
2023-02-17 01:51:57 +00:00
|
|
|
- run: nuget sources add -Name "ADO" -Source "$NUGET_SOURCE" -UserName "jawelton@microsoft.com" -Password "$AZURE_DEVOPS_PAT"
|
2020-05-30 02:14:09 +01:00
|
|
|
- run: nuget pack -Version "2.0.0-github-${GITHUB_SHA}"
|
2021-03-05 04:49:52 +00:00
|
|
|
- run: nuget push -SkipDuplicate -Source "$NUGET_SOURCE" -ApiKey Az *.nupkg
|
2023-12-13 18:24:40 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
2020-07-02 15:58:36 +01:00
|
|
|
name: packages
|
2020-05-30 02:14:09 +01:00
|
|
|
with:
|
|
|
|
path: "*.nupkg"
|
2024-06-05 20:46:32 +01:00
|
|
|
|
|
|
|
playwright-tests:
|
|
|
|
name: "Run Playwright Tests (Shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }})"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
|
|
|
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
|
|
|
|
shardTotal: [8]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: "Az CLI login"
|
|
|
|
uses: azure/login@v1
|
|
|
|
with:
|
|
|
|
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
|
|
|
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
|
|
|
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
|
|
- name: Use Node.js 18.x
|
|
|
|
uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: 18.x
|
|
|
|
- run: npm ci
|
|
|
|
- run: npx playwright install --with-deps
|
|
|
|
- name: Run test shard ${{ matrix['shardIndex'] }} of ${{ matrix['shardTotal']}}
|
|
|
|
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
|
|
|
- name: Upload blob report to GitHub Actions Artifacts
|
|
|
|
if: ${{ !cancelled() }}
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: blob-report-${{ matrix.shardIndex }}
|
|
|
|
path: blob-report
|
|
|
|
retention-days: 1
|
|
|
|
|
|
|
|
merge-playwright-reports:
|
|
|
|
name: "Merge Playwright Reports"
|
|
|
|
# Merge reports after playwright-tests, even if some shards have failed
|
|
|
|
if: ${{ !cancelled() }}
|
|
|
|
needs: [playwright-tests]
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
|
|
with:
|
|
|
|
node-version: 18
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
- name: Download blob reports from GitHub Actions Artifacts
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
path: all-blob-reports
|
|
|
|
pattern: blob-report-*
|
|
|
|
merge-multiple: true
|
|
|
|
|
|
|
|
- name: Merge into HTML Report
|
|
|
|
run: npx playwright merge-reports --reporter html ./all-blob-reports
|
|
|
|
|
|
|
|
- name: Upload HTML report
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: html-report--attempt-${{ github.run_attempt }}
|
|
|
|
path: playwright-report
|
|
|
|
retention-days: 14
|