-
Notifications
You must be signed in to change notification settings - Fork 5k
168 lines (148 loc) · 7.05 KB
/
component-pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Component Check
on:
pull_request_target:
types:
- opened
- reopened
paths:
- 'parent/**'
- 'core/**'
- 'components/**'
workflow_run:
workflows: [ "PR Build (Camel 3.x)" ]
types:
- completed
permissions: {}
jobs:
process:
if: github.repository == 'apache/camel'
permissions:
pull-requests: write # to comment on a pull request
actions: read # to download artifact
name: Process
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: |
github.event_name == 'pull_request_target' &&
(github.event.action == 'opened' ||
github.event.action == 'reopened')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command \`/component-test (camel-)component-name1 (camel-)component-name2..\` to request a test from the test bot.
* You can label PRs using \`build-all\`, \`build-dependents\`, \`skip-tests\` and \`test-dependents\` to fine-tune the checks executed by this PR.
* Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
* :warning: Be careful when sharing logs. Review their contents before sharing them publicly.`
})
- name: 'Download artifact'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: |
github.event_name == 'workflow_run'
with:
# Secure download based on:
# - https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "test-logs"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/test-logs.zip', Buffer.from(download.data));
- run: unzip test-logs.zip
if: |
github.event_name == 'workflow_run'
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: |
github.event_name == 'workflow_run'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./pr_number'));
let componentsTotal = Number(fs.readFileSync('./components-total'));
let componentsTested = Number(fs.readFileSync('./components-tested'));
let componentsFailures = Number(fs.readFileSync('./components-failures'));
let componentsSuccesses = Number(fs.readFileSync('./components-successes'));
var message = ""
if (componentsTested === 0) {
if (componentsTotal === 0) {
message = ":no_entry_sign: There are (likely) no components to be tested in this PR"
} else {
if (componentsTotal > 20) {
message = `:leftwards_arrow_with_hook: There are either **too many** changes to be tested in this PR or the code **needs be rebased**: (${componentsTotal} components likely to be affected)`
}
}
} else {
message = `### Components test results:
| Total | Tested | Failed :x: | Passed :white_check_mark: |
| --- | --- | --- | --- |
| ${componentsTotal} | ${componentsTested} | ${componentsFailures} | ${componentsSuccesses} |`
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: |
github.event_name == 'workflow_run'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let issue_number = Number(fs.readFileSync('./pr_number'));
let coreTested = Number(fs.readFileSync('./core-tested'));
let coreFailures = Number(fs.readFileSync('./core-failures'));
let coreSuccesses = Number(fs.readFileSync('./core-successes'));
var message = ""
if (coreTested === 0) {
message = ":no_entry_sign: There are (likely) no changes in core core to be tested in this PR"
} else {
message = `### Core test results:
| Tested | Failed :x: | Passed :white_check_mark: |
| --- | --- | --- |
| ${coreTested} | ${coreFailures} | ${coreSuccesses} |`
}
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});