-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathaction.yml
executable file
·67 lines (61 loc) · 2.82 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
# action.yml
name: 'Codacy Coverage Reporter'
description: 'Multi-language coverage reporter for Codacy'
branding:
icon: 'check'
color: 'gray-dark'
inputs:
project-token:
required: false
description: "API project token to authenticate on the Codacy API while uploading the coverage data"
api-token:
required: false
description: "API account token to authenticate on the Codacy API while uploading the coverage data"
coverage-reports:
description: 'Optional comma separated list of coverage reports to send to Codacy'
required: false
default: ''
language:
description: 'Optionally force associating a language with your coverage report'
required: false
force-coverage-parser:
description: 'Optionally force using a specific coverage report parser'
required: false
coverage-reporter-version:
description: 'Optionally force using a specific coverage reporter version'
required: false
runs:
using: "composite"
steps:
- name: "Set Repository Variables"
shell: bash
run: |
echo "ORGANIZATION_PROVIDER=$(if [[ $GITHUB_SERVER_URL == "https://github.com" ]]; then echo "gh"; else echo "ghe"; fi)" >> $GITHUB_ENV
echo "OWNER_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)" >> $GITHUB_ENV
echo "REPOSITORY_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)" >> $GITHUB_ENV
echo "CODACY_REPORTER_VERSION=$(if [ -n "${{ inputs.coverage-reporter-version }}" ]; then echo "${{ inputs.coverage-reporter-version }}"; fi)" >> $GITHUB_ENV
- name: "Run coverage-reporter"
shell: bash
run: |
echo "Welcome to Coverage-Reporter-Action"
set -eux
report_list=''
# comma separated list of report files
if [ -n "${{ inputs.coverage-reports }}" ]; then report_list="${{ inputs.coverage-reports }}"; fi
IFS=','
report_array=$report_list
params=''
for report in $report_array
do
if [ ! -z "$report" ]
then
params="$params -r $report"
fi
done
auth=''
if [ -n "${{ inputs.api-token }}" ]; then auth="--api-token ${{ inputs.api-token }} --organization-provider $ORGANIZATION_PROVIDER --username $OWNER_NAME --project-name $REPOSITORY_NAME"; fi
if [ -n "${{ inputs.project-token }}" ]; then auth="--project-token ${{ inputs.project-token }}"; fi
if [ -n "${{ inputs.force-coverage-parser }}" ]; then force_parser="--force-coverage-parser ${{ inputs.force-coverage-parser }}"; else force_parser=""; fi
if [ -n "${{ inputs.language }}" ]; then lang="--language ${{ inputs.language }}"; else lang=""; fi
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $lang $force_parser $auth $params --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth