chore: Fix eslint command #1438
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: build | |
env: | |
NODE_CURRENT_VERSION: "18.16.0" | |
on: | |
push: | |
branches: | |
- master | |
- release | |
- refactor/typescript-migration | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
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.4 | |
with: | |
version: "6.x" | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
cache: 'pnpm' | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- 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 "test-unit=$(./scripts/commands/affected-target-print-array.sh origin/${{github.event.pull_request.base.ref}} test:unit)" >> $GITHUB_OUTPUT | |
echo "test-e2e=$(./scripts/commands/affected-target-print-array.sh origin/${{github.event.pull_request.base.ref}} test:e2e)" >> $GITHUB_OUTPUT | |
echo "sonar=$(./scripts/commands/affected-target-print-array.sh origin/${{github.event.pull_request.base.ref}} sonar)" >> $GITHUB_OUTPUT | |
else | |
echo "test-unit=$(./scripts/commands/projects-target-print-array.sh test:unit)" >> $GITHUB_OUTPUT | |
echo "test-e2e=$(./scripts/commands/projects-target-print-array.sh test:e2e)" >> $GITHUB_OUTPUT | |
echo "sonar=$(./scripts/commands/projects-target-print-array.sh sonar)" >> $GITHUB_OUTPUT | |
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.4 | |
with: | |
version: "6.x" | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" | |
cache: 'pnpm' | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- 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: ["18.16.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.4 | |
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 "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- 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@v2 | |
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@v2 | |
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: ["18.16.0", "20.0.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.4 | |
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 "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- 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.16.0' || matrix.node == '20.0.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.16.0' || matrix.node == '20.0.0' }} | |
run: | | |
echo "NODE_OPTIONS=" >> $GITHUB_ENV | |
install-windows: | |
runs-on: windows-2019 | |
strategy: | |
matrix: | |
node: ["18.16.0"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2.2.4 | |
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 | |
shell: bash | |
run: | | |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- 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: ["18.16.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.4 | |
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 | |
shell: bash | |
run: | | |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- 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" |