From 713cbc11bd44bc38bd454ab1d0a6d630748a0d71 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Wed, 22 Mar 2023 12:17:17 -0700 Subject: [PATCH] ci: Run prettier in repo-policy-check pipeline (#14703) There's a gap in our prettier coverage in CI. If you edit a file in the root, or, say, the `scripts` folder, it won't trigger a CI job that includes prettier. The reason is that the client release group pipeline is responsible for running prettier on the root files, but it's not triggered by edits outside the client release group/pipeline. There is a CI pipeline that runs on every PR: repo-policy-check. I fixed this by adding a step to that pipeline that runs `npm run prettier:root`. I also added pnpm store caching to the repo-policy-check job and removed the layer-check and policy-check from the client pipeline since those checks are repo-wide and done already in repo-policy-check. --- tools/pipelines/build-client.yml | 2 -- tools/pipelines/repo-policy-check.yml | 36 ++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/tools/pipelines/build-client.yml b/tools/pipelines/build-client.yml index 2e56677080d3..17acecc2c7cc 100644 --- a/tools/pipelines/build-client.yml +++ b/tools/pipelines/build-client.yml @@ -103,8 +103,6 @@ extends: - ci:test:stress:tinylicious - test:copyresults checks: - - policy-check - - layer-check - syncpack:deps - syncpack:versions - prettier diff --git a/tools/pipelines/repo-policy-check.yml b/tools/pipelines/repo-policy-check.yml index 5c220a499030..47e2592dcdb7 100644 --- a/tools/pipelines/repo-policy-check.yml +++ b/tools/pipelines/repo-policy-check.yml @@ -21,6 +21,8 @@ pool: variables: - name: skipComponentGovernanceDetection value: true +- name: pnpmStorePath + value: $(Pipeline.Workspace)/.pnpm-store steps: - task: UseNode@1 @@ -28,15 +30,30 @@ steps: inputs: version: 16.x +- task: Cache@2 + displayName: Cache pnpm store + inputs: + # Caches are already scoped to individual pipelines, so no need to include the release group name or tag + # in the cache key + key: 'pnpm-store | "$(Agent.OS)" | pnpm-lock.yaml' + path: ${{ variables.pnpmStorePath }} + restoreKeys: | + pnpm-store | "$(Agent.OS)" + - task: Bash@3 - displayName: Install root dependencies + displayName: Install and configure pnpm inputs: targetType: 'inline' - workingDirectory: . script: | - # Install pnpm globally npm i -g pnpm + pnpm config set store-dir $(pnpmStorePath) +- task: Bash@3 + displayName: Install root dependencies + inputs: + targetType: 'inline' + workingDirectory: . + script: | # We only want to install the root package deps, so we set recursive-install to false pnpm config set recursive-install false pnpm install --frozen-lockfile @@ -52,3 +69,16 @@ steps: inputs: command: 'custom' customCommand: 'run layer-check' + +- task: Npm@1 + displayName: npm run prettier:root + inputs: + command: 'custom' + customCommand: 'run prettier:root' + +- task: Bash@3 + displayName: Prune pnpm store + inputs: + targetType: 'inline' + script: | + pnpm store prune