229 lines
7.4 KiB
YAML
229 lines
7.4 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- hotfix/**
|
|
- release/**
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
jobs:
|
|
codemetrics:
|
|
runs-on: ubuntu-latest
|
|
name: "Log Code Metrics"
|
|
if: github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- run: node utils/codeMetrics.js
|
|
env:
|
|
CODE_METRICS_APP_ID: ${{ secrets.CODE_METRICS_APP_ID }}
|
|
compile:
|
|
runs-on: ubuntu-latest
|
|
name: "Compile TypeScript"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- run: npm run compile
|
|
- run: npm run compile:strict
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
name: "Check Format"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- run: npm run format:check
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
name: "Lint"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- run: npm run lint
|
|
unittest:
|
|
runs-on: ubuntu-latest
|
|
name: "Unit Tests"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- run: npm run test
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
name: "Build"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- 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
|
|
env:
|
|
NODE_OPTIONS: "--max-old-space-size=4096"
|
|
- run: cp -r ./Contracts ./dist/contracts
|
|
- run: cp -r ./configs ./dist/configs
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
- name: Upload build to preview blob storage
|
|
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
|
|
env:
|
|
PREVIEW_STORAGE_KEY: ${{ secrets.PREVIEW_STORAGE_KEY }}
|
|
- name: Upload preview config to blob storage
|
|
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
|
|
env:
|
|
PREVIEW_STORAGE_KEY: ${{ secrets.PREVIEW_STORAGE_KEY }}
|
|
endtoendemulator:
|
|
name: "End To End Emulator Tests"
|
|
# Temporarily disabled. This test needs to be rewritten in playwright
|
|
if: false
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 18.x
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 18.x
|
|
- uses: southpolesteve/cosmos-emulator-github-action@v1
|
|
- name: End to End Tests
|
|
run: |
|
|
npm ci
|
|
npm start &
|
|
npm run wait-for-server
|
|
npx jest -c ./jest.config.e2e.js --detectOpenHandles test/sql/container.spec.ts
|
|
shell: bash
|
|
env:
|
|
DATA_EXPLORER_ENDPOINT: "https://localhost:1234/explorer.html?platform=Emulator"
|
|
PLATFORM: "Emulator"
|
|
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
|
- uses: actions/upload-artifact@v3
|
|
if: failure()
|
|
with:
|
|
name: screenshots
|
|
path: failed-*
|
|
endtoend:
|
|
name: "E2E"
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
NODE_TLS_REJECT_UNAUTHORIZED: 0
|
|
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
test-file:
|
|
- ./test/cassandra/container.spec.ts
|
|
- ./test/graph/container.spec.ts
|
|
- ./test/sql/container.spec.ts
|
|
- ./test/mongo/container.spec.ts
|
|
- ./test/mongo/container32.spec.ts
|
|
- ./test/selfServe/selfServeExample.spec.ts
|
|
- ./test/sql/resourceToken.spec.ts
|
|
- ./test/tables/container.spec.ts
|
|
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: npm start &
|
|
- run: npm run wait-for-server
|
|
- name: ${{ matrix['test-file'] }}
|
|
run: |
|
|
# Run tests up to three times
|
|
for i in $(seq 1 3); do npx jest -c ./jest.config.playwright.js ${{ matrix['test-file'] }} && s=0 && break || s=$? && sleep 1; done; (exit $s)
|
|
shell: bash
|
|
- uses: actions/upload-artifact@v3
|
|
if: failure()
|
|
with:
|
|
name: screenshots
|
|
path: screenshots/
|
|
nuget:
|
|
name: Publish Nuget
|
|
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
|
needs: [build]
|
|
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
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: dist
|
|
- run: cp ./configs/prod.json config.json
|
|
- run: nuget sources add -Name "ADO" -Source "$NUGET_SOURCE" -UserName "jawelton@microsoft.com" -Password "$AZURE_DEVOPS_PAT"
|
|
- run: nuget pack -Version "2.0.0-github-${GITHUB_SHA}"
|
|
- run: nuget push -SkipDuplicate -Source "$NUGET_SOURCE" -ApiKey Az *.nupkg
|
|
- uses: actions/upload-artifact@v3
|
|
name: packages
|
|
with:
|
|
path: "*.nupkg"
|
|
nugetmpac:
|
|
name: Publish Nuget MPAC
|
|
if: github.ref == 'refs/heads/master' || contains(github.ref, 'hotfix/') || contains(github.ref, 'release/')
|
|
needs: [build]
|
|
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
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: dist
|
|
- run: cp ./configs/mpac.json config.json
|
|
- run: sed -i 's/Azure.Cosmos.DB.Data.Explorer/Azure.Cosmos.DB.Data.Explorer.MPAC/g' DataExplorer.nuspec
|
|
- run: nuget sources add -Name "ADO" -Source "$NUGET_SOURCE" -UserName "jawelton@microsoft.com" -Password "$AZURE_DEVOPS_PAT"
|
|
- run: nuget pack -Version "2.0.0-github-${GITHUB_SHA}"
|
|
- run: nuget push -SkipDuplicate -Source "$NUGET_SOURCE" -ApiKey Az *.nupkg
|
|
- uses: actions/upload-artifact@v3
|
|
name: packages
|
|
with:
|
|
path: "*.nupkg"
|