-
Notifications
You must be signed in to change notification settings - Fork 245
134 lines (125 loc) · 5.04 KB
/
Helix-CI.yml
File metadata and controls
134 lines (125 loc) · 5.04 KB
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
name: Helix CI
on:
push:
branches: [ master ]
schedule:
- cron: '0 */12 * * *'
permissions: write-all
jobs:
Merge_PR_CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Delete frontend-maven-plugin dir
run: rm -rf .m2\repository\com\github\eirslett
- name: Build with Maven
run: mvn clean install -Dmaven.test.skip.exec=true -DretryFailedDeploymentCount=5
- name: Run All Tests
run: mvn -q -fae test
- name: Upload to Codecov
run: bash <(curl -s https://codecov.io/bash)
if: ${{ github.repository == 'apache/helix' && github.event_name == 'push' && (success() || failure()) }}
# Temporarily disabled due to enterprise policy restriction
# TODO: Re-enable once an approved alternative is found
# - name: Generate Test Report
# uses: dorny/test-reporter@v1
# if: ${{ success() || failure() }}
# with:
# name: Tests Results
# path: './**/target/surefire-reports/TEST-TestSuite.xml'
# reporter: java-junit
- name: Upload Unit Test Results as Artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: surefire-reports
path: ./**/target/surefire-reports/
if-no-files-found: ignore
- name: Print Tests Results
run: .github/scripts/printTestResult.sh
if: ${{ success() || failure() }}
- name: Report Failed Tests as GitHub Issues
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs');
const readline = require('readline');
var run_url = 'Unknown URL. Run ID is ' + context.runId
if (process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY && process.env.GITHUB_RUN_ID ) {
run_url = process.env.GITHUB_SERVER_URL + '/' + process.env.GITHUB_REPOSITORY + '/actions/runs/' + process.env.GITHUB_RUN_ID
}
const failureReportPath = './FailingTest.out'
// 1. Search for any test failures
if (!fs.existsSync(failureReportPath)) {
console.log('No test failure report found.')
return
}
var response = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['FailedTestTracking'],
state: ['all']
})
const existingIssues = response.data.filter((data) => !data.pull_request)
const lineReader = readline.createInterface({
input: fs.createReadStream('./FailingTest.out')
});
const failingTests = []
for await (const line of lineReader) {
failingTests.push(line)
}
for (failingTest of failingTests) {
// 2. Creating issues for the failing tests
console.log('Failing test identified:\n' + failingTest)
if (failingTest) {
const testInfo = failingTest.split(' ')[0]
const issueTitle = '[Failed CI Test] ' + testInfo
if (issueTitle) {
console.log('Adding comment to issue: ' + issueTitle)
var issue = null
// 2.1. Check existing test issues, create new ones for the failing tests if not exist.
for (existingIssue of existingIssues) {
if (existingIssue.title == issueTitle) {
issue = existingIssue
break
}
}
if (!issue) {
console.log('Creating issue: ' + issueTitle)
response = await github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['FailedTestTracking'],
title: issueTitle,
body: 'This issue is created for tracking unstable test: ' + testInfo
});
issue = response.data
} else {
// 2.2. Reopen the tickets if needed.
if (issue.state != 'open') {
console.log('Reopen issue: ' + issueTitle)
await github.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'open'
});
}
}
// 2.3. Adding the most recent failure to the ticket.
console.log('Add comment to issue: ' + issueTitle)
github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: 'This test fails in: ' + run_url
});
}
}
}
if: ${{ github.repository == 'apache/helix' && (success() || failure()) }}