@invarn/cibuild 2.6.4 → 2.6.5
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/cli.cjs +10 -10
- package/dist/src/yaml/preflight-validation.d.ts +12 -23
- package/dist/src/yaml/preflight-validation.d.ts.map +1 -1
- package/dist/src/yaml/preflight-validation.js +11 -142
- package/dist/src/yaml/steps/git-clone.d.ts +8 -2
- package/dist/src/yaml/steps/git-clone.d.ts.map +1 -1
- package/dist/src/yaml/steps/git-clone.js +8 -2
- package/dist/src/yaml/steps/index.d.ts.map +1 -1
- package/dist/src/yaml/steps/index.js +9 -5
- package/package.json +1 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pre-flight validation
|
|
3
|
-
*
|
|
2
|
+
* Pre-flight validation hook that runs before any workflow step executes.
|
|
3
|
+
*
|
|
4
|
+
* It no longer checks anything. The checks it used to carry — that
|
|
5
|
+
* CIBUILD_GIT_REPOSITORY_URL is set and reachable, and that activate-ssh-key
|
|
6
|
+
* precedes git-clone — assumed cibuild would clone the repository itself. It
|
|
7
|
+
* does not: the source is already on disk when a pipeline runs (a runner
|
|
8
|
+
* checks out the dispatched commit before cibuild starts; locally it is the
|
|
9
|
+
* working copy), so there is no remote to validate before execution. The
|
|
10
|
+
* class and its `validate()` signature are kept so the call site in
|
|
11
|
+
* pipeline-with-secrets.ts is unchanged.
|
|
4
12
|
*/
|
|
5
|
-
import { MissingEnvironmentVariableError } from './env-resolver.js';
|
|
13
|
+
import type { MissingEnvironmentVariableError } from './env-resolver.js';
|
|
6
14
|
import type { SecretsManager } from './secrets-manager.js';
|
|
7
15
|
import type { YAMLWorkflow } from './types.js';
|
|
8
16
|
/**
|
|
@@ -12,28 +20,9 @@ export interface PreFlightResult {
|
|
|
12
20
|
success: boolean;
|
|
13
21
|
error?: MissingEnvironmentVariableError;
|
|
14
22
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Validates that required environment variables exist and repository is accessible
|
|
17
|
-
* This runs before any workflow steps execute
|
|
18
|
-
*/
|
|
19
23
|
export declare class PreFlightValidator {
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param workflow The workflow to check
|
|
23
|
-
* @returns True if SSH key setup is in the workflow
|
|
24
|
-
*/
|
|
25
|
-
private hasSSHKeySetup;
|
|
26
|
-
/**
|
|
27
|
-
* Validates CIBUILD_GIT_REPOSITORY_URL exists and is accessible
|
|
28
|
-
* @param env Environment variables
|
|
29
|
-
* @param secretsManager Secrets manager to check for stored secrets
|
|
30
|
-
* @param workflow The workflow to check for SSH key setup
|
|
31
|
-
* @returns Validation result
|
|
32
|
-
*/
|
|
33
|
-
validateRepositoryAccess(env: Record<string, string>, secretsManager?: SecretsManager, workflow?: YAMLWorkflow): Promise<PreFlightResult>;
|
|
34
|
-
/**
|
|
35
|
-
* Run all pre-flight validations
|
|
36
|
-
* git-clone now uses the local checkout — no remote URL or connectivity check needed.
|
|
25
|
+
* Run all pre-flight validations. Always succeeds — see the file comment.
|
|
37
26
|
*/
|
|
38
27
|
validate(_env: Record<string, string>, _secretsManager?: SecretsManager, _workflow?: YAMLWorkflow): Promise<PreFlightResult>;
|
|
39
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight-validation.d.ts","sourceRoot":"","sources":["../../../src/yaml/preflight-validation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"preflight-validation.d.ts","sourceRoot":"","sources":["../../../src/yaml/preflight-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,+BAA+B,CAAC;CACzC;AAED,qBAAa,kBAAkB;IAC7B;;OAEG;IACG,QAAQ,CACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,eAAe,CAAC,EAAE,cAAc,EAChC,SAAS,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,eAAe,CAAC;CAG5B"}
|
|
@@ -1,149 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pre-flight validation
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
2
|
+
* Pre-flight validation hook that runs before any workflow step executes.
|
|
3
|
+
*
|
|
4
|
+
* It no longer checks anything. The checks it used to carry — that
|
|
5
|
+
* CIBUILD_GIT_REPOSITORY_URL is set and reachable, and that activate-ssh-key
|
|
6
|
+
* precedes git-clone — assumed cibuild would clone the repository itself. It
|
|
7
|
+
* does not: the source is already on disk when a pipeline runs (a runner
|
|
8
|
+
* checks out the dispatched commit before cibuild starts; locally it is the
|
|
9
|
+
* working copy), so there is no remote to validate before execution. The
|
|
10
|
+
* class and its `validate()` signature are kept so the call site in
|
|
11
|
+
* pipeline-with-secrets.ts is unchanged.
|
|
10
12
|
*/
|
|
11
13
|
export class PreFlightValidator {
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param workflow The workflow to check
|
|
15
|
-
* @returns True if SSH key setup is in the workflow
|
|
16
|
-
*/
|
|
17
|
-
hasSSHKeySetup(workflow) {
|
|
18
|
-
if (!workflow.steps || workflow.steps.length === 0) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
let foundSSHKeyStep = false;
|
|
22
|
-
for (const step of workflow.steps) {
|
|
23
|
-
// Step can be an object with step name as key
|
|
24
|
-
const stepName = typeof step === 'string' ? step : Object.keys(step)[0];
|
|
25
|
-
// Check for git-clone step first - if we hit it before finding SSH key, return false
|
|
26
|
-
if (stepName.startsWith('git-clone')) {
|
|
27
|
-
return foundSSHKeyStep; // Return true only if we found SSH key before this
|
|
28
|
-
}
|
|
29
|
-
// Check for activate-ssh-key step
|
|
30
|
-
if (stepName.startsWith('activate-ssh-key')) {
|
|
31
|
-
foundSSHKeyStep = true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// If we got here, no git-clone step was found, so return if SSH key exists
|
|
35
|
-
return foundSSHKeyStep;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Validates CIBUILD_GIT_REPOSITORY_URL exists and is accessible
|
|
39
|
-
* @param env Environment variables
|
|
40
|
-
* @param secretsManager Secrets manager to check for stored secrets
|
|
41
|
-
* @param workflow The workflow to check for SSH key setup
|
|
42
|
-
* @returns Validation result
|
|
43
|
-
*/
|
|
44
|
-
async validateRepositoryAccess(env, secretsManager, workflow) {
|
|
45
|
-
// Check environment variables first, then secrets manager
|
|
46
|
-
let repoUrl = env.CIBUILD_GIT_REPOSITORY_URL || env.GIT_REPOSITORY_URL || '';
|
|
47
|
-
// If not in env, check secrets manager
|
|
48
|
-
if ((!repoUrl || repoUrl.trim() === '') && secretsManager) {
|
|
49
|
-
const secretId = secretsManager.getSecretIdByName('CIBUILD_GIT_REPOSITORY_URL');
|
|
50
|
-
if (secretId) {
|
|
51
|
-
repoUrl = secretsManager.getSecret(secretId) || '';
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// Check if repository URL is provided
|
|
55
|
-
if (!repoUrl || repoUrl.trim() === '') {
|
|
56
|
-
return {
|
|
57
|
-
success: false,
|
|
58
|
-
error: new MissingEnvironmentVariableError('CIBUILD_GIT_REPOSITORY_URL', 'preflight-validation', 'Git repository URL for cloning source code in CI/CD builds.\n\n' +
|
|
59
|
-
'Expected format:\n' +
|
|
60
|
-
' ┌────────────────────────────────────────────────────────┐\n' +
|
|
61
|
-
' │ https://github.com/username/repository.git │\n' +
|
|
62
|
-
' │ git@github.com:username/repository.git │\n' +
|
|
63
|
-
' │ https://gitlab.com/username/repository.git │\n' +
|
|
64
|
-
' └────────────────────────────────────────────────────────┘\n\n' +
|
|
65
|
-
'How to set it:\n' +
|
|
66
|
-
' • Environment variable: GIT_REPOSITORY_URL=<your-repo-url>\n' +
|
|
67
|
-
' • In YAML inputs: repository: <your-repo-url>\n' +
|
|
68
|
-
' • CI platform automatically provides this in most cases'),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// If the workflow uses activate-ssh-key, skip connectivity test entirely.
|
|
72
|
-
// SSH authentication isn't available pre-execution, so any network test would fail
|
|
73
|
-
// for private repos regardless of whether the URL is SSH or HTTPS format.
|
|
74
|
-
const hasSSHKeyInWorkflow = workflow ? this.hasSSHKeySetup(workflow) : false;
|
|
75
|
-
if (hasSSHKeyInWorkflow) {
|
|
76
|
-
console.log('🔍 Pre-flight: Validating repository URL...');
|
|
77
|
-
console.log(` Repository: ${repoUrl}`);
|
|
78
|
-
console.log(' SSH authentication will be configured by activate-ssh-key step');
|
|
79
|
-
console.log('✅ Pre-flight: Repository URL validated (connectivity test skipped)\n');
|
|
80
|
-
return { success: true };
|
|
81
|
-
}
|
|
82
|
-
// Test repository connectivity using git ls-remote
|
|
83
|
-
try {
|
|
84
|
-
console.log('🔍 Pre-flight: Validating repository access...');
|
|
85
|
-
console.log(` Repository: ${repoUrl}`);
|
|
86
|
-
// Execute git ls-remote to check if repository is accessible
|
|
87
|
-
// This command lists remote references without cloning
|
|
88
|
-
// Timeout after 10 seconds to prevent hanging
|
|
89
|
-
execSync(`git ls-remote "${repoUrl}" HEAD`, {
|
|
90
|
-
stdio: 'pipe',
|
|
91
|
-
timeout: 10000,
|
|
92
|
-
encoding: 'utf-8',
|
|
93
|
-
});
|
|
94
|
-
console.log('✅ Pre-flight: Repository is accessible\n');
|
|
95
|
-
return { success: true };
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
// Repository is not accessible - analyze the error
|
|
99
|
-
const errorMessage = error.message || String(error);
|
|
100
|
-
console.log(`❌ Pre-flight: Repository access failed`);
|
|
101
|
-
console.log(` Error: ${errorMessage}\n`);
|
|
102
|
-
// Check if this is an SSH authentication error
|
|
103
|
-
const isSSHAuthError = errorMessage.includes('Permission denied') &&
|
|
104
|
-
errorMessage.includes('publickey');
|
|
105
|
-
const isSSHUrl = repoUrl.startsWith('git@') || repoUrl.includes('ssh://');
|
|
106
|
-
if (isSSHAuthError || (isSSHUrl && errorMessage.includes('Could not read from remote'))) {
|
|
107
|
-
// SSH authentication is the issue, not the repository URL
|
|
108
|
-
console.log('⚠️ Repository URL is valid, but SSH authentication is required.\n');
|
|
109
|
-
console.log('Please ensure:');
|
|
110
|
-
console.log(' 1. SSH key is configured in your workflow (activate-ssh-key step)');
|
|
111
|
-
console.log(' 2. SSH key has access to this repository');
|
|
112
|
-
console.log(' 3. SSH key is added to your GitHub/GitLab account\n');
|
|
113
|
-
throw new Error('Pre-flight validation failed: SSH authentication required.\n\n' +
|
|
114
|
-
`Repository: ${repoUrl}\n\n` +
|
|
115
|
-
'The repository URL is valid but requires SSH authentication.\n' +
|
|
116
|
-
'Make sure your workflow includes an "activate-ssh-key" step before "git-clone".\n\n' +
|
|
117
|
-
'Example workflow:\n' +
|
|
118
|
-
' steps:\n' +
|
|
119
|
-
' - activate-ssh-key@4: # Add SSH key first\n' +
|
|
120
|
-
' inputs:\n' +
|
|
121
|
-
' ssh_key_save_path: $HOME/.ssh/bitrise_rsa\n' +
|
|
122
|
-
' - git-clone@6: # Then clone\n\n' +
|
|
123
|
-
`Error details: ${errorMessage}`);
|
|
124
|
-
}
|
|
125
|
-
// For other errors (invalid URL, network issues, etc.), return error
|
|
126
|
-
return {
|
|
127
|
-
success: false,
|
|
128
|
-
error: new MissingEnvironmentVariableError('CIBUILD_GIT_REPOSITORY_URL', 'preflight-validation', 'Git repository URL validation failed. The repository is not accessible.\n\n' +
|
|
129
|
-
'Expected format:\n' +
|
|
130
|
-
' ┌────────────────────────────────────────────────────────┐\n' +
|
|
131
|
-
' │ https://github.com/username/repository.git │\n' +
|
|
132
|
-
' │ git@github.com:username/repository.git │\n' +
|
|
133
|
-
' │ https://gitlab.com/username/repository.git │\n' +
|
|
134
|
-
' └────────────────────────────────────────────────────────┘\n\n' +
|
|
135
|
-
'Common issues:\n' +
|
|
136
|
-
' • Invalid repository URL\n' +
|
|
137
|
-
' • Network connectivity issues\n' +
|
|
138
|
-
' • Repository does not exist or is private\n' +
|
|
139
|
-
' • Wrong URL format (check for typos)\n\n' +
|
|
140
|
-
`Error details: ${errorMessage}`),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Run all pre-flight validations
|
|
146
|
-
* git-clone now uses the local checkout — no remote URL or connectivity check needed.
|
|
15
|
+
* Run all pre-flight validations. Always succeeds — see the file comment.
|
|
147
16
|
*/
|
|
148
17
|
async validate(_env, _secretsManager, _workflow) {
|
|
149
18
|
return { success: true };
|
|
@@ -15,8 +15,14 @@ export interface GitCloneInputs {
|
|
|
15
15
|
clone_into_dir?: string;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* git-clone step executor.
|
|
19
|
+
*
|
|
20
|
+
* Does not clone. The source is already on disk when this runs — on a runner
|
|
21
|
+
* the dispatched commit was checked out before cibuild started (see
|
|
22
|
+
* cibuild-runner's GitCloneRunner); locally it is the developer's working copy.
|
|
23
|
+
* The step locates that checkout and republishes its commit metadata. Every
|
|
24
|
+
* input in GitCloneInputs is accepted so existing YAML keeps parsing, and none
|
|
25
|
+
* of them is read.
|
|
20
26
|
*/
|
|
21
27
|
export declare class GitCloneStepExecutor extends BaseStepExecutor {
|
|
22
28
|
getValidationRequirements(_inputs: GitCloneInputs, _env: Record<string, string>, _config: CIConfig): ValidationRequirement[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-clone.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/git-clone.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED
|
|
1
|
+
{"version":3,"file":"git-clone.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/git-clone.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD,yBAAyB,CACvB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,OAAO,EAAE,QAAQ,GAChB,qBAAqB,EAAE;IAU1B,UAAU,IAAI,UAAU,EAAE;IAkDpB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;CAqD1G"}
|
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BaseStepExecutor } from './base.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* git-clone step executor.
|
|
7
|
+
*
|
|
8
|
+
* Does not clone. The source is already on disk when this runs — on a runner
|
|
9
|
+
* the dispatched commit was checked out before cibuild started (see
|
|
10
|
+
* cibuild-runner's GitCloneRunner); locally it is the developer's working copy.
|
|
11
|
+
* The step locates that checkout and republishes its commit metadata. Every
|
|
12
|
+
* input in GitCloneInputs is accepted so existing YAML keeps parsing, and none
|
|
13
|
+
* of them is read.
|
|
8
14
|
*/
|
|
9
15
|
export class GitCloneStepExecutor extends BaseStepExecutor {
|
|
10
16
|
getValidationRequirements(_inputs, _env, _config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CA07C7C"}
|
|
@@ -32,28 +32,32 @@ import { UiFidelityRenderAndroidStepExecutor, DEFAULT_GRADLE_TASK, DEFAULT_PACKA
|
|
|
32
32
|
*/
|
|
33
33
|
export function initializeStepRegistry() {
|
|
34
34
|
// Git steps
|
|
35
|
+
// Does not clone. The source is already on disk when any step runs — on a
|
|
36
|
+
// runner the dispatched commit is checked out before cibuild starts; locally
|
|
37
|
+
// it is the developer's working copy. The inputs are kept so existing YAML
|
|
38
|
+
// keeps parsing; the executor never reads them.
|
|
35
39
|
registerStep('git-clone', new GitCloneStepExecutor(), {
|
|
36
40
|
name: 'git-clone',
|
|
37
|
-
description: '
|
|
41
|
+
description: 'Locate the source checkout already on disk and record its commit. Does not clone — on a runner the dispatched commit is checked out before any step runs; locally it is your working copy. Inputs are ignored.',
|
|
38
42
|
platform: 'all',
|
|
39
43
|
inputs: {
|
|
40
44
|
repository: {
|
|
41
|
-
description: '
|
|
45
|
+
description: 'Ignored — no clone is performed; the checkout already exists',
|
|
42
46
|
required: false,
|
|
43
47
|
default: '$CIBUILD_GIT_REPOSITORY_URL',
|
|
44
48
|
},
|
|
45
49
|
branch: {
|
|
46
|
-
description: '
|
|
50
|
+
description: 'Ignored — on a runner the dispatched ref is checked out, not this value',
|
|
47
51
|
required: false,
|
|
48
52
|
default: '$CIBUILD_GIT_BRANCH or main',
|
|
49
53
|
},
|
|
50
54
|
clone_depth: {
|
|
51
|
-
description: '
|
|
55
|
+
description: 'Ignored — no clone is performed; a runner checkout is always depth 1',
|
|
52
56
|
required: false,
|
|
53
57
|
default: 0,
|
|
54
58
|
},
|
|
55
59
|
clone_into_dir: {
|
|
56
|
-
description: '
|
|
60
|
+
description: 'Ignored — the checkout location is not chosen by this step',
|
|
57
61
|
required: false,
|
|
58
62
|
default: '.',
|
|
59
63
|
},
|