@ckeditor/ckeditor5-dev-ci 54.5.0 → 54.6.1

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/README.md CHANGED
@@ -129,6 +129,26 @@ These commands accept a mix of environment variables and command line arguments.
129
129
  Can be omitted if it matches `--slug`.
130
130
  - `--release-branch` — *(Optional)* Branch that leads the release process.
131
131
 
132
+ - ⚙️ **`ckeditor5-dev-ci-trigger-snyk-scan`**
133
+
134
+ Publishes Snyk code and dependency snapshots for the current branch.
135
+ It configures the Snyk CLI to use the EU endpoint and the provided organization, then runs `snyk code test --report` and `snyk monitor --all-projects --exclude=external,tests`.
136
+
137
+ **Environment variables:**
138
+ - `SNYK_TOKEN` — Snyk token used for authentication.
139
+
140
+ **CircleCI-provided variables:**
141
+ - `CIRCLE_BRANCH` — Git branch used as Snyk's `target-reference`.
142
+
143
+ **Parameters:**
144
+ - `--exclude` — *(Optional, repeatable)* Directory or file name passed to Snyk's `--exclude`. Use multiple times, for example `--exclude=external --exclude=tests`. Defaults to `external` and `tests`.
145
+ - `--organization` — Snyk organization ID or slug.
146
+
147
+ **Behavior:**
148
+ - Excludes directories and files named `external` and `tests` from dependency snapshot detection by default, and allows overriding that list with repeated `--exclude` flags.
149
+ - Accepts exit code `1` from `snyk code test --report`, so code snapshots are still published when vulnerabilities are found.
150
+ - Requires exit code `0` from `snyk monitor --all-projects`, because any other code means the dependency snapshot was not created.
151
+
132
152
  ## Changelog
133
153
 
134
154
  See the [`CHANGELOG.md`](https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-ci/CHANGELOG.md) file.
@@ -112,8 +112,9 @@ async function waitForOtherJobsAndSendNotification() {
112
112
  return waitForOtherJobsAndSendNotification();
113
113
  }
114
114
 
115
- // If any ignored job failed, all of its children will be marked as 'failed_parent', and thus will not trigger this check.
116
- const anyJobsFailed = jobs.some( job => job.status === 'failed' );
115
+ // If any ignored job failed or was canceled, all of its children will be marked as
116
+ // 'failed_parent', and thus will not trigger this check.
117
+ const anyJobsFailed = jobs.some( job => job.status === 'failed' || job.status === 'canceled' );
117
118
 
