@payfit/nx-core 5.6.10-ephemeral-fix-parallelization-config.4 → 5.6.10
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 +1 -6
- package/migrations.json +0 -5
- package/package.json +1 -2
- package/dist/src/migrations/20251112-fix-parallelization-circleci.d.ts +0 -2
- package/dist/src/migrations/20251112-fix-parallelization-circleci.js +0 -98
- package/dist/src/migrations/20251112-fix-parallelization-circleci.js.map +0 -1
|
@@ -111,12 +111,7 @@ 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
|
-
|
|
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
|
|
114
|
+
echo "$PROJECT_WITH_DOCKER" | circleci tests run --command="xargs -I '{}' bash -c 'npx nx run-many -t docker-build --parallel=3 -p {}'"
|
|
120
115
|
<% } else { -%>
|
|
121
116
|
command: npx nx affected -t docker-build
|
|
122
117
|
<% } %>
|
package/migrations.json
CHANGED
|
@@ -14,11 +14,6 @@
|
|
|
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": "Apply a fix to parallelized jobs so they do not run everything if no affected project",
|
|
21
|
-
"implementation": "./dist/src/migrations/20251112-fix-parallelization-circleci"
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payfit/nx-core",
|
|
3
|
-
"version": "5.6.10
|
|
3
|
+
"version": "5.6.10",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -17,7 +17,6 @@
|
|
|
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",
|
|
21
20
|
"@octokit/auth-app": "^8.0.2",
|
|
22
21
|
"@octokit/rest": "^22.0.0",
|
|
23
22
|
"args-tokenizer": "^0.3.0",
|
|
@@ -1,98 +0,0 @@
|
|
|
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 section
|
|
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
|
-
// Find all jobs that have parallelism set
|
|
28
|
-
const jobsWithParallelism = [];
|
|
29
|
-
if ((0, yaml_1.isMap)(jobs)) {
|
|
30
|
-
// Iterate over all job entries in the jobs map
|
|
31
|
-
for (const item of jobs.items) {
|
|
32
|
-
if (item.key instanceof yaml_1.Scalar) {
|
|
33
|
-
const jobName = item.key.value;
|
|
34
|
-
const job = item.value;
|
|
35
|
-
if ((0, yaml_1.isMap)(job) && job.has('parallelism')) {
|
|
36
|
-
jobsWithParallelism.push({ jobName: jobName.toString(), job });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (jobsWithParallelism.length === 0) {
|
|
42
|
-
logger_1.consola.info('No jobs with parallelism found. Skipping migration.');
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
// Process each job with parallelism to find parallelizable commands
|
|
46
|
-
let updatedAnyJob = false;
|
|
47
|
-
for (const { jobName, job } of jobsWithParallelism) {
|
|
48
|
-
const steps = job.get('steps');
|
|
49
|
-
if (!(0, yaml_1.isSeq)(steps)) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
for (const step of steps.items) {
|
|
53
|
-
if ((0, yaml_1.isMap)(step) && step.has('run')) {
|
|
54
|
-
const runStep = step.get('run');
|
|
55
|
-
if ((0, yaml_1.isMap)(runStep)) {
|
|
56
|
-
const command = runStep.get('command');
|
|
57
|
-
const commandStr = command.toString();
|
|
58
|
-
if (command && commandStr.includes('circleci tests run')) {
|
|
59
|
-
// Check if the command is already using the new parallelization logic
|
|
60
|
-
if (commandStr.includes('No affected project, nothing to do')) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
// Extract the target from the existing command
|
|
64
|
-
const targetMatch = commandStr.match(/(?:-t|--target)\s+([^\s]+)/);
|
|
65
|
-
if (!targetMatch)
|
|
66
|
-
continue;
|
|
67
|
-
const target = targetMatch[1];
|
|
68
|
-
// Extract the parallel value from the existing command (only if it exists)
|
|
69
|
-
const parallelMatch = commandStr.match(/--parallel[=:]?(\d+)/);
|
|
70
|
-
const parallelParam = parallelMatch
|
|
71
|
-
? ` --parallel=${parallelMatch[1]}`
|
|
72
|
-
: '';
|
|
73
|
-
// Replace the old command with the new parallelization logic
|
|
74
|
-
const newCommand = `PROJECTS=$(npx nx show projects --affected --base=$NX_BASE --head=$NX_HEAD --with-target=${target})
|
|
75
|
-
if [ -n "$PROJECTS" ]; then
|
|
76
|
-
echo "$PROJECTS" | circleci tests run --command="xargs -I '{}' bash -c 'npx nx run-many -t ${target}${parallelParam} -p {}'"
|
|
77
|
-
else
|
|
78
|
-
echo "No affected project, nothing to do"
|
|
79
|
-
circleci-agent step halt
|
|
80
|
-
fi`;
|
|
81
|
-
runStep.set('command', newCommand);
|
|
82
|
-
updatedAnyJob = true;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (!updatedAnyJob) {
|
|
89
|
-
logger_1.consola.info('No job needed updating. Skipping migration.');
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// Write back with comments and anchors preserved
|
|
93
|
-
host.write(circleciConfigPath, doc.toString({
|
|
94
|
-
lineWidth: 0, // avoid cutting line on width
|
|
95
|
-
}));
|
|
96
|
-
logger_1.consola.info('Successfully updated jobs with parallelism to use skip if no affected project');
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=20251112-fix-parallelization-circleci.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"20251112-fix-parallelization-circleci.js","sourceRoot":"","sources":["../../../src/migrations/20251112-fix-parallelization-circleci.ts"],"names":[],"mappings":";;AAKA,yBA6GC;AAjHD,+BAAmE;AAEnE,mDAAgD;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