-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
127 lines (114 loc) · 4.25 KB
/
action.yml
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
name: 'RcppDeepState'
author: 'Fabrizio Sandri'
description: 'This Action runs RcppDeepState in any Rcpp-based projects hosted on GitHub'
branding:
icon: search
color: gray-dark
inputs:
fail_ci_if_error:
description: 'Specify if CI pipeline should fail when RcppDeepState finds errors'
require: false
default: 'false'
location:
description: 'Location of the package if not in the root of the repository'
required: false
default: '/'
additional_dependencies:
description: 'A string containing a list of extra dependencies that the testing system requires, separated by spaces'
require: false
default: ''
seed:
description: 'Seed used for deterministic fuzz testing and reproduce the analysis results'
required: false
default: '-1'
max_seconds_per_function:
description: "Fuzzing phase's duration in seconds"
required: false
default: '2'
max_inputs:
description: 'Number of inputs generated in the fuzzing phase to analyze'
required: false
default: '3'
comment:
description: 'Print the analysis results as a comment in pull request'
require: false
default: 'false'
verbose:
description: 'Enables verbose logging of RcppDeepState'
require: false
default: 'false'
runs:
using: "composite"
steps:
- name: Get the pull request SHA
run: |
PULL_SHA="${{ github.event.pull_request.head.sha }}"
echo "PULL_SHA=${PULL_SHA}" >> $GITHUB_ENV
shell: bash
- name: Analyze the package with RcppDeepState
id: rcppdeepstate
uses: docker://fabriziosandri/rcppdeepstate:latest
with:
fail_ci_if_error: ${{ inputs.fail_ci_if_error }}
location: ${{ inputs.location }}
additional_dependencies: ${{ inputs.additional_dependencies }}
seed: ${{ inputs.seed }}
max_seconds_per_function: ${{ inputs.max_seconds_per_function }}
max_inputs: ${{ inputs.max_inputs }}
verbose: ${{ inputs.verbose }}
- name: Zip artifact before upload
if: failure() || inputs.fail_ci_if_error == 'false'
run: |
zip -r -q outputs.zip ./${{ inputs.location }}/inst/testfiles
shell: bash
- uses: actions/upload-artifact@v3
if: failure() || inputs.fail_ci_if_error == 'false'
with:
name: Test results
path: outputs.zip
if-no-files-found: ignore
- uses: actions/upload-artifact@v3
if: always() && steps.rcppdeepstate.outputs.truncated == 'true'
with:
name: Truncated comment
path: truncated.md
if-no-files-found: ignore
- name: Comment on pull requests
uses: actions/github-script@v6
if: |
always() && (
inputs.comment == 'true' || (
inputs.comment == 'failure' && steps.rcppdeepstate.outputs.errors == 'true'
)
)
with:
script: |
if (context.issue.number) {
const fs = require("fs");
const report = fs.readFileSync('./report.md', {encoding:'utf8', flag:'r'});
const response = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const comments = response.data;
// Find the comment generated by RcppDeepState-action
const comment_identifier = "<!-- RcppDeepState-action comment-->"
const action_comment = comments.find(comment => comment.body.includes(comment_identifier))
const new_comment_body = `${comment_identifier}\n${report}`
if (action_comment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: action_comment.id,
body: new_comment_body
})
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: new_comment_body
})
}
}