From 6d9fcebe48f6372309691e81ae7b78e4fde9bdab Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 14:45:49 -0500 Subject: [PATCH 01/17] Add a dynamic config setup in .circleci/dynamic/index.ts --- .circleci/config.yml | 76 +++---------- .circleci/dynamic/dynamicConfig.yml | 14 +++ .circleci/dynamic/index.ts | 76 +++++++++++++ .circleci/dynamic/package-lock.json | 165 ++++++++++++++++++++++++++++ .circleci/dynamic/package.json | 21 ++++ .circleci/dynamic/tsconfig.json | 20 ++++ 6 files changed, 309 insertions(+), 63 deletions(-) create mode 100644 .circleci/dynamic/dynamicConfig.yml create mode 100644 .circleci/dynamic/index.ts create mode 100644 .circleci/dynamic/package-lock.json create mode 100644 .circleci/dynamic/package.json create mode 100644 .circleci/dynamic/tsconfig.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 6688ac6..eb6583b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,71 +1,21 @@ -# https://circleci.com/docs/2.0/config-intro/ - version: 2.1 - orbs: - node: circleci/node@5.0.0 - + continuation: circleci/continuation@0.3 + node: circleci/node@5.0 +setup: true jobs: - js-build: - docker: - - image: cimg/node:14.18 + generate-config: + executor: node/default steps: - checkout - - node/install-packages + - node/install-packages: + app-dir: .circleci/dynamic - run: - name: Running JS linting and unit test - command: | - npm run lint:js - npm run test:js - - php-lint: - docker: - - image: cimg/php:8.1 - steps: - - checkout - - run: - name: Linting PHP - command: | - composer i - composer lint - - php-test: - parameters: - php-version-number: - type: string - docker: - - image: cimg/php:<< parameters.php-version-number >> - steps: - - checkout - - run: - name: Testing PHP - command: | - composer i - composer test - - e2e-test: - machine: - image: ubuntu-2004:202111-02 - steps: - - checkout - - node/install-packages - - run: - name: Running e2e tests - command: | - npm run wp-env start - npm run test:e2e - - store_artifacts: - path: artifacts - + name: Generate config + command: 'cd .circleci/dynamic && npm run start' + - continuation/continue: + configuration_path: ./dynamicConfig.yml workflows: - test-lint: + dynamic-workflow: jobs: - - js-build - - php-lint - - php-test: - requires: - - php-lint - matrix: - parameters: - php-version-number: [ '7.3', '7.4', '8.0', '8.1' ] - - e2e-test + - generate-config diff --git a/.circleci/dynamic/dynamicConfig.yml b/.circleci/dynamic/dynamicConfig.yml new file mode 100644 index 0000000..a8a2672 --- /dev/null +++ b/.circleci/dynamic/dynamicConfig.yml @@ -0,0 +1,14 @@ +# This configuration has been automatically generated by the CircleCI Config SDK. +# For more information, see https://github.com/CircleCI-Public/circleci-config-sdk-ts +# SDK Version: 0.0.0-development + +version: 2.1 +setup: false +jobs: {} +workflows: + test-lint: + jobs: + - js-build + - php-lint + - php-test + - e2e-test diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts new file mode 100644 index 0000000..230d603 --- /dev/null +++ b/.circleci/dynamic/index.ts @@ -0,0 +1,76 @@ +import * as fs from 'fs'; +import CircleCI from '@circleci/circleci-config-sdk'; + +const config = new CircleCI.Config(); +const workflow = new CircleCI.Workflow('test-lint'); +config.addWorkflow(workflow); + +const nodeExecutor = new CircleCI.executors.DockerExecutor('cimg/node:14.18'); +const phpExecutor = new CircleCI.executors.DockerExecutor('cimg/php:8.1'); +const e2eExecutor = new CircleCI.executors.MachineExecutor('large', 'ubuntu-2004:202111-02'); + +const nodeOrb = new CircleCI.orb.OrbImport('node', 'circleci', 'node', '5.0'); +const phpOrb = new CircleCI.orb.OrbImport('php', 'circleci', 'php', '1.1'); + +workflow + .addJob( + new CircleCI.Job( + 'js-build', + nodeExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { + command: nodeOrb.commands['install-packages']?.name, + } ), + new CircleCI.commands.Run( { + name: 'Running JS linting and unit test', + command: `npm run lint:js \n npm run test:js`, + } ), + ] + ) + ) + .addJob( + new CircleCI.Job( + 'php-lint', + phpExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { command: 'composer i' } ), + new CircleCI.commands.Run( { command: 'composer lint' } ), + ] + ) + ) + .addJob( + new CircleCI.Job( + 'php-test', + phpExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { command: 'composer i' } ), + new CircleCI.commands.Run( { command: 'composer test' } ), + ] + ) + ) + .addJob( + new CircleCI.Job( + 'e2e-test', + e2eExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { + command: 'npm ci', + } ), + new CircleCI.commands.Run( { + name: 'Running e2e tests', + command: 'npm run wp-env start && npm run test:e2e', + } ), + new CircleCI.commands.StoreArtifacts({ path: 'artifacts' }), + ] + ) + ); + +fs.writeFile( + './dynamicConfig.yml', + config.stringify(), + () => {} +); diff --git a/.circleci/dynamic/package-lock.json b/.circleci/dynamic/package-lock.json new file mode 100644 index 0000000..612072e --- /dev/null +++ b/.circleci/dynamic/package-lock.json @@ -0,0 +1,165 @@ +{ + "name": "circleci-tutorial-for-beginners-dynamic-config", + "version": "0.1.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@circleci/circleci-config-sdk": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@circleci/circleci-config-sdk/-/circleci-config-sdk-0.10.1.tgz", + "integrity": "sha512-QSJBYXTza3UiO2UcmHJQhORkF6UzYOVtddS2cCjDraUkonF4uCawBXXksPXnCaLI98HU8uPwwVVJhdrbJreKQw==", + "dev": true, + "requires": { + "yaml": "2.1.1" + } + }, + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", + "dev": true + }, + "@types/node": { + "version": "18.7.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.20.tgz", + "integrity": "sha512-adzY4vLLr5Uivmx8+zfSJ5fbdgKxX8UMtjtl+17n0B1q1Nz8JEmE151vefMdpD+1gyh+77weN4qEhej/O7budQ==", + "dev": true + }, + "acorn": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", + "dev": true + }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + } + }, + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "dev": true + }, + "typescript": { + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", + "dev": true + }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "yaml": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", + "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", + "dev": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + } + } +} diff --git a/.circleci/dynamic/package.json b/.circleci/dynamic/package.json new file mode 100644 index 0000000..03da50f --- /dev/null +++ b/.circleci/dynamic/package.json @@ -0,0 +1,21 @@ +{ + "name": "circleci-tutorial-for-beginners-dynamic-config", + "version": "0.1.0", + "description": "Dynamic CircleCI® config", + "main": "index.ts", + "type": "module", + "scripts": { + "start": "ts-node --esm index.ts" + }, + "keywords": [], + "author": "Ryan Kienstra", + "license": "GPL-2.0-or-later", + "devDependencies": { + "@circleci/circleci-config-sdk": "^0.10.1", + "@types/node": "^18.7.20", + "ts-node": "^10.9.1", + "tslib": "^2.4.0", + "typescript": "^4.8.3" + }, + "dependencies": {} +} diff --git a/.circleci/dynamic/tsconfig.json b/.circleci/dynamic/tsconfig.json new file mode 100644 index 0000000..add7ca5 --- /dev/null +++ b/.circleci/dynamic/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "noImplicitAny": false, + "module": "ESNext", + "target": "ESNext", + "moduleResolution": "Node", + "esModuleInterop": true, + "jsx": "react", + "allowJs": true, + "checkJs": true, + "sourceMap": true, + "noEmit": true + }, + "include": [ + "index.ts" + ], + "exclude": [ + "node_modules/" + ] +} From 8dfae6e926f6075eafae131a04aa593579f79f74 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 14:54:59 -0500 Subject: [PATCH 02/17] Make the configuration_path different --- .circleci/config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eb6583b..251408c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,9 +12,10 @@ jobs: app-dir: .circleci/dynamic - run: name: Generate config - command: 'cd .circleci/dynamic && npm run start' + command: npm run start + working_directory: .circleci/dynamic - continuation/continue: - configuration_path: ./dynamicConfig.yml + configuration_path: .circleci/dynamic/dynamicConfig.yml workflows: dynamic-workflow: jobs: From ed3d6c602b81d19a56fc0e9e2e9ec103ce52f7a3 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 15:01:03 -0500 Subject: [PATCH 03/17] Add a .gitignore for dynamicConfig.yml --- .circleci/config.yml | 2 +- .circleci/dynamic/.gitignore | 1 + .circleci/dynamic/index.ts | 108 +++++++++++++++++------------------ 3 files changed, 55 insertions(+), 56 deletions(-) create mode 100644 .circleci/dynamic/.gitignore diff --git a/.circleci/config.yml b/.circleci/config.yml index 251408c..6332edd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: app-dir: .circleci/dynamic - run: name: Generate config - command: npm run start + command: npm start working_directory: .circleci/dynamic - continuation/continue: configuration_path: .circleci/dynamic/dynamicConfig.yml diff --git a/.circleci/dynamic/.gitignore b/.circleci/dynamic/.gitignore new file mode 100644 index 0000000..5c47936 --- /dev/null +++ b/.circleci/dynamic/.gitignore @@ -0,0 +1 @@ +dynamicConfig.yml diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 230d603..3bf3b89 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -12,62 +12,60 @@ const e2eExecutor = new CircleCI.executors.MachineExecutor('large', 'ubuntu-2004 const nodeOrb = new CircleCI.orb.OrbImport('node', 'circleci', 'node', '5.0'); const phpOrb = new CircleCI.orb.OrbImport('php', 'circleci', 'php', '1.1'); -workflow - .addJob( - new CircleCI.Job( - 'js-build', - nodeExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { - command: nodeOrb.commands['install-packages']?.name, - } ), - new CircleCI.commands.Run( { - name: 'Running JS linting and unit test', - command: `npm run lint:js \n npm run test:js`, - } ), - ] - ) +const jobs = [ + new CircleCI.Job( + 'js-build', + nodeExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { + command: nodeOrb.commands['install-packages']?.name, + } ), + new CircleCI.commands.Run( { + name: 'Running JS linting and unit test', + command: `npm run lint:js \n npm run test:js`, + } ), + ] + ), + new CircleCI.Job( + 'php-lint', + phpExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { command: 'composer i' } ), + new CircleCI.commands.Run( { command: 'composer lint' } ), + ] + ), + new CircleCI.Job( + 'php-test', + phpExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { command: 'composer i' } ), + new CircleCI.commands.Run( { command: 'composer test' } ), + ] + ), + new CircleCI.Job( + 'e2e-test', + e2eExecutor, + [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run( { + command: 'npm ci', + } ), + new CircleCI.commands.Run( { + name: 'Running e2e tests', + command: 'npm run wp-env start && npm run test:e2e', + } ), + new CircleCI.commands.StoreArtifacts({ path: 'artifacts' }), + ] ) - .addJob( - new CircleCI.Job( - 'php-lint', - phpExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { command: 'composer i' } ), - new CircleCI.commands.Run( { command: 'composer lint' } ), - ] - ) - ) - .addJob( - new CircleCI.Job( - 'php-test', - phpExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { command: 'composer i' } ), - new CircleCI.commands.Run( { command: 'composer test' } ), - ] - ) - ) - .addJob( - new CircleCI.Job( - 'e2e-test', - e2eExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { - command: 'npm ci', - } ), - new CircleCI.commands.Run( { - name: 'Running e2e tests', - command: 'npm run wp-env start && npm run test:e2e', - } ), - new CircleCI.commands.StoreArtifacts({ path: 'artifacts' }), - ] - ) - ); +]; + +jobs.forEach((job) => { + config.addJob(job) + workflow.addJob(job) +}); fs.writeFile( './dynamicConfig.yml', From 313733e01db833d65067bccdfefaceeed193228a Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:20:00 -0500 Subject: [PATCH 04/17] Add dynamicConfig.yml to .gitignore --- .circleci/dynamic/.gitignore | 1 - .circleci/dynamic/index.ts | 2 +- .gitignore | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 .circleci/dynamic/.gitignore diff --git a/.circleci/dynamic/.gitignore b/.circleci/dynamic/.gitignore deleted file mode 100644 index 5c47936..0000000 --- a/.circleci/dynamic/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dynamicConfig.yml diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 3bf3b89..5c43920 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -19,7 +19,7 @@ const jobs = [ [ new CircleCI.commands.Checkout(), new CircleCI.commands.Run( { - command: nodeOrb.commands['install-packages']?.name, + command: 'npm i', } ), new CircleCI.commands.Run( { name: 'Running JS linting and unit test', diff --git a/.gitignore b/.gitignore index 022b988..ff0855c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules vendor +.circleci/dynamic/dynamicConfig.yml From 4e3476b30dda87a081575090707f55518b562220 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:20:47 -0500 Subject: [PATCH 05/17] Remove dynamicConfig.yml, now that it's in .gitignore --- .circleci/dynamic/dynamicConfig.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .circleci/dynamic/dynamicConfig.yml diff --git a/.circleci/dynamic/dynamicConfig.yml b/.circleci/dynamic/dynamicConfig.yml deleted file mode 100644 index a8a2672..0000000 --- a/.circleci/dynamic/dynamicConfig.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This configuration has been automatically generated by the CircleCI Config SDK. -# For more information, see https://github.com/CircleCI-Public/circleci-config-sdk-ts -# SDK Version: 0.0.0-development - -version: 2.1 -setup: false -jobs: {} -workflows: - test-lint: - jobs: - - js-build - - php-lint - - php-test - - e2e-test From 80d9b21c6baac791b88d6f82be97e51611643caa Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:28:46 -0500 Subject: [PATCH 06/17] Empty commit to trigger build From 8001422553e75c711f0eb2e31a1f63f5b7c975d3 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:35:12 -0500 Subject: [PATCH 07/17] Simplify tsconfig.json file --- .circleci/dynamic/tsconfig.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.circleci/dynamic/tsconfig.json b/.circleci/dynamic/tsconfig.json index add7ca5..5ba2111 100644 --- a/.circleci/dynamic/tsconfig.json +++ b/.circleci/dynamic/tsconfig.json @@ -1,19 +1,11 @@ { "compilerOptions": { - "noImplicitAny": false, "module": "ESNext", "target": "ESNext", "moduleResolution": "Node", "esModuleInterop": true, - "jsx": "react", - "allowJs": true, - "checkJs": true, - "sourceMap": true, "noEmit": true }, - "include": [ - "index.ts" - ], "exclude": [ "node_modules/" ] From b5816f3268d3c0cc51ea9ede6c23a27f73525c3d Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:40:58 -0500 Subject: [PATCH 08/17] Add prettier to config --- .circleci/dynamic/index.ts | 107 ++++++++++++---------------- .circleci/dynamic/package-lock.json | 6 ++ .circleci/dynamic/package.json | 8 ++- 3 files changed, 56 insertions(+), 65 deletions(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 5c43920..a02b5cc 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -1,74 +1,57 @@ -import * as fs from 'fs'; -import CircleCI from '@circleci/circleci-config-sdk'; +import * as fs from "fs"; +import CircleCI from "@circleci/circleci-config-sdk"; const config = new CircleCI.Config(); -const workflow = new CircleCI.Workflow('test-lint'); +const workflow = new CircleCI.Workflow("test-lint"); config.addWorkflow(workflow); -const nodeExecutor = new CircleCI.executors.DockerExecutor('cimg/node:14.18'); -const phpExecutor = new CircleCI.executors.DockerExecutor('cimg/php:8.1'); -const e2eExecutor = new CircleCI.executors.MachineExecutor('large', 'ubuntu-2004:202111-02'); +const nodeExecutor = new CircleCI.executors.DockerExecutor("cimg/node:14.18"); +const phpExecutor = new CircleCI.executors.DockerExecutor("cimg/php:8.1"); +const e2eExecutor = new CircleCI.executors.MachineExecutor( + "large", + "ubuntu-2004:202111-02" +); -const nodeOrb = new CircleCI.orb.OrbImport('node', 'circleci', 'node', '5.0'); -const phpOrb = new CircleCI.orb.OrbImport('php', 'circleci', 'php', '1.1'); +const nodeOrb = new CircleCI.orb.OrbImport("node", "circleci", "node", "5.0"); +const phpOrb = new CircleCI.orb.OrbImport("php", "circleci", "php", "1.1"); const jobs = [ - new CircleCI.Job( - 'js-build', - nodeExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { - command: 'npm i', - } ), - new CircleCI.commands.Run( { - name: 'Running JS linting and unit test', - command: `npm run lint:js \n npm run test:js`, - } ), - ] - ), - new CircleCI.Job( - 'php-lint', - phpExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { command: 'composer i' } ), - new CircleCI.commands.Run( { command: 'composer lint' } ), - ] - ), - new CircleCI.Job( - 'php-test', - phpExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { command: 'composer i' } ), - new CircleCI.commands.Run( { command: 'composer test' } ), - ] - ), - new CircleCI.Job( - 'e2e-test', - e2eExecutor, - [ - new CircleCI.commands.Checkout(), - new CircleCI.commands.Run( { - command: 'npm ci', - } ), - new CircleCI.commands.Run( { - name: 'Running e2e tests', - command: 'npm run wp-env start && npm run test:e2e', - } ), - new CircleCI.commands.StoreArtifacts({ path: 'artifacts' }), - ] - ) + new CircleCI.Job("js-build", nodeExecutor, [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run({ + command: "npm i", + }), + new CircleCI.commands.Run({ + name: "Running JS linting and unit test", + command: `npm run lint:js \n npm run test:js`, + }), + ]), + new CircleCI.Job("php-lint", phpExecutor, [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run({ command: "composer i" }), + new CircleCI.commands.Run({ command: "composer lint" }), + ]), + new CircleCI.Job("php-test", phpExecutor, [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run({ command: "composer i" }), + new CircleCI.commands.Run({ command: "composer test" }), + ]), + new CircleCI.Job("e2e-test", e2eExecutor, [ + new CircleCI.commands.Checkout(), + new CircleCI.commands.Run({ + command: "npm ci", + }), + new CircleCI.commands.Run({ + name: "Running e2e tests", + command: "npm run wp-env start && npm run test:e2e", + }), + new CircleCI.commands.StoreArtifacts({ path: "artifacts" }), + ]), ]; jobs.forEach((job) => { - config.addJob(job) - workflow.addJob(job) + config.addJob(job); + workflow.addJob(job); }); -fs.writeFile( - './dynamicConfig.yml', - config.stringify(), - () => {} -); +fs.writeFile("./dynamicConfig.yml", config.stringify(), () => {}); diff --git a/.circleci/dynamic/package-lock.json b/.circleci/dynamic/package-lock.json index 612072e..40153dc 100644 --- a/.circleci/dynamic/package-lock.json +++ b/.circleci/dynamic/package-lock.json @@ -110,6 +110,12 @@ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", "dev": true }, + "prettier": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", + "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "dev": true + }, "ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", diff --git a/.circleci/dynamic/package.json b/.circleci/dynamic/package.json index 03da50f..d7b4545 100644 --- a/.circleci/dynamic/package.json +++ b/.circleci/dynamic/package.json @@ -2,20 +2,22 @@ "name": "circleci-tutorial-for-beginners-dynamic-config", "version": "0.1.0", "description": "Dynamic CircleCI® config", + "author": "Ryan Kienstra", "main": "index.ts", "type": "module", "scripts": { + "lint": "prettier --check index.ts", + "lint:fix": "prettier --write index.ts", "start": "ts-node --esm index.ts" }, "keywords": [], - "author": "Ryan Kienstra", "license": "GPL-2.0-or-later", "devDependencies": { "@circleci/circleci-config-sdk": "^0.10.1", "@types/node": "^18.7.20", + "prettier": "^2.7.1", "ts-node": "^10.9.1", "tslib": "^2.4.0", "typescript": "^4.8.3" - }, - "dependencies": {} + } } From c7c2e4a99ee04f08eb2cd0acdded58aa2a4ea4b5 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:45:27 -0500 Subject: [PATCH 09/17] Remove needles exclude of node_modules That might be the default. --- .circleci/dynamic/tsconfig.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.circleci/dynamic/tsconfig.json b/.circleci/dynamic/tsconfig.json index 5ba2111..01d16a2 100644 --- a/.circleci/dynamic/tsconfig.json +++ b/.circleci/dynamic/tsconfig.json @@ -5,8 +5,5 @@ "moduleResolution": "Node", "esModuleInterop": true, "noEmit": true - }, - "exclude": [ - "node_modules/" - ] + } } From 2b032a8de3ffc9bb867580a903a1de7ad7747f18 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 16:46:03 -0500 Subject: [PATCH 10/17] Remove needless keywords --- .circleci/dynamic/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/dynamic/package.json b/.circleci/dynamic/package.json index d7b4545..8fb79e5 100644 --- a/.circleci/dynamic/package.json +++ b/.circleci/dynamic/package.json @@ -10,7 +10,6 @@ "lint:fix": "prettier --write index.ts", "start": "ts-node --esm index.ts" }, - "keywords": [], "license": "GPL-2.0-or-later", "devDependencies": { "@circleci/circleci-config-sdk": "^0.10.1", From 3ec16fca26b0580081e9071261afdcf993918720 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 18:10:30 -0500 Subject: [PATCH 11/17] Use the orb commands install-packages --- .circleci/dynamic/index.ts | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index a02b5cc..1368dc5 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -12,15 +12,38 @@ const e2eExecutor = new CircleCI.executors.MachineExecutor( "ubuntu-2004:202111-02" ); -const nodeOrb = new CircleCI.orb.OrbImport("node", "circleci", "node", "5.0"); -const phpOrb = new CircleCI.orb.OrbImport("php", "circleci", "php", "1.1"); +const manifest: CircleCI.types.orb.OrbImportManifest = { + jobs: {}, + commands: { + "install-packages": new CircleCI.parameters.CustomParametersList(), + }, + executors: {}, +}; + +const nodeOrb = new CircleCI.orb.OrbImport( + "node", + "circleci", + "node", + "5.0", + undefined, + manifest +); +const phpOrb = new CircleCI.orb.OrbImport( + "php", + "circleci", + "php", + "1.1", + undefined, + manifest +); + +config.importOrb(nodeOrb); +config.importOrb(phpOrb); const jobs = [ new CircleCI.Job("js-build", nodeExecutor, [ new CircleCI.commands.Checkout(), - new CircleCI.commands.Run({ - command: "npm i", - }), + new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), new CircleCI.commands.Run({ name: "Running JS linting and unit test", command: `npm run lint:js \n npm run test:js`, @@ -28,19 +51,17 @@ const jobs = [ ]), new CircleCI.Job("php-lint", phpExecutor, [ new CircleCI.commands.Checkout(), - new CircleCI.commands.Run({ command: "composer i" }), + new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), new CircleCI.commands.Run({ command: "composer lint" }), ]), new CircleCI.Job("php-test", phpExecutor, [ new CircleCI.commands.Checkout(), - new CircleCI.commands.Run({ command: "composer i" }), + new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), new CircleCI.commands.Run({ command: "composer test" }), ]), new CircleCI.Job("e2e-test", e2eExecutor, [ new CircleCI.commands.Checkout(), - new CircleCI.commands.Run({ - command: "npm ci", - }), + new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), new CircleCI.commands.Run({ name: "Running e2e tests", command: "npm run wp-env start && npm run test:e2e", From c2a9d53073a341cfd48f2410dc56d7978f63c23b Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 18:17:52 -0500 Subject: [PATCH 12/17] Add a matrix for php-test for the PHP version --- .circleci/dynamic/index.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 1368dc5..80f5606 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -6,7 +6,9 @@ const workflow = new CircleCI.Workflow("test-lint"); config.addWorkflow(workflow); const nodeExecutor = new CircleCI.executors.DockerExecutor("cimg/node:14.18"); -const phpExecutor = new CircleCI.executors.DockerExecutor("cimg/php:8.1"); +const phpExecutor = new CircleCI.executors.DockerExecutor( + "cimg/php:<< parameters.php-version-number >>" +); const e2eExecutor = new CircleCI.executors.MachineExecutor( "large", "ubuntu-2004:202111-02" @@ -40,7 +42,7 @@ const phpOrb = new CircleCI.orb.OrbImport( config.importOrb(nodeOrb); config.importOrb(phpOrb); -const jobs = [ +[ new CircleCI.Job("js-build", nodeExecutor, [ new CircleCI.commands.Checkout(), new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), @@ -68,11 +70,14 @@ const jobs = [ }), new CircleCI.commands.StoreArtifacts({ path: "artifacts" }), ]), -]; - -jobs.forEach((job) => { +].forEach((job) => { config.addJob(job); - workflow.addJob(job); + workflow.addJob( + job, + job.name === "php-test" + ? { matrix: { "php-version-number": ["7.3", "7.4", "8.0", "8.1"] } } + : undefined + ); }); fs.writeFile("./dynamicConfig.yml", config.stringify(), () => {}); From 3a2e8889fb96d63dd7006d0eae389cdb560673fb Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 18:37:32 -0500 Subject: [PATCH 13/17] Add a parameterized executor --- .circleci/dynamic/index.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 80f5606..00c1747 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -7,8 +7,22 @@ config.addWorkflow(workflow); const nodeExecutor = new CircleCI.executors.DockerExecutor("cimg/node:14.18"); const phpExecutor = new CircleCI.executors.DockerExecutor( - "cimg/php:<< parameters.php-version-number >>" + "cimg/php:8.1" ); + +const reusablePhpExecutor = new CircleCI.reusable.ReusableExecutor( + 'php', + new CircleCI.executors.DockerExecutor("cimg/php:<< parameters.php-version-number >>"), + new CircleCI.parameters.CustomParametersList( + [ + new CircleCI.parameters.CustomParameter( + 'php-version-number', + CircleCI.mapping.ParameterSubtype.STRING + ), + ], + ), +); + const e2eExecutor = new CircleCI.executors.MachineExecutor( "large", "ubuntu-2004:202111-02" @@ -56,7 +70,7 @@ config.importOrb(phpOrb); new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), new CircleCI.commands.Run({ command: "composer lint" }), ]), - new CircleCI.Job("php-test", phpExecutor, [ + new CircleCI.Job("php-test", reusablePhpExecutor.executor, [ new CircleCI.commands.Checkout(), new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), new CircleCI.commands.Run({ command: "composer test" }), @@ -71,7 +85,7 @@ config.importOrb(phpOrb); new CircleCI.commands.StoreArtifacts({ path: "artifacts" }), ]), ].forEach((job) => { - config.addJob(job); + config.addJob(job).defineParameter("php-version-number", "string"); workflow.addJob( job, job.name === "php-test" From c2d011f3a179c7670bd645d9da2b2ac889d5865a Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 18:43:27 -0500 Subject: [PATCH 14/17] Remove the config parameters --- .circleci/dynamic/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 00c1747..42e2680 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -85,7 +85,7 @@ config.importOrb(phpOrb); new CircleCI.commands.StoreArtifacts({ path: "artifacts" }), ]), ].forEach((job) => { - config.addJob(job).defineParameter("php-version-number", "string"); + config.addJob(job); workflow.addJob( job, job.name === "php-test" From 38c21a4c84d296a7e8b1fa1547cac473fba0e808 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 18:50:20 -0500 Subject: [PATCH 15/17] Add a php-version-number parameter to the test-php job --- .circleci/dynamic/index.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 42e2680..88b82ab 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -6,21 +6,21 @@ const workflow = new CircleCI.Workflow("test-lint"); config.addWorkflow(workflow); const nodeExecutor = new CircleCI.executors.DockerExecutor("cimg/node:14.18"); -const phpExecutor = new CircleCI.executors.DockerExecutor( - "cimg/php:8.1" -); +const phpExecutor = new CircleCI.executors.DockerExecutor("cimg/php:8.1"); const reusablePhpExecutor = new CircleCI.reusable.ReusableExecutor( - 'php', - new CircleCI.executors.DockerExecutor("cimg/php:<< parameters.php-version-number >>"), + "php", + new CircleCI.executors.DockerExecutor( + "cimg/php:<< parameters.php-version-number >>" + ), new CircleCI.parameters.CustomParametersList( [ new CircleCI.parameters.CustomParameter( - 'php-version-number', + "php-version-number", CircleCI.mapping.ParameterSubtype.STRING ), - ], - ), + ] + ) ); const e2eExecutor = new CircleCI.executors.MachineExecutor( @@ -70,11 +70,16 @@ config.importOrb(phpOrb); new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), new CircleCI.commands.Run({ command: "composer lint" }), ]), - new CircleCI.Job("php-test", reusablePhpExecutor.executor, [ - new CircleCI.commands.Checkout(), - new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), - new CircleCI.commands.Run({ command: "composer test" }), - ]), + new CircleCI.reusable.ParameterizedJob( + "php-test", + reusablePhpExecutor.executor + ) + .defineParameter("php-version-number", "string") + .addStep(new CircleCI.commands.Checkout()) + .addStep( + new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]) + ) + .addStep(new CircleCI.commands.Run({ command: "composer test" })), new CircleCI.Job("e2e-test", e2eExecutor, [ new CircleCI.commands.Checkout(), new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), From cc96591d5f974ffea7f81d7eb6d11646c9af9dbc Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 18:58:56 -0500 Subject: [PATCH 16/17] Remove some needless constants --- .circleci/dynamic/index.ts | 103 +++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 88b82ab..7376966 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -5,30 +5,8 @@ const config = new CircleCI.Config(); const workflow = new CircleCI.Workflow("test-lint"); config.addWorkflow(workflow); -const nodeExecutor = new CircleCI.executors.DockerExecutor("cimg/node:14.18"); -const phpExecutor = new CircleCI.executors.DockerExecutor("cimg/php:8.1"); - -const reusablePhpExecutor = new CircleCI.reusable.ReusableExecutor( - "php", - new CircleCI.executors.DockerExecutor( - "cimg/php:<< parameters.php-version-number >>" - ), - new CircleCI.parameters.CustomParametersList( - [ - new CircleCI.parameters.CustomParameter( - "php-version-number", - CircleCI.mapping.ParameterSubtype.STRING - ), - ] - ) -); - -const e2eExecutor = new CircleCI.executors.MachineExecutor( - "large", - "ubuntu-2004:202111-02" -); - -const manifest: CircleCI.types.orb.OrbImportManifest = { +const phpVersionParameterName = "php-version-number"; +const orbManifest: CircleCI.types.orb.OrbImportManifest = { jobs: {}, commands: { "install-packages": new CircleCI.parameters.CustomParametersList(), @@ -42,7 +20,7 @@ const nodeOrb = new CircleCI.orb.OrbImport( "node", "5.0", undefined, - manifest + orbManifest ); const phpOrb = new CircleCI.orb.OrbImport( "php", @@ -50,51 +28,74 @@ const phpOrb = new CircleCI.orb.OrbImport( "php", "1.1", undefined, - manifest + orbManifest ); config.importOrb(nodeOrb); config.importOrb(phpOrb); [ - new CircleCI.Job("js-build", nodeExecutor, [ - new CircleCI.commands.Checkout(), - new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), - new CircleCI.commands.Run({ - name: "Running JS linting and unit test", - command: `npm run lint:js \n npm run test:js`, - }), - ]), - new CircleCI.Job("php-lint", phpExecutor, [ - new CircleCI.commands.Checkout(), - new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), - new CircleCI.commands.Run({ command: "composer lint" }), - ]), + new CircleCI.Job( + "js-build", + new CircleCI.executors.DockerExecutor("cimg/node:14.18"), + [ + new CircleCI.commands.Checkout(), + new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), + new CircleCI.commands.Run({ + name: "Running JS linting and unit test", + command: `npm run lint:js \n npm run test:js`, + }), + ] + ), + new CircleCI.Job( + "php-lint", + new CircleCI.executors.DockerExecutor("cimg/php:8.1"), + [ + new CircleCI.commands.Checkout(), + new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]), + new CircleCI.commands.Run({ command: "composer lint" }), + ] + ), new CircleCI.reusable.ParameterizedJob( "php-test", - reusablePhpExecutor.executor + new CircleCI.reusable.ReusableExecutor( + "php", + new CircleCI.executors.DockerExecutor( + "cimg/php:<< parameters.php-version-number >>" + ), + new CircleCI.parameters.CustomParametersList([ + new CircleCI.parameters.CustomParameter( + phpVersionParameterName, + CircleCI.mapping.ParameterSubtype.STRING + ), + ]) + ).executor ) - .defineParameter("php-version-number", "string") + .defineParameter(phpVersionParameterName, "string") .addStep(new CircleCI.commands.Checkout()) .addStep( new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"]) ) .addStep(new CircleCI.commands.Run({ command: "composer test" })), - new CircleCI.Job("e2e-test", e2eExecutor, [ - new CircleCI.commands.Checkout(), - new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), - new CircleCI.commands.Run({ - name: "Running e2e tests", - command: "npm run wp-env start && npm run test:e2e", - }), - new CircleCI.commands.StoreArtifacts({ path: "artifacts" }), - ]), + new CircleCI.Job( + "e2e-test", + new CircleCI.executors.MachineExecutor("large", "ubuntu-2004:202111-02"), + [ + new CircleCI.commands.Checkout(), + new CircleCI.reusable.ReusedCommand(nodeOrb.commands["install-packages"]), + new CircleCI.commands.Run({ + name: "Running e2e tests", + command: "npm run wp-env start && npm run test:e2e", + }), + new CircleCI.commands.StoreArtifacts({ path: "artifacts" }), + ] + ), ].forEach((job) => { config.addJob(job); workflow.addJob( job, job.name === "php-test" - ? { matrix: { "php-version-number": ["7.3", "7.4", "8.0", "8.1"] } } + ? { matrix: { [phpVersionParameterName]: ["7.3", "7.4", "8.0", "8.1"] } } : undefined ); }); From 72b000cbc19804330faeb5edd7b3812783a41860 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Sat, 24 Sep 2022 19:05:11 -0500 Subject: [PATCH 17/17] Replace 'string' with an enum --- .circleci/dynamic/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/dynamic/index.ts b/.circleci/dynamic/index.ts index 7376966..6e796c3 100644 --- a/.circleci/dynamic/index.ts +++ b/.circleci/dynamic/index.ts @@ -71,7 +71,7 @@ config.importOrb(phpOrb); ]) ).executor ) - .defineParameter(phpVersionParameterName, "string") + .defineParameter(phpVersionParameterName, CircleCI.mapping.ParameterSubtype.STRING) .addStep(new CircleCI.commands.Checkout()) .addStep( new CircleCI.reusable.ReusedCommand(phpOrb.commands["install-packages"])