From 25c8201fe36e7ea4ae38ad35311b473574dfa57e Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Wed, 25 Aug 2021 07:09:21 -0600 Subject: [PATCH] ci: update circle ci config for all-nuts job (#178) * ci: update circle ci config for all-nuts job * test: correct tests for windows --- .circleci/config.yml | 86 +++++++++++++++++-- test/formatters/deployResultFormatter.test.ts | 12 +++ .../retrieveResultFormatter.test.ts | 12 ++- 3 files changed, 101 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index af35a5997..cea0053c0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,27 +1,72 @@ version: 2.1 orbs: release-management: salesforce/npm-release-management@4 +parameters: + run-auto-workflows: + description: > + Boolean that controls when an workflow would run. + + It is used to gate which workflows should run when github events occur. + + This parameter is used by automation to determine if a workflow will run + within a pipeline. + default: true + type: boolean + run-just-nuts: + description: > + Boolean that controls when the just-nuts will run. + + Default value is false and this parameter is used by automation to + determine if + + the just-nuts workflow will run. + default: false + type: boolean + sfdx_version: + description: | + By default, the latest version of the standalone CLI will be installed. + To install via npm, supply a version tag such as "latest" or "6". + default: '' + type: string + repo_tag: + description: "The tag of the module repo to checkout, '' defaults to branch/PR" + default: '' + type: string + npm_module_name: + description: 'The fully qualified npm module name, i.e. @salesforce/plugins-data' + default: '' + type: string workflows: version: 2 test-and-release: + when: << pipeline.parameters.run-auto-workflows >> jobs: - release-management/validate-pr: filters: branches: ignore: main - # - release-management/test-package: - # name: node-latest - # node_version: latest - release-management/test-package: - name: node-lts - node_version: lts + matrix: + parameters: + os: + - linux + - windows + node_version: + - latest + - lts + - maintenance + exclude: + - os: windows + node_version: lts + - os: windows + node_version: maintenance - release-management/test-nut: name: nuts-on-linux node_version: lts size: large sfdx_version: latest requires: - - node-lts + - release-management/test-package - release-management/test-nut: name: nuts-on-windows sfdx_version: latest @@ -29,15 +74,16 @@ workflows: node_version: lts os: windows requires: - - node-lts + - release-management/test-package - release-management/release-package: sign: true github-release: true requires: - - node-lts + - release-management/test-package filters: branches: only: main + context: CLI_CTC test-ts-update: triggers: - schedule: @@ -48,3 +94,27 @@ workflows: - main jobs: - release-management/test-ts-update + just-nuts: + when: << pipeline.parameters.run-just-nuts >> + jobs: + - release-management/test-nut: + name: just-nuts-<< matrix.os >> + sfdx_version: << pipeline.parameters.sfdx_version >> + sfdx_executable_path: sfdx + repo_tag: << pipeline.parameters.repo_tag >> + matrix: + parameters: + os: + - linux + - windows + npm_module_name: << pipeline.parameters.npm_module_name >> + dependabot-automerge: + triggers: + - schedule: + cron: '0 2,5,8,11 * * *' + filters: + branches: + only: + - main + jobs: + - release-management/dependabot-automerge diff --git a/test/formatters/deployResultFormatter.test.ts b/test/formatters/deployResultFormatter.test.ts index a1be55ca4..821d46b7d 100644 --- a/test/formatters/deployResultFormatter.test.ts +++ b/test/formatters/deployResultFormatter.test.ts @@ -5,10 +5,12 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import * as path from 'path'; import * as sinon from 'sinon'; import { expect } from 'chai'; import { Logger } from '@salesforce/core'; import { UX } from '@salesforce/command'; +import { FileResponse } from '@salesforce/source-deploy-retrieve'; import { stubInterface } from '@salesforce/ts-sinon'; import { getDeployResult } from '../commands/source/deployResponses'; import { DeployCommandResult, DeployResultFormatter } from '../../src/formatters/deployResultFormatter'; @@ -28,6 +30,14 @@ describe('DeployResultFormatter', () => { let styledHeaderStub: sinon.SinonStub; let tableStub: sinon.SinonStub; + const resolveExpectedPaths = (fileResponses: FileResponse[]): void => { + fileResponses.forEach((file) => { + if (file.filePath) { + file.filePath = path.relative(process.cwd(), file.filePath); + } + }); + }; + beforeEach(() => { logStub = sandbox.stub(); styledHeaderStub = sandbox.stub(); @@ -76,6 +86,7 @@ describe('DeployResultFormatter', () => { expect(tableStub.called).to.equal(true); expect(styledHeaderStub.firstCall.args[0]).to.contain('Deployed Source'); const fileResponses = deployResultSuccess.getFileResponses(); + resolveExpectedPaths(fileResponses); expect(tableStub.firstCall.args[0]).to.deep.equal(fileResponses); }); @@ -87,6 +98,7 @@ describe('DeployResultFormatter', () => { expect(tableStub.called).to.equal(true); expect(styledHeaderStub.firstCall.args[0]).to.contain('Component Failures [1]'); const fileResponses = deployResultFailure.getFileResponses(); + resolveExpectedPaths(fileResponses); expect(tableStub.firstCall.args[0]).to.deep.equal(fileResponses); }); diff --git a/test/formatters/retrieveResultFormatter.test.ts b/test/formatters/retrieveResultFormatter.test.ts index e44d33c8f..6f43298ab 100644 --- a/test/formatters/retrieveResultFormatter.test.ts +++ b/test/formatters/retrieveResultFormatter.test.ts @@ -5,11 +5,12 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import { join } from 'path'; +import { join, relative } from 'path'; import * as sinon from 'sinon'; import { expect } from 'chai'; import { Logger } from '@salesforce/core'; import { UX } from '@salesforce/command'; +import { FileResponse } from '@salesforce/source-deploy-retrieve'; import { cloneJson } from '@salesforce/kit'; import { stubInterface } from '@salesforce/ts-sinon'; import { getRetrieveResult } from '../commands/source/retrieveResponses'; @@ -31,6 +32,14 @@ describe('RetrieveResultFormatter', () => { let styledHeaderStub: sinon.SinonStub; let tableStub: sinon.SinonStub; + const resolveExpectedPaths = (fileResponses: FileResponse[]): void => { + fileResponses.forEach((file) => { + if (file.filePath) { + file.filePath = relative(process.cwd(), file.filePath); + } + }); + }; + beforeEach(() => { logStub = sandbox.stub(); styledHeaderStub = sandbox.stub(); @@ -115,6 +124,7 @@ describe('RetrieveResultFormatter', () => { expect(tableStub.called).to.equal(true); expect(styledHeaderStub.firstCall.args[0]).to.contain('Retrieved Source'); const fileResponses = retrieveResultSuccess.getFileResponses(); + resolveExpectedPaths(fileResponses); expect(tableStub.firstCall.args[0]).to.deep.equal(fileResponses); });