@payfit/nx-core 5.6.9 → 5.6.10-ephemeral-fix-parallelization-config.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/generators/init/globalFiles/.circleci/config.yml.template +6 -1
- package/dist/src/migrations/20251112-fix-parallelization-circleci.d.ts +2 -0
- package/dist/src/migrations/20251112-fix-parallelization-circleci.js +87 -0
- package/dist/src/migrations/20251112-fix-parallelization-circleci.js.map +1 -0
- package/migrations.json +5 -0
- package/package.json +2 -1
|
@@ -111,7 +111,12 @@ jobs:
|
|
|
111
111
|
<% if (parallelizeDockerBuilds > 0) { -%>
|
|
112
112
|
command: |
|
|
113
113
|
PROJECT_WITH_DOCKER=$(npx nx show projects --affected --base=$NX_BASE --head=$NX_HEAD --with-target=docker-build)
|
|
114
|
-
|
|
114
|
+
if [ -n "$PROJECT_WITH_DOCKER" ]; then
|
|
115
|
+
echo "$PROJECT_WITH_DOCKER" | circleci tests run --command="xargs -I '{}' bash -c 'npx nx run-many -t docker-build --parallel=3 -p {}'"
|
|
116
|
+
else
|
|
117
|
+
echo "No affected project, nothing to do"
|
|
118
|
+
circleci-agent step halt
|
|
119
|
+
fi
|
|
115
120
|
<% } else { -%>
|
|
116
121
|
command: npx nx affected -t docker-build
|
|
117
122
|
<% } %>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const yaml_1 = require("yaml");
|
|
5
|
+
const logger_1 = require("../utils/common/logger");
|
|
6
|
+
function update(host) {
|
|
7
|
+
const circleciConfigPath = '.circleci/config.yml';
|
|
8
|
+
// Check if the CircleCI config file exists
|
|
9
|
+
if (!host.exists(circleciConfigPath)) {
|
|
10
|
+
logger_1.consola.warn(`${circleciConfigPath} not found. Skipping migration.`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
// Read the CircleCI config file
|
|
14
|
+
const circleciConfig = host.read(circleciConfigPath, 'utf-8');
|
|
15
|
+
if (!circleciConfig) {
|
|
16
|
+
logger_1.consola.warn(`${circleciConfigPath} is empty. Skipping migration.`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Parse the YAML document while preserving comments and anchors
|
|
20
|
+
const doc = (0, yaml_1.parseDocument)(circleciConfig);
|
|
21
|
+
// Navigate to jobs.docker-build
|
|
22
|
+
const jobs = doc.get('jobs');
|
|
23
|
+
if (!(0, yaml_1.isMap)(jobs)) {
|
|
24
|
+
logger_1.consola.warn('No jobs section found. Skipping migration.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const dockerBuildJob = jobs.get('docker-build');
|
|
28
|
+
if (!(0, yaml_1.isMap)(dockerBuildJob)) {
|
|
29
|
+
logger_1.consola.warn('No docker-build job found. Skipping migration.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Check if the job has parallelism set (indicating it should use parallel builds)
|
|
33
|
+
const parallelism = dockerBuildJob.get('parallelism');
|
|
34
|
+
if (!parallelism) {
|
|
35
|
+
logger_1.consola.info('docker-build job does not have parallelism set. Skipping migration.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Find the run step with the docker-build command
|
|
39
|
+
const steps = dockerBuildJob.get('steps');
|
|
40
|
+
if (!(0, yaml_1.isSeq)(steps)) {
|
|
41
|
+
logger_1.consola.warn('No steps found in docker-build job. Skipping migration.');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let dockerBuildRunStep = null;
|
|
45
|
+
for (const step of steps.items) {
|
|
46
|
+
if ((0, yaml_1.isMap)(step) && step.has('run')) {
|
|
47
|
+
const runStep = step.get('run');
|
|
48
|
+
if ((0, yaml_1.isMap)(runStep)) {
|
|
49
|
+
const name = runStep.get('name');
|
|
50
|
+
if (name === 'docker-build') {
|
|
51
|
+
dockerBuildRunStep = runStep;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!dockerBuildRunStep) {
|
|
58
|
+
logger_1.consola.warn('Could not find docker-build run step. Skipping migration.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const command = dockerBuildRunStep.get('command');
|
|
62
|
+
if (!command) {
|
|
63
|
+
logger_1.consola.warn('No command found in docker-build run step. Skipping migration.');
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Check if the command is already fixed
|
|
67
|
+
const commandStr = command.toString();
|
|
68
|
+
if (commandStr.includes('if [ -n "$PROJECT_WITH_DOCKER" ]; then')) {
|
|
69
|
+
logger_1.consola.info('docker-build command already fixed. Skipping migration.');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// Replace the old command with the new parallelization logic
|
|
73
|
+
const newCommand = `PROJECT_WITH_DOCKER=$(npx nx show projects --affected --base=$NX_BASE --head=$NX_HEAD --with-target=docker-build)
|
|
74
|
+
if [ -n "$PROJECT_WITH_DOCKER" ]; then
|
|
75
|
+
echo "$PROJECT_WITH_DOCKER" | circleci tests run --command="xargs -I '{}' bash -c 'npx nx run-many -t docker-build --parallel=3 -p {}'"
|
|
76
|
+
else
|
|
77
|
+
echo "No affected project, nothing to do"
|
|
78
|
+
circleci-agent step halt
|
|
79
|
+
fi`;
|
|
80
|
+
dockerBuildRunStep.set('command', newCommand);
|
|
81
|
+
// Write back with comments and anchors preserved
|
|
82
|
+
host.write(circleciConfigPath, doc.toString({
|
|
83
|
+
lineWidth: 0, // avoid cutting line on width
|
|
84
|
+
}));
|
|
85
|
+
logger_1.consola.info('Successfully updated docker-build job to use parallelization logic in .circleci/config.yml');
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=20251112-fix-parallelization-circleci.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20251112-fix-parallelization-circleci.js","sourceRoot":"","sources":["../../../src/migrations/20251112-fix-parallelization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6D;IAC7D,MAAM,UAAU,GAAG;;;;;;GAMlB,CAAA;IAED,kBAAkB,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;IAE7C,iDAAiD;IACjD,IAAI,CAAC,KAAK,CACR,kBAAkB,EAClB,GAAG,CAAC,QAAQ,CAAC;QACX,SAAS,EAAE,CAAC,EAAE,8BAA8B;KAC7C,CAAC,CACH,CAAA;IACD,gBAAO,CAAC,IAAI,CACV,4FAA4F,CAC7F,CAAA;AACH,CAAC"}
|
package/migrations.json
CHANGED
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"version": "5.2.0",
|
|
15
15
|
"description": "Adds nx-conformance CI step as a requirement for the publish step",
|
|
16
16
|
"implementation": "./dist/src/migrations/20251029-nx-conformance-requirement-publish"
|
|
17
|
+
},
|
|
18
|
+
"20251112-fix-parallelization-circleci": {
|
|
19
|
+
"version": "5.7.0",
|
|
20
|
+
"description": "Migration for v5.7.0",
|
|
21
|
+
"implementation": "./dist/src/migrations/20251112-fix-parallelization-circleci"
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/nx-core",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.10-ephemeral-fix-parallelization-config.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@cdktf/hcl2json": "0.21.0",
|
|
18
18
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
19
19
|
"@inquirer/prompts": "^7.8.6",
|
|
20
|
+
"@nx/devkit": "22.0.1",
|
|
20
21
|
"@octokit/auth-app": "^8.0.2",
|
|
21
22
|
"@octokit/rest": "^22.0.0",
|
|
22
23
|
"args-tokenizer": "^0.3.0",
|