-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
130 lines (120 loc) · 5.11 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
128
129
130
name: "UTBot code analysis"
description: "UTBot code analysis allows adding tests and code analysis information by pull request"
branding:
icon: 'terminal'
color: 'blue'
on:
inputs:
add_tests:
description: 'Do tests need to be pushed'
required: true
refresh_tests:
description: 'Do old tests need to be deleted'
required: true
utbot_version:
description: 'UTBot version'
required: true
runtests:
description: 'Run generated tests'
required: true
scope:
description: 'Run utbot to all project, directory or file'
required: true
path:
description: 'directory or file name'
required: true
runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Delete old tests
if: ${{ inputs.refresh_tests == 'true' }}
uses: EndBug/add-and-commit@v9
with:
remove: 'tests'
author_name: 'github-actions[utbot]'
message: 'UTBot code analysis delete old tests'
- name: Download server executable
run: |
mkdir "utbot-release-${{ inputs.utbot_version }}"
wget -qq "https://github.com/UnitTestBot/UTBotCpp/releases/download/${{ inputs.utbot_version }}/utbot-release-${{ inputs.utbot_version }}.zip" -P "./utbot-release-${{ inputs.utbot_version }}"
unzip -qq "./utbot-release-${{ inputs.utbot_version }}/utbot-release-${{ inputs.utbot_version }}.zip" -d "./utbot-release-${{ inputs.utbot_version }}/"
chmod +x "./utbot-release-${{ inputs.utbot_version }}/unpack_and_run_utbot.sh"
cd "./utbot-release-${{ inputs.utbot_version }}" && ./unpack_and_run_utbot.sh
shell: sh
- name: Testing project
if: ${{ inputs.scope == 'project' }}
run: |
cd "./utbot-release-${{ inputs.utbot_version }}/utbot_distr"
export CURRENT_FOLDER="$( cd $( dirname . ) && pwd )"
RUN_SYSTEM_SCRIPT_PATH=$CURRENT_FOLDER/utbot_run_system.sh
UTBOT_CLI_OPTIONS="generate --project-path ../.. project"
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_OPTIONS
RUN_TESTS="${{ inputs.runtests }}"
if [ $RUN_TESTS = 'true' ]
then
UTBOT_CLI_RUN_OPTIONS="run --project-path ../.. project"
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_RUN_OPTIONS
fi
shell: sh
- name: Testing file
if: ${{ inputs.scope == 'file' }}
run: |
cd "./utbot-release-${{ inputs.utbot_version }}/utbot_distr"
export CURRENT_FOLDER="$( cd $( dirname . ) && pwd )"
RUN_SYSTEM_SCRIPT_PATH=$CURRENT_FOLDER/utbot_run_system.sh
UTBOT_CLI_OPTIONS="generate --project-path ../.. file --file-path ../../${{ inputs.path }}"
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_OPTIONS
RUN_TESTS="${{ inputs.runtests }}"
if [ $RUN_TESTS = 'true' ]
then
UTBOT_CLI_RUN_OPTIONS="run --project-path ../.. file --file-path ../../${{ inputs.path }}"
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_RUN_OPTIONS
fi
shell: sh
- name: Testing directory
if: ${{ inputs.scope == 'directory' }}
run: |
cd "./utbot-release-${{ inputs.utbot_version }}/utbot_distr"
export CURRENT_FOLDER="$( cd $( dirname . ) && pwd )"
RUN_SYSTEM_SCRIPT_PATH=$CURRENT_FOLDER/utbot_run_system.sh
UTBOT_CLI_OPTIONS="generate --project-path ../../${{ inputs.path }} folder --folder-path ../../${{ inputs.path }}"
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_OPTIONS
RUN_TESTS="${{ inputs.runtests }}"
if [ $RUN_TESTS = 'true' ]
then
UTBOT_CLI_RUN_OPTIONS="run --project-path ../../${{ inputs.path }} folder --folder-path ../../${{ inputs.path }}"
$RUN_SYSTEM_SCRIPT_PATH "cli" $UTBOT_CLI_RUN_OPTIONS
fi
ls
shell: sh
- name: Create Pull Request with tests and utbot_report information
uses: peter-evans/create-pull-request@v4
if: ${{ inputs.add_tests == 'true' }}
with:
add-paths: |
tests/
utbot_report/
commit-message: UTBot code analysis add tests and utbot_report information
branch-suffix: short-commit-hash
branch: utbote-code-analysis
title: UTBot code analysis
body: UTBot code analysis add tests and utbot_report information
delete-branch: true
- name: Create Pull Request with tests and utbot_report information
uses: peter-evans/create-pull-request@v4
if: ${{ inputs.add_tests != 'true' }}
with:
add-paths: |
utbot_report/
commit-message: UTBot code analysis add tests and utbot_report information
branch-suffix: short-commit-hash
branch: utbote-code-analysis
title: UTBot code analysis
body: UTBot code analysis add tests and utbot_report information
delete-branch: true
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: utbot_report/project_code_analysis.sarif