@ckeditor/ckeditor5-dev-ci 53.3.2 → 54.0.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/README.md +116 -2
- package/bin/circle-disable-auto-cancel-builds.js +21 -13
- package/bin/circle-enable-auto-cancel-builds.js +21 -13
- package/bin/circle-workflow-notifier.js +16 -34
- package/bin/is-job-triggered-by-member.js +30 -21
- package/bin/notify-circle-status.js +53 -25
- package/bin/trigger-circle-build.js +32 -22
- package/package.json +2 -6
- package/bin/allocate-swap-memory.sh +0 -21
- package/bin/install-latest-chrome.sh +0 -13
- package/bin/notify-travis-status.js +0 -111
package/README.md
CHANGED
|
@@ -6,9 +6,123 @@ CKEditor 5 CI utilities
|
|
|
6
6
|
|
|
7
7
|
Utils for [CKEditor 5](https://ckeditor.com) CI builds.
|
|
8
8
|
|
|
9
|
-
Contains tools for sending Slack notifications by
|
|
9
|
+
Contains tools for sending Slack notifications by Circle CI.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Available scripts
|
|
12
|
+
|
|
13
|
+
These commands accept a mix of environment variables and command line arguments. Environment variables are preferred when the value comes from the CI environment or is sensitive (like tokens). Command line arguments are preferred when the value is static or local to a given repository.
|
|
14
|
+
|
|
15
|
+
> [!WARNING]
|
|
16
|
+
> Tokens are passed as environment variables to avoid exposing sensitive credentials in shell history, CI logs, or shared configuration files.
|
|
17
|
+
|
|
18
|
+
- ⚙️ **`ckeditor5-dev-ci-circle-disable-auto-cancel-builds`**
|
|
19
|
+
|
|
20
|
+
Disables the _“Auto-cancel redundant workflows”_ option in CircleCI for a given repository.
|
|
21
|
+
Useful during release processes to prevent CircleCI from canceling the workflow triggered by the release commit itself.
|
|
22
|
+
|
|
23
|
+
**Environment variables:**
|
|
24
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
25
|
+
|
|
26
|
+
**Parameters:**
|
|
27
|
+
- `--organization` — GitHub organization name.
|
|
28
|
+
- `--repository` — GitHub repository name.
|
|
29
|
+
|
|
30
|
+
- ⚙️ **`ckeditor5-dev-ci-circle-enable-auto-cancel-builds`**
|
|
31
|
+
|
|
32
|
+
Enables the _“Auto-cancel redundant workflows”_ option in CircleCI for a given repository.
|
|
33
|
+
Should be used after a release workflow that temporarily disables this option using the `ckeditor5-dev-ci-circle-disable-auto-cancel-builds` script.
|
|
34
|
+
|
|
35
|
+
**Environment variables:**
|
|
36
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
37
|
+
|
|
38
|
+
**Parameters:**
|
|
39
|
+
- `--organization` — GitHub organization name.
|
|
40
|
+
- `--repository` — GitHub repository name.
|
|
41
|
+
|
|
42
|
+
- ⚙️ **`ckeditor5-dev-ci-circle-workflow-notifier`**
|
|
43
|
+
|
|
44
|
+
Waits for all jobs in the **current CircleCI workflow** to finish (success or error) and then runs a final command (the "notifier").
|
|
45
|
+
Intended to run as a **dedicated job** in your workflow. The script itself handles waiting – you typically don’t add `requires` on this job.
|
|
46
|
+
|
|
47
|
+
**Environment variables:**
|
|
48
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
49
|
+
|
|
50
|
+
**CircleCI-provided variables:**
|
|
51
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow.
|
|
52
|
+
- `CIRCLE_JOB` — Name of the current job.
|
|
53
|
+
|
|
54
|
+
**Parameters:**
|
|
55
|
+
- `--task` — Command to execute at the end; default: `pnpm ckeditor5-dev-ci-notify-circle-status`.
|
|
56
|
+
- `--ignore` — Job name to ignore when waiting (repeatable; can be passed multiple times).
|
|
57
|
+
|
|
58
|
+
- ⚙️ **`ckeditor5-dev-ci-is-job-triggered-by-member`**
|
|
59
|
+
|
|
60
|
+
Verifies that a **CircleCI approval job** was approved by a user who belongs to a specified GitHub team.
|
|
61
|
+
Uses CircleCI and GitHub APIs to check the approver against the team membership.
|
|
62
|
+
|
|
63
|
+
**Environment variables:**
|
|
64
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
65
|
+
- `CKE5_GITHUB_TOKEN` — GitHub token used to query team membership.
|
|
66
|
+
|
|
67
|
+
**CircleCI-provided variables:**
|
|
68
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow.
|
|
69
|
+
|
|
70
|
+
**Parameters:**
|
|
71
|
+
- `--job` — Name of the approval job to verify.
|
|
72
|
+
- `--organization` — GitHub organization name.
|
|
73
|
+
- `--team` — GitHub team name (slug) to validate against.
|
|
74
|
+
|
|
75
|
+
- ⚙️ **`ckeditor5-dev-ci-is-workflow-restarted`**
|
|
76
|
+
|
|
77
|
+
Checks whether the current CircleCI workflow has been **restarted**.
|
|
78
|
+
If a restart is detected, the script exits with a zero exit code, allowing the pipeline to continue conditionally.
|
|
79
|
+
|
|
80
|
+
**Environment variables:**
|
|
81
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
82
|
+
|
|
83
|
+
**CircleCI-provided variables:**
|
|
84
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow (set by CircleCI).
|
|
85
|
+
|
|
86
|
+
- ⚙️ **`ckeditor5-dev-ci-notify-circle-status`**
|
|
87
|
+
|
|
88
|
+
Sends a Slack notification summarizing the current CircleCI build/workflow status.
|
|
89
|
+
For failed builds, fetches the commit author via the GitHub API (works with private repositories).
|
|
90
|
+
|
|
91
|
+
**Environment variables:**
|
|
92
|
+
- `CKE5_GITHUB_TOKEN` — GitHub token with the `repo` scope, used to fetch commit author.
|
|
93
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for API calls.
|
|
94
|
+
- `CKE5_SLACK_WEBHOOK_URL` — Incoming Webhook URL for the Slack channel receiving notifications.
|
|
95
|
+
|
|
96
|
+
**CircleCI-provided variables:**
|
|
97
|
+
- `CIRCLE_BRANCH` — The number of the current build.
|
|
98
|
+
- `CIRCLE_PROJECT_REPONAME` — Repository name.
|
|
99
|
+
- `CIRCLE_PROJECT_USERNAME` — Organization/user name.
|
|
100
|
+
- `CIRCLE_SHA1` — Commit SHA of the current build.
|
|
101
|
+
- `CIRCLE_WORKFLOW_ID` — ID of the current workflow.
|
|
102
|
+
|
|
103
|
+
**Parameters:**
|
|
104
|
+
- `--pipeline-id` &mdash Value of Circle's `<< pipeline.number >>` parameter ([read more](https://circleci.com/docs/guides/orchestrate/pipeline-variables/#pipeline-values)).
|
|
105
|
+
- `--trigger-repository-slug` — `<org>/<repo>` to construct the commit URL when provided with `--trigger-commit-hash`. Useful when a pipeline was triggered via a different repository.
|
|
106
|
+
- `--trigger-commit-hash` — Commit SHA to construct the commit URL. Useful when a pipeline was triggered via a different repository.
|
|
107
|
+
- `--hide-author` — `"true"`/`"false"` to hide the author in Slack.
|
|
108
|
+
|
|
109
|
+
- ⚙️ **`ckeditor5-dev-ci-trigger-circle-build`**
|
|
110
|
+
|
|
111
|
+
Triggers a **new CircleCI pipeline** for a specified repository.
|
|
112
|
+
Commonly used to initiate release or follow-up pipelines from an existing workflow.
|
|
113
|
+
|
|
114
|
+
**Environment variables:**
|
|
115
|
+
- `CKE5_CIRCLE_TOKEN` — CircleCI API token used for authentication.
|
|
116
|
+
|
|
117
|
+
**CircleCI-provided variables:**
|
|
118
|
+
- `CIRCLE_BRANCH` — Git branch of the currently processed pipeline.
|
|
119
|
+
- `CIRCLE_SHA1` — Full commit SHA of the currently processed pipeline.
|
|
120
|
+
|
|
121
|
+
**Parameters:**
|
|
122
|
+
- `--slug` — Repository slug (`org/name`) where the new pipeline will be started.
|
|
123
|
+
- `--trigger-repository-slug` — *(Optional)* Repository slug (`org/name`) that triggered the new pipeline.
|
|
124
|
+
Can be omitted if it matches `--slug`.
|
|
125
|
+
- `--release-branch` — *(Optional)* Branch that leads the release process.
|
|
12
126
|
|
|
13
127
|
## Changelog
|
|
14
128
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-builds.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -13,26 +14,33 @@ import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-build
|
|
|
13
14
|
* It's needed when triggering a release process via CI to avoid canceling the release workflow by pushing
|
|
14
15
|
* a new commit (the released one) that will trigger a new pipeline.
|
|
15
16
|
*
|
|
16
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
17
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
17
18
|
*
|
|
18
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
19
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
20
|
+
* - `--organization` - a GitHub organization.
|
|
21
|
+
* - `--repository` - a GitHub repository.
|
|
21
22
|
*
|
|
22
23
|
* Example usage:
|
|
23
|
-
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-disable-auto-cancel-builds
|
|
24
|
+
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-disable-auto-cancel-builds --organization ... --repository ...
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const { values: cliOptions } = parseArgs( {
|
|
28
|
+
options: {
|
|
29
|
+
organization: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: process.env.CKE5_GITHUB_ORGANIZATION
|
|
32
|
+
},
|
|
33
|
+
repository: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env.CKE5_GITHUB_REPOSITORY
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} );
|
|
31
39
|
|
|
32
40
|
const options = {
|
|
33
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
34
|
-
githubOrganization:
|
|
35
|
-
githubRepository:
|
|
41
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
42
|
+
githubOrganization: cliOptions.organization,
|
|
43
|
+
githubRepository: cliOptions.repository,
|
|
36
44
|
newValue: false
|
|
37
45
|
};
|
|
38
46
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-builds.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -13,26 +14,33 @@ import circleUpdateAutoCancelBuilds from '../lib/circle-update-auto-cancel-build
|
|
|
13
14
|
* It should be done only if a release workflow uses the `ckeditor5-dev-ci-circle-disable-auto-cancel-builds`
|
|
14
15
|
* script to disable the same option.
|
|
15
16
|
*
|
|
16
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
17
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
17
18
|
*
|
|
18
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
19
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
20
|
+
* - `--organization` - a GitHub organization.
|
|
21
|
+
* - `--repository` - a GitHub repository.
|
|
21
22
|
*
|
|
22
23
|
* Example usage:
|
|
23
|
-
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-enable-auto-cancel-builds
|
|
24
|
+
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-circle-enable-auto-cancel-builds --organization ... --repository ...
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const { values: cliOptions } = parseArgs( {
|
|
28
|
+
options: {
|
|
29
|
+
organization: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: process.env.CKE5_GITHUB_ORGANIZATION
|
|
32
|
+
},
|
|
33
|
+
repository: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env.CKE5_GITHUB_REPOSITORY
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} );
|
|
31
39
|
|
|
32
40
|
const options = {
|
|
33
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
34
|
-
githubOrganization:
|
|
35
|
-
githubRepository:
|
|
41
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
42
|
+
githubOrganization: cliOptions.organization,
|
|
43
|
+
githubRepository: cliOptions.repository,
|
|
36
44
|
newValue: true
|
|
37
45
|
};
|
|
38
46
|
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import { execSync } from 'child_process';
|
|
9
|
-
import minimist from 'minimist';
|
|
10
10
|
import processJobStatuses from '../lib/process-job-statuses.js';
|
|
11
11
|
import isWorkflowFinished from '../lib/utils/is-workflow-finished.js';
|
|
12
12
|
|
|
@@ -35,7 +35,7 @@ import isWorkflowFinished from '../lib/utils/is-workflow-finished.js';
|
|
|
35
35
|
// See: https://github.com/ckeditor/ckeditor5/issues/16403.
|
|
36
36
|
//
|
|
37
37
|
// By defining the `--ignore` option, you can skip waiting for particular jobs.
|
|
38
|
-
// You can also specify jobs to ignore
|
|
38
|
+
// You can also specify jobs to ignore.
|
|
39
39
|
//
|
|
40
40
|
// Let's consider the example below:
|
|
41
41
|
// ┌─────┐ ┌─────┐
|
|
@@ -54,7 +54,7 @@ import isWorkflowFinished from '../lib/utils/is-workflow-finished.js';
|
|
|
54
54
|
// The assumption is that "Job D" is the approval job. To ignore it and its children, you can execute
|
|
55
55
|
// the notifier like this:
|
|
56
56
|
//
|
|
57
|
-
// $ ckeditor5-dev-ci-circle-workflow-notifier --ignore
|
|
57
|
+
// $ ckeditor5-dev-ci-circle-workflow-notifier --ignore="Job D" --ignore="Job E"
|
|
58
58
|
|
|
59
59
|
const {
|
|
60
60
|
/**
|
|
@@ -67,7 +67,19 @@ const {
|
|
|
67
67
|
CIRCLE_JOB
|
|
68
68
|
} = process.env;
|
|
69
69
|
|
|
70
|
-
const { task, ignore } =
|
|
70
|
+
const { values: { task, ignore } } = parseArgs( {
|
|
71
|
+
options: {
|
|
72
|
+
task: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: 'pnpm ckeditor5-dev-ci-notify-circle-status'
|
|
75
|
+
},
|
|
76
|
+
ignore: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
multiple: true,
|
|
79
|
+
default: []
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} );
|
|
71
83
|
|
|
72
84
|
waitForOtherJobsAndSendNotification()
|
|
73
85
|
.catch( err => {
|
|
@@ -113,33 +125,3 @@ async function getOtherJobsData() {
|
|
|
113
125
|
|
|
114
126
|
return data.items.filter( job => job.name !== CIRCLE_JOB );
|
|
115
127
|
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* @param {Array.<string>} args
|
|
119
|
-
* @returns {object} result
|
|
120
|
-
* @returns {string} result.task
|
|
121
|
-
* @returns {Array.<string>} result.ignore
|
|
122
|
-
*/
|
|
123
|
-
function parseArguments( args ) {
|
|
124
|
-
const config = {
|
|
125
|
-
string: [
|
|
126
|
-
'task',
|
|
127
|
-
'ignore'
|
|
128
|
-
],
|
|
129
|
-
|
|
130
|
-
default: {
|
|
131
|
-
task: 'pnpm ckeditor5-dev-ci-notify-circle-status',
|
|
132
|
-
ignore: []
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
let { task, ignore } = minimist( args, config );
|
|
137
|
-
|
|
138
|
-
if ( typeof ignore === 'string' ) {
|
|
139
|
-
ignore = [ ignore ];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
ignore = ignore.flatMap( item => item.split( ',' ) );
|
|
143
|
-
|
|
144
|
-
return { task, ignore };
|
|
145
|
-
}
|
|
@@ -5,40 +5,49 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import isJobTriggeredByMember from '../lib/is-job-triggered-by-member.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* This script checks if a user that approved an approval job could do that.
|
|
12
13
|
*
|
|
13
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
14
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
14
15
|
*
|
|
15
|
-
* - CIRCLE_WORKFLOW_ID - provided by default by CircleCI and keeps a unique id of the CI build.
|
|
16
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
17
|
-
* -
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
16
|
+
* - `CIRCLE_WORKFLOW_ID` - provided by default by CircleCI and keeps a unique id of the CI build.
|
|
17
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
18
|
+
* - `CKE5_GITHUB_TOKEN` - a GitHub token used for authorization a request.
|
|
19
|
+
* - `--team` - a GitHub team name (slug) that defines accounts that could approve the job.
|
|
20
|
+
* - `--organization` - your GitHub organization.
|
|
21
|
+
* - `--job` - a job name to verify.
|
|
21
22
|
*
|
|
22
23
|
* Example usage:
|
|
23
24
|
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-is-job-triggered-by-member
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const { values: cliOptions } = parseArgs( {
|
|
28
|
+
options: {
|
|
29
|
+
job: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: process.env.CKE5_CIRCLE_APPROVAL_JOB_NAME
|
|
32
|
+
},
|
|
33
|
+
organization: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: process.env.CKE5_GITHUB_ORGANIZATION
|
|
36
|
+
},
|
|
37
|
+
team: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: process.env.CKE5_GITHUB_TEAM_SLUG
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} );
|
|
34
43
|
|
|
35
44
|
const options = {
|
|
36
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
37
|
-
circleWorkflowId: CIRCLE_WORKFLOW_ID,
|
|
38
|
-
circleApprovalJobName:
|
|
39
|
-
githubOrganization:
|
|
40
|
-
githubTeamSlug:
|
|
41
|
-
githubToken: CKE5_GITHUB_TOKEN
|
|
45
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
46
|
+
circleWorkflowId: process.env.CIRCLE_WORKFLOW_ID,
|
|
47
|
+
circleApprovalJobName: cliOptions.job,
|
|
48
|
+
githubOrganization: cliOptions.organization,
|
|
49
|
+
githubTeamSlug: cliOptions.team,
|
|
50
|
+
githubToken: process.env.CKE5_GITHUB_TOKEN
|
|
42
51
|
};
|
|
43
52
|
|
|
44
53
|
isJobTriggeredByMember( options )
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import slackNotify from 'slack-notify';
|
|
9
10
|
import formatMessage from '../lib/format-message.js';
|
|
10
11
|
|
|
@@ -14,11 +15,6 @@ import formatMessage from '../lib/format-message.js';
|
|
|
14
15
|
// Described environment variables starting with "CKE5" should be added by the integrator.
|
|
15
16
|
|
|
16
17
|
const {
|
|
17
|
-
/**
|
|
18
|
-
* Required. Value of Circle's `pipeline.number` variable.
|
|
19
|
-
*/
|
|
20
|
-
CKE5_PIPELINE_NUMBER,
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
19
|
* Required. Token to a Github account with the scope: "repos". It is required for obtaining an author of
|
|
24
20
|
* the commit if the build failed. The repository can be private and we can't use the public API.
|
|
@@ -35,28 +31,49 @@ const {
|
|
|
35
31
|
*/
|
|
36
32
|
CKE5_SLACK_WEBHOOK_URL,
|
|
37
33
|
|
|
38
|
-
/**
|
|
39
|
-
* Optional. If both are defined, the script will use the URL as the commit URL.
|
|
40
|
-
* Otherwise, URL will be constructed using current repository data.
|
|
41
|
-
*/
|
|
42
|
-
CKE5_TRIGGER_REPOSITORY_SLUG,
|
|
43
|
-
CKE5_TRIGGER_COMMIT_HASH,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Optional. If set to "true", commit author will be hidden.
|
|
47
|
-
* See: https://github.com/ckeditor/ckeditor5/issues/9252.
|
|
48
|
-
*/
|
|
49
|
-
CKE5_SLACK_NOTIFY_HIDE_AUTHOR,
|
|
50
|
-
|
|
51
34
|
// Variables that are available by default in Circle environment.
|
|
52
35
|
CIRCLE_BRANCH,
|
|
53
|
-
CIRCLE_BUILD_NUM,
|
|
54
36
|
CIRCLE_PROJECT_REPONAME,
|
|
55
37
|
CIRCLE_PROJECT_USERNAME,
|
|
56
38
|
CIRCLE_SHA1,
|
|
57
39
|
CIRCLE_WORKFLOW_ID
|
|
58
40
|
} = process.env;
|
|
59
41
|
|
|
42
|
+
const { values: cliArguments } = parseArgs( {
|
|
43
|
+
options: {
|
|
44
|
+
/**
|
|
45
|
+
* Required. Value of Circle's `pipeline.number` variable.
|
|
46
|
+
* Unfortunately, it does not overlap with `CIRCLE_BUILD_NUM`.
|
|
47
|
+
*/
|
|
48
|
+
'pipeline-id': {
|
|
49
|
+
type: 'string',
|
|
50
|
+
default: process.env.CKE5_PIPELINE_NUMBER
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Optional. If both are defined, the script will use the URL as the commit URL.
|
|
55
|
+
* Otherwise, URL will be constructed using the current repository data.
|
|
56
|
+
*/
|
|
57
|
+
'trigger-repository-slug': {
|
|
58
|
+
type: 'string',
|
|
59
|
+
default: process.env.CKE5_TRIGGER_REPOSITORY_SLUG
|
|
60
|
+
},
|
|
61
|
+
'trigger-commit-hash': {
|
|
62
|
+
type: 'string',
|
|
63
|
+
default: process.env.CKE5_TRIGGER_COMMIT_HASH
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Optional. If set to "true" or "1", commit author will be hidden.
|
|
68
|
+
* See: https://github.com/ckeditor/ckeditor5/issues/9252.
|
|
69
|
+
*/
|
|
70
|
+
'hide-author': {
|
|
71
|
+
type: 'string',
|
|
72
|
+
default: process.env.CKE5_SLACK_NOTIFY_HIDE_AUTHOR
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} );
|
|
76
|
+
|
|
60
77
|
notifyCircleStatus();
|
|
61
78
|
|
|
62
79
|
async function notifyCircleStatus() {
|
|
@@ -68,12 +85,16 @@ async function notifyCircleStatus() {
|
|
|
68
85
|
throw new Error( 'Missing environment variable: CKE5_SLACK_WEBHOOK_URL' );
|
|
69
86
|
}
|
|
70
87
|
|
|
88
|
+
if ( !CKE5_CIRCLE_TOKEN ) {
|
|
89
|
+
throw new Error( 'Missing environment variable: CKE5_CIRCLE_TOKEN' );
|
|
90
|
+
}
|
|
91
|
+
|
|
71
92
|
const jobData = await getJobData();
|
|
72
93
|
const buildUrl = [
|
|
73
94
|
'https://app.circleci.com/pipelines/github',
|
|
74
95
|
CIRCLE_PROJECT_USERNAME,
|
|
75
96
|
CIRCLE_PROJECT_REPONAME,
|
|
76
|
-
|
|
97
|
+
cliArguments[ 'pipeline-id' ],
|
|
77
98
|
'workflows',
|
|
78
99
|
CIRCLE_WORKFLOW_ID
|
|
79
100
|
].join( '/' );
|
|
@@ -91,7 +112,7 @@ async function notifyCircleStatus() {
|
|
|
91
112
|
triggeringCommitUrl: getTriggeringCommitUrl(),
|
|
92
113
|
startTime: Math.ceil( ( new Date( jobData.started_at ) ).getTime() / 1000 ),
|
|
93
114
|
endTime: Math.ceil( ( new Date() ) / 1000 ),
|
|
94
|
-
shouldHideAuthor:
|
|
115
|
+
shouldHideAuthor: isTrueLike( cliArguments[ 'hide-author' ] )
|
|
95
116
|
} );
|
|
96
117
|
|
|
97
118
|
return slackNotify( CKE5_SLACK_WEBHOOK_URL )
|
|
@@ -105,7 +126,7 @@ async function getJobData() {
|
|
|
105
126
|
CIRCLE_PROJECT_USERNAME,
|
|
106
127
|
CIRCLE_PROJECT_REPONAME,
|
|
107
128
|
'job',
|
|
108
|
-
|
|
129
|
+
cliArguments[ 'pipeline-id' ]
|
|
109
130
|
].join( '/' );
|
|
110
131
|
|
|
111
132
|
const fetchOptions = {
|
|
@@ -120,9 +141,12 @@ async function getJobData() {
|
|
|
120
141
|
function getTriggeringCommitUrl() {
|
|
121
142
|
let repoSlug, hash;
|
|
122
143
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
144
|
+
const cliRepoSlug = cliArguments[ 'trigger-repository-slug' ];
|
|
145
|
+
const cliCommitHash = cliArguments[ 'trigger-commit-hash' ];
|
|
146
|
+
|
|
147
|
+
if ( cliRepoSlug && cliCommitHash ) {
|
|
148
|
+
repoSlug = cliRepoSlug.trim();
|
|
149
|
+
hash = cliCommitHash.trim();
|
|
126
150
|
} else {
|
|
127
151
|
repoSlug = [ CIRCLE_PROJECT_USERNAME, CIRCLE_PROJECT_REPONAME ].join( '/' );
|
|
128
152
|
hash = CIRCLE_SHA1;
|
|
@@ -130,3 +154,7 @@ function getTriggeringCommitUrl() {
|
|
|
130
154
|
|
|
131
155
|
return [ 'https://github.com', repoSlug, 'commit', hash ].join( '/' );
|
|
132
156
|
}
|
|
157
|
+
|
|
158
|
+
function isTrueLike( value ) {
|
|
159
|
+
return value === true || value === 1 || value === '1' || value === 'true';
|
|
160
|
+
}
|
|
@@ -5,43 +5,53 @@
|
|
|
5
5
|
* For licensing, see LICENSE.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { parseArgs } from 'util';
|
|
8
9
|
import triggerCircleBuild from '../lib/trigger-circle-build.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* This script triggers a new CircleCI build.
|
|
12
13
|
*
|
|
13
|
-
* In order to integrate the action in your pipeline, you need prepare a few environment variables:
|
|
14
|
+
* In order to integrate the action in your pipeline, you need prepare a few CLI or environment variables:
|
|
14
15
|
*
|
|
15
|
-
* - CIRCLE_BRANCH - provided by default by CircleCI and keeps the git branch of processed
|
|
16
|
-
* -
|
|
17
|
-
* - CKE5_CIRCLE_TOKEN - an authorization token to talk to CircleCI REST API.
|
|
18
|
-
* -
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
16
|
+
* - `CIRCLE_BRANCH` - provided by default by CircleCI and keeps the git branch of processed pipeline.
|
|
17
|
+
* - `CIRCLE_SHA1` - provided by default by CircleCI and keeps a full commit identifier of the processed the pipeline.
|
|
18
|
+
* - `CKE5_CIRCLE_TOKEN` - an authorization token to talk to CircleCI REST API.
|
|
19
|
+
* - `--slug` - a repository slug (org/name) where a new pipeline will be started.
|
|
20
|
+
* - `--trigger-repository-slug` - (optional) a repository slug (org/name) that triggers a new pipeline.
|
|
21
|
+
* Can be skipped when overlaps with `--slug`.
|
|
22
|
+
* - `--release-branch` - (optional) define a branch that leads the release process.
|
|
21
23
|
*
|
|
22
24
|
* Example usage:
|
|
23
25
|
* CKE5_CIRCLE_TOKEN=... ckeditor5-dev-ci-trigger-circle-build
|
|
24
26
|
*/
|
|
25
27
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const { values: cliOptions } = parseArgs( {
|
|
29
|
+
options: {
|
|
30
|
+
slug: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: process.env.CKE5_GITHUB_REPOSITORY_SLUG
|
|
33
|
+
},
|
|
34
|
+
'trigger-repository-slug': {
|
|
35
|
+
type: 'string',
|
|
36
|
+
default: process.env.CKE5_GITHUB_TRIGGER_REPOSITORY_SLUG
|
|
37
|
+
},
|
|
38
|
+
'release-branch': {
|
|
39
|
+
type: 'string',
|
|
40
|
+
default: process.env.CKE5_GITHUB_RELEASE_BRANCH
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} );
|
|
34
44
|
|
|
35
45
|
const options = {
|
|
36
|
-
circleToken: CKE5_CIRCLE_TOKEN,
|
|
37
|
-
commit:
|
|
38
|
-
branch: CIRCLE_BRANCH,
|
|
39
|
-
releaseBranch:
|
|
40
|
-
repositorySlug:
|
|
46
|
+
circleToken: process.env.CKE5_CIRCLE_TOKEN,
|
|
47
|
+
commit: process.env.CIRCLE_SHA1,
|
|
48
|
+
branch: process.env.CIRCLE_BRANCH,
|
|
49
|
+
releaseBranch: cliOptions[ 'release-branch' ],
|
|
50
|
+
repositorySlug: cliOptions.slug
|
|
41
51
|
};
|
|
42
52
|
|
|
43
|
-
if (
|
|
44
|
-
options.triggerRepositorySlug =
|
|
53
|
+
if ( cliOptions[ 'trigger-repository-slug' ] ) {
|
|
54
|
+
options.triggerRepositorySlug = cliOptions[ 'trigger-repository-slug' ];
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
triggerCircleBuild( options )
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-dev-ci",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "54.0.0",
|
|
4
4
|
"description": "Utils used on various Continuous Integration services.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/ckeditor5-dev-ci"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=24.11.0",
|
|
17
17
|
"npm": ">=5.7.1"
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
@@ -23,11 +23,8 @@
|
|
|
23
23
|
"lib"
|
|
24
24
|
],
|
|
25
25
|
"bin": {
|
|
26
|
-
"ckeditor5-dev-ci-notify-travis-status": "bin/notify-travis-status.js",
|
|
27
26
|
"ckeditor5-dev-ci-notify-circle-status": "bin/notify-circle-status.js",
|
|
28
27
|
"ckeditor5-dev-ci-circle-workflow-notifier": "bin/circle-workflow-notifier.js",
|
|
29
|
-
"ckeditor5-dev-ci-allocate-swap-memory": "bin/allocate-swap-memory.sh",
|
|
30
|
-
"ckeditor5-dev-ci-install-latest-chrome": "bin/install-latest-chrome.sh",
|
|
31
28
|
"ckeditor5-dev-ci-is-job-triggered-by-member": "bin/is-job-triggered-by-member.js",
|
|
32
29
|
"ckeditor5-dev-ci-is-workflow-restarted": "bin/is-workflow-restarted.js",
|
|
33
30
|
"ckeditor5-dev-ci-trigger-circle-build": "bin/trigger-circle-build.js",
|
|
@@ -36,7 +33,6 @@
|
|
|
36
33
|
},
|
|
37
34
|
"dependencies": {
|
|
38
35
|
"@octokit/rest": "^22.0.0",
|
|
39
|
-
"minimist": "^1.2.8",
|
|
40
36
|
"slack-notify": "^2.0.6"
|
|
41
37
|
}
|
|
42
38
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
4
|
-
# For licensing, see LICENSE.md.
|
|
5
|
-
|
|
6
|
-
echo "Allocating swap memory to prevent running out of RAM."
|
|
7
|
-
|
|
8
|
-
# Remove existing swap so that allocating new swap does not throw.
|
|
9
|
-
sudo swapoff -a
|
|
10
|
-
|
|
11
|
-
# Create a 4 gigabyte swapfile.
|
|
12
|
-
sudo fallocate -l 4G /swapfile
|
|
13
|
-
|
|
14
|
-
# Secure the swapfile by restricting access to root.
|
|
15
|
-
sudo chmod 600 /swapfile
|
|
16
|
-
|
|
17
|
-
# Mark the file as a swap space.
|
|
18
|
-
sudo mkswap /swapfile
|
|
19
|
-
|
|
20
|
-
# Enable the swap.
|
|
21
|
-
sudo swapon /swapfile
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
4
|
-
# For licensing, see LICENSE.md.
|
|
5
|
-
|
|
6
|
-
echo "Installing the latest Chrome."
|
|
7
|
-
|
|
8
|
-
sudo apt-get update
|
|
9
|
-
sudo apt-get install lsb-release libappindicator3-1
|
|
10
|
-
curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
11
|
-
sudo dpkg -i google-chrome.deb
|
|
12
|
-
sudo sed -i 's|HERE/chrome"|HERE/chrome" --no-sandbox|g' /opt/google/chrome/google-chrome
|
|
13
|
-
rm google-chrome.deb
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
5
|
-
* For licensing, see LICENSE.md.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import formatMessage from '../lib/format-message.js';
|
|
9
|
-
import slackNotify from 'slack-notify';
|
|
10
|
-
|
|
11
|
-
const ALLOWED_BRANCHES = [
|
|
12
|
-
'stable',
|
|
13
|
-
'master'
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const ALLOWED_EVENTS = [
|
|
17
|
-
'push',
|
|
18
|
-
'cron',
|
|
19
|
-
'api'
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
// This script assumes that is being executed on Travis CI.
|
|
23
|
-
// Described environment variables should be added by the integrator.
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
/**
|
|
27
|
-
* POSIX timestamps created when the script has begun and ended the job.
|
|
28
|
-
* Timestamps should be in seconds instead of milliseconds.
|
|
29
|
-
*/
|
|
30
|
-
START_TIME,
|
|
31
|
-
END_TIME,
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Token to a Github account with the scope: "repos". It is required for obtaining an author of
|
|
35
|
-
* the commit if the build failed. The repository can be private and we can't use the public API.
|
|
36
|
-
*/
|
|
37
|
-
GITHUB_TOKEN,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Required. Webhook URL of the Slack channel where the notification should be sent.
|
|
41
|
-
*/
|
|
42
|
-
SLACK_WEBHOOK_URL,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Optional. If defined, the script will use the URL as the commit URL.
|
|
46
|
-
* Otherwise, URL will be constructed using current repository data.
|
|
47
|
-
*/
|
|
48
|
-
SLACK_NOTIFY_COMMIT_URL,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Optional. If set to "true", commit author will be hidden.
|
|
52
|
-
* See: https://github.com/ckeditor/ckeditor5/issues/9252.
|
|
53
|
-
*/
|
|
54
|
-
SLACK_NOTIFY_HIDE_AUTHOR,
|
|
55
|
-
|
|
56
|
-
// Variables that are available by default in Travis environment.
|
|
57
|
-
TRAVIS_BRANCH,
|
|
58
|
-
TRAVIS_COMMIT,
|
|
59
|
-
TRAVIS_EVENT_TYPE,
|
|
60
|
-
TRAVIS_JOB_NUMBER,
|
|
61
|
-
TRAVIS_JOB_WEB_URL,
|
|
62
|
-
TRAVIS_REPO_SLUG,
|
|
63
|
-
TRAVIS_TEST_RESULT
|
|
64
|
-
} = process.env;
|
|
65
|
-
|
|
66
|
-
notifyTravisStatus();
|
|
67
|
-
|
|
68
|
-
async function notifyTravisStatus() {
|
|
69
|
-
// Send a notification only for main branches...
|
|
70
|
-
if ( !ALLOWED_BRANCHES.includes( TRAVIS_BRANCH ) ) {
|
|
71
|
-
console.log( `Aborting slack notification due to an invalid branch (${ TRAVIS_BRANCH }).` );
|
|
72
|
-
|
|
73
|
-
process.exit();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ...and an event that triggered the build is correct...
|
|
77
|
-
if ( !ALLOWED_EVENTS.includes( TRAVIS_EVENT_TYPE ) ) {
|
|
78
|
-
console.log( `Aborting slack notification due to an invalid event type (${ TRAVIS_EVENT_TYPE }).` );
|
|
79
|
-
|
|
80
|
-
process.exit();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// ...and for builds that failed.
|
|
84
|
-
if ( TRAVIS_TEST_RESULT == 0 ) {
|
|
85
|
-
console.log( 'The build did not fail. The notification will not be sent.' );
|
|
86
|
-
|
|
87
|
-
process.exit();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const [ repositoryOwner, repositoryName ] = TRAVIS_REPO_SLUG.split( '/' );
|
|
91
|
-
|
|
92
|
-
const message = await formatMessage( {
|
|
93
|
-
slackMessageUsername: 'Travis CI',
|
|
94
|
-
iconUrl: 'https://a.slack-edge.com/66f9/img/services/travis_36.png',
|
|
95
|
-
repositoryOwner,
|
|
96
|
-
repositoryName,
|
|
97
|
-
branch: TRAVIS_BRANCH,
|
|
98
|
-
buildTitle: 'Job number',
|
|
99
|
-
buildUrl: TRAVIS_JOB_WEB_URL,
|
|
100
|
-
buildId: '#' + TRAVIS_JOB_NUMBER,
|
|
101
|
-
githubToken: GITHUB_TOKEN,
|
|
102
|
-
triggeringCommitUrl: SLACK_NOTIFY_COMMIT_URL || `https://github.com/${ TRAVIS_REPO_SLUG }/commit/${ TRAVIS_COMMIT }`,
|
|
103
|
-
startTime: Number( START_TIME ),
|
|
104
|
-
endTime: Number( END_TIME ),
|
|
105
|
-
shouldHideAuthor: SLACK_NOTIFY_HIDE_AUTHOR === 'true'
|
|
106
|
-
} );
|
|
107
|
-
|
|
108
|
-
return slackNotify( SLACK_WEBHOOK_URL )
|
|
109
|
-
.send( message )
|
|
110
|
-
.catch( err => console.log( 'API error occurred:', err ) );
|
|
111
|
-
}
|