Skip to content

feat: Add MocksServer.Config interface allowing to type the configura… #1391

feat: Add MocksServer.Config interface allowing to type the configura…

feat: Add MocksServer.Config interface allowing to type the configura… #1391

Workflow file for this run

name: build
env:
NODE_CURRENT_VERSION: "16.15.0"
on:
push:
branches:
- master
- release
- refactor/typescript-migration
pull_request:
jobs:
get-affected:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
if: github.event_name == 'pull_request'
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: ${{github.event.pull_request.base.ref}}
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: "6.x"
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Get affected
id: get-projects-arrays
run: |
if [[ "${{github.event.pull_request.base.ref}}" != "" ]]; then
echo "::set-output name=test-unit::$(./scripts/commands/affected-target-print-array.sh origin/${{github.event.pull_request.base.ref}} test:unit)"
echo "::set-output name=test-e2e::$(./scripts/commands/affected-target-print-array.sh origin/${{github.event.pull_request.base.ref}} test:e2e)"
echo "::set-output name=sonar::$(./scripts/commands/affected-target-print-array.sh origin/${{github.event.pull_request.base.ref}} sonar)"
else
echo "::set-output name=test-unit::$(./scripts/commands/projects-target-print-array.sh test:unit)"
echo "::set-output name=test-e2e::$(./scripts/commands/projects-target-print-array.sh test:e2e)"
echo "::set-output name=sonar::$(./scripts/commands/projects-target-print-array.sh sonar)"
fi
outputs:
test-unit: ${{ steps.get-projects-arrays.outputs.test-unit }}
test-e2e: ${{ steps.get-projects-arrays.outputs.test-e2e }}
sonar: ${{ steps.get-projects-arrays.outputs.sonar }}
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: "6.x"
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16.x"
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Generate graph
run: pnpm run graph -- --file=graph.json
- name: Build all
run: pnpm run build:all
- name: Lint
run: pnpm run lint
test-unit:
runs-on: ubuntu-latest
needs: [lint, get-affected]
if: ${{ fromJson(needs.get-affected.outputs.test-unit)[0] }}
strategy:
max-parallel: 2
matrix:
node: ["16.15.0"]
projectName: ${{fromJson(needs.get-affected.outputs.test-unit)}}
env:
NODE: ${{ matrix.node }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get project path
id: get-project-path
uses: notiz-dev/github-action-json-property@release
with:
path: "workspace.json"
prop_path: "projects.${{matrix.projectName}}"
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: "6.x"
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Test unit
run: pnpm run nx run-many -- --target test:unit --projects ${{ matrix.projectName }}
- name: Check if coverage exists
id: check-coverage
uses: andstor/file-existence-action@v1
with:
files: "${{steps.get-project-path.outputs.prop}}/coverage/lcov.info"
- name: Upload test results
if: matrix.node == env.NODE_CURRENT_VERSION
uses: actions/upload-artifact@v3
with:
name: coverage-${{ matrix.node }}-${{matrix.projectName}}
path: ${{steps.get-project-path.outputs.prop}}/coverage
retention-days: 1
- name: Convert coverage paths to worskpace
run: pnpm run project:coverage:to-workspace -- --project ${{ matrix.projectName }}
- name: Upload coverage to Codecov
if: steps.check-coverage.outputs.files_exists == 'true'
uses: codecov/codecov-action@v3
with:
directory: ./${{steps.get-project-path.outputs.prop}}/coverage
fail_ci_if_error: false
files: lcov.info
env_vars: NODE
flags: ${{ matrix.projectName }}
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
sonar:
runs-on: ubuntu-latest
needs: [test-unit, get-affected]
if: |
always() &&
needs.get-affected.result == 'success' &&
(needs.test-unit.result == 'success' || needs.test-unit.result == 'skipped') &&
fromJson(needs.get-affected.outputs.sonar)[0]
strategy:
max-parallel: 2
matrix:
projectName: ${{fromJson(needs.get-affected.outputs.sonar)}}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get project path
id: get-project-path
uses: notiz-dev/github-action-json-property@release
with:
path: "workspace.json"
prop_path: "projects.${{matrix.projectName}}"
- name: Check Sonar config
id: check-sonar-config
uses: andstor/file-existence-action@v1
with:
files: "${{steps.get-project-path.outputs.prop}}/sonar-project.properties"
- name: Download test results
if: steps.check-sonar-config.outputs.files_exists == 'true'
continue-on-error: true
uses: actions/download-artifact@v3
with:
name: coverage-${{env.NODE_CURRENT_VERSION}}-${{matrix.projectName}}
path: ${{steps.get-project-path.outputs.prop}}/coverage
- name: SonarCloud Scan
if: ${{ env.SONAR_TOKEN != '' && steps.check-sonar-config.outputs.files_exists == 'true' }}
uses: SonarSource/sonarcloud-github-action@v1.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: ${{steps.get-project-path.outputs.prop}}/
test-e2e:
runs-on: ubuntu-latest
needs: get-affected
if: ${{ fromJson(needs.get-affected.outputs.test-e2e)[0] }}
strategy:
max-parallel: 4
matrix:
node: ["14.19.3","16.15.0","17.9.0", "18.2.0"]
projectName: ${{fromJson(needs.get-affected.outputs.test-e2e)}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: "6.x"
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Set env vars
run: |
echo "NODE_OPTIONS=--openssl-legacy-provider" >> $GITHUB_ENV
if: ${{ matrix.node == '18.2.0' || matrix.node == '17.9.0' }}
- name: Test E2E
run: pnpm run nx run-many -- --target test:e2e --projects ${{ matrix.projectName }}
- name: Unset env vars
if: always() && ${{ matrix.node == '18.2.0' || matrix.node == '17.9.0' }}
run: |
echo "NODE_OPTIONS=" >> $GITHUB_ENV
install-windows:
runs-on: windows-2019
strategy:
matrix:
node: ["16.15.0"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: "6.x"
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
env:
HUSKY_SKIP_INSTALL: 1
test-e2e-windows:
runs-on: windows-2019
needs: [get-affected,install-windows]
if: ${{ fromJson(needs.get-affected.outputs.test-e2e)[0] }}
strategy:
max-parallel: 2
matrix:
node: ["16.15.0"]
projectName: ${{fromJson(needs.get-affected.outputs.test-e2e)}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: "6.x"
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
env:
HUSKY_SKIP_INSTALL: 1
- name: Test E2E
run: pnpm run nx run-many -- --target test:e2e --projects ${{ matrix.projectName }}
build-finished:
runs-on: ubuntu-latest
needs: [test-unit, test-e2e, test-e2e-windows, sonar]
if: |
always() &&
(needs.test-unit.result == 'success' || needs.test-unit.result == 'skipped') &&
(needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped') &&
(needs.test-e2e-windows.result == 'success' || needs.test-e2e-windows.result == 'skipped') &&
(needs.sonar.result == 'success' || needs.sonar.result == 'skipped')
steps:
- name: Trace
run: echo "All jobs finished"