118
119
  if ( anyJobsFailed ) {
119
120
  return execSync( task, { stdio: 'inherit' } );
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
5
+ * For licensing, see LICENSE.md.
6
+ */
7
+
8
+ import { parseArgs } from 'node:util';
9
+ import runSnykCommand from '../lib/run-snyk-command.js';
10
+
11
+ const SNYK_ENDPOINT = 'https://api.eu.snyk.io';
12
+
13
+ try {
14
+ const { CIRCLE_BRANCH, SNYK_TOKEN } = process.env;
15
+
16
+ const { values } = parseArgs( {
17
+ options: {
18
+ exclude: {
19
+ default: [ 'external', 'tests' ],
20
+ multiple: true,
21
+ type: 'string'
22
+ },
23
+ organization: {
24
+ type: 'string'
25
+ }
26
+ },
27
+ strict: true
28
+ } );
29
+
30
+ if ( !values.organization ) {
31
+ throw new Error( 'Missing required argument: --organization' );
32
+ }
33
+
34
+ if ( !SNYK_TOKEN ) {
35
+ throw new Error( 'Missing environment variable: SNYK_TOKEN' );
36
+ }
37
+
38
+ if ( !CIRCLE_BRANCH ) {
39
+ throw new Error( 'Missing environment variable: CIRCLE_BRANCH' );
40
+ }
41
+
42
+ await runSnykCommand( [ 'config', 'set', `endpoint=${ SNYK_ENDPOINT }` ] );
43
+ await runSnykCommand( [ 'config', 'set', `org=${ values.organization }` ] );
44
+
45
+ await runSnykCommand(
46
+ [
47
+ 'code',
48
+ 'test',
49
+ '--report',
50
+ '--project-name=Code analysis',
51
+ `--target-reference=${ CIRCLE_BRANCH }`
52
+ ],
53
+
54
+ /**
55
+ * Snyk CLI returns exit code 1 when vulnerabilities are found. Since we want to publish
56
+ * the snapshot even if there are some vulnerabilities, we need to allow exit code 1.
57
+ */
58
+ [ 0, 1 ]
59
+ );
60
+
61
+ await runSnykCommand(
62
+ [
63
+ 'monitor',
64
+ '--all-projects',
65
+ `--exclude=${ values.exclude.join( ',' ) }`,
66
+ `--target-reference=${ CIRCLE_BRANCH }`
67
+ ],
68
+
69
+ /**
70
+ * Unlike `snyk code test --report`, `snyk monitor` reports a successful snapshot upload
71
+ * only with exit code 0. Any other exit code means the dependency snapshot was not created.
72
+ */
73
+ [ 0 ]
74
+ );
75
+ } catch ( error ) {
76
+ console.error( error );
77
+ process.exitCode = 1;
78
+ }
@@ -64,6 +64,11 @@ function isJobFailed( job ) {
64
64
  return true;
65
65
  }
66
66
 
67
+ // See: https://github.com/ckeditor/ckeditor5/issues/19978.
68
+ if ( job.status === 'canceled' ) {
69
+ return true;
70
+ }
71
+
67
72
  if ( job.status === 'failed_parent' ) {
68
73
  return true;
69
74
  }
@@ -85,7 +90,7 @@ function clone( obj ) {
85
90
  *
86
91
  * @property {string} id
87
92
  *
88
- * @property {'blocked'|'running'|'failed'|'failed_parent'|'success'} status
93
+ * @property {'blocked'|'running'|'failed'|'canceled'|'failed_parent'|'success'|'skipped'} status
89
94
  *
90
95
  * @property {Array.<string>} dependencies
91
96
  */
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */
5
+
6
+ import { spawn } from 'node:child_process';
7
+
8
+ /**
9
+ * Runs the Snyk CLI through `pnpm exec` and resolves only for explicitly allowed exit codes.
10
+ * This lets callers tolerate Snyk's non-zero "findings present" codes when a snapshot should still be published.
11
+ *
12
+ * @param {Array<string>} snykArguments CLI arguments passed to `snyk`.
13
+ * @param {Array<number>} [allowedExitCodes=[ 0 ]] Exit codes treated as successful.
14
+ * @returns {Promise<void>}
15
+ */
16
+ export default function runSnykCommand( snykArguments, allowedExitCodes = [ 0 ] ) {
17
+ return new Promise( ( resolve, reject ) => {
18
+ const childProcess = spawn( 'pnpm', [ '--silent', 'exec', 'snyk', ...snykArguments ], {
19
+ cwd: process.cwd(),
20
+ stdio: 'inherit'
21
+ } );
22
+
23
+ childProcess.on( 'error', reject );
24
+ childProcess.on( 'close', exitCode => {
25
+ if ( allowedExitCodes.includes( exitCode ) ) {
26
+ resolve();
27
+
28
+ return;
29
+ }
30
+
31
+ reject( new Error( `Snyk command failed with exit code ${ exitCode }.` ) );
32
+ } );
33
+ } );
34
+ }
@@ -6,6 +6,8 @@
6
6
  const FINISHED_STATUSES = [
7
7
  'success',
8
8
  'failed',
9
+ // See: https://github.com/ckeditor/ckeditor5/issues/19978.
10
+ 'canceled',
9
11
  'failed_parent',
10
12
  // See: https://github.com/ckeditor/ckeditor5/issues/18359.
11
13
  'skipped'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-ci",
3
- "version": "54.5.0",
3
+ "version": "54.6.1",
4
4
  "description": "Utils used on various Continuous Integration services.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -23,16 +23,18 @@
23
23
  "lib"
24
24
  ],
25
25
  "bin": {
26
- "ckeditor5-dev-ci-notify-circle-status": "bin/notify-circle-status.js",
26
+ "ckeditor5-dev-ci-circle-enable-auto-cancel-builds": "bin/circle-enable-auto-cancel-builds.js",
27
+ "ckeditor5-dev-ci-circle-disable-auto-cancel-builds": "bin/circle-disable-auto-cancel-builds.js",
27
28
  "ckeditor5-dev-ci-circle-workflow-notifier": "bin/circle-workflow-notifier.js",
28
29
  "ckeditor5-dev-ci-is-job-triggered-by-member": "bin/is-job-triggered-by-member.js",
29
30
  "ckeditor5-dev-ci-is-workflow-restarted": "bin/is-workflow-restarted.js",
31
+ "ckeditor5-dev-ci-notify-circle-status": "bin/notify-circle-status.js",
30
32
  "ckeditor5-dev-ci-trigger-circle-build": "bin/trigger-circle-build.js",
31
- "ckeditor5-dev-ci-circle-disable-auto-cancel-builds": "bin/circle-disable-auto-cancel-builds.js",
32
- "ckeditor5-dev-ci-circle-enable-auto-cancel-builds": "bin/circle-enable-auto-cancel-builds.js"
33
+ "ckeditor5-dev-ci-trigger-snyk-scan": "bin/trigger-snyk-scan.js"
33
34
  },
34
35
  "dependencies": {
35
36
  "@octokit/rest": "^22.0.0",
36
- "slack-notify": "^2.0.6"
37
+ "slack-notify": "^2.0.6",
38
+ "snyk": "^1.1303.1"
37
39
  }
38
40
  }