Skip to content

Commit 3f58b0e

Browse files
feat: build for release
0 parents  commit 3f58b0e

File tree

4 files changed

+143
-0
lines changed

4 files changed

+143
-0
lines changed

Diff for: LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2020 Codacy.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

Diff for: README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# codacy-coverage-reporter action
2+
3+
> 🤖 Automated multi-language coverage reporter for Codacy
4+
5+
This action runs the [codacy-coverage-reporter](https://github.com/codacy/codacy-coverage-reporter) for all commits and pull requests with your Codacy configuration.
6+
7+
## Usage
8+
9+
Create a new workflow `.yml` file in the `.github/workflows/` directory.
10+
11+
### .github/workflows/codacy-coverage-reporter.yml
12+
13+
```yml
14+
name: codacy-coverage-reporter
15+
16+
on: ["push"]
17+
18+
jobs:
19+
codacy-coverage-reporter:
20+
runs-on: ubuntu-latest
21+
name: codacy-coverage-reporter
22+
steps:
23+
- uses: actions/checkout@master
24+
- name: Run codacy-coverage-reporter
25+
uses: codacy/codacy-coverage-reporter-action@master
26+
with:
27+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
28+
# or
29+
# api-token: ${{ secrets.CODACY_API_TOKEN }}
30+
coverage-reports: cobertura.xml
31+
```
32+
33+
## Workflow options
34+
35+
Change these options in the workflow `.yml` file to meet your GitHub project needs.
36+
37+
| Setting | Description | Default value |
38+
| ------------------ | ------------------------------------------------ | ------------------------------------- |
39+
| `api-token` | An account API token | `${{ secrets.CODACY_API_TOKEN }}` |
40+
| `project-token` | The project API token | `${{ secrets.CODACY_PROJECT_TOKEN }}` |
41+
| `coverage-reports` | Optional Comma separated list of reports to send | `''` |

Diff for: action.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# action.yml
2+
name: 'Codacy Coverage Reporter'
3+
description: 'Multi-language coverage reporter for Codacy'
4+
branding:
5+
icon: 'check'
6+
color: 'gray-dark'
7+
inputs:
8+
project-token:
9+
required: false
10+
description: "API project token to retrieve your remote Codacy configuration for the project being analyzed"
11+
api-token:
12+
required: false
13+
description: "API account token to retrieve your remote Codacy configuration for the project being analyzed"
14+
coverage-reports:
15+
description: 'Optional comma separated list of coverage reports to send to Codacy'
16+
required: false
17+
default: ''
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: "Set Repository Variables"
22+
shell: bash
23+
run: |
24+
echo "ORGANIZATION_PROVIDER=$(if [[ $GITHUB_SERVER_URL == "https://github.com" ]]; then echo "gh"; else echo "ghe"; fi)" >> $GITHUB_ENV
25+
echo "OWNER_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)" >> $GITHUB_ENV
26+
echo "REPOSITORY_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)" >> $GITHUB_ENV
27+
- name: "Run coverage-reporter"
28+
shell: bash
29+
run: |
30+
set -eux
31+
32+
report_list=''
33+
# comma separated list of report files
34+
if [ -n "${{ inputs.coverage-reports }}" ]; then report_list="${{ inputs.coverage-reports }}"; fi
35+
36+
IFS=','
37+
report_array=$report_list
38+
params=''
39+
for report in $report_array
40+
do
41+
if [ ! -z "$report" ]
42+
then
43+
params="$params -r $report"
44+
fi
45+
done
46+
47+
auth=''
48+
if [ -n "${{ inputs.api-token }}" ]; then auth="--api-token ${{ inputs.api-token }} --organization-provider $ORGANIZATION_PROVIDER --username $OWNER_NAME --project-name $REPOSITORY_NAME"; fi
49+
if [ -n "${{ inputs.project-token }}" ]; then auth="--project-token ${{ inputs.project-token }}"; fi
50+
51+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $params --partial &&\
52+
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth

Diff for: cobertura.xml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" ?>
2+
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3+
<coverage lines-valid="8" lines-covered="8" line-rate="1" branches-valid="4" branches-covered="4" branch-rate="1" timestamp="1394890504210" complexity="0" version="0.1">
4+
<sources>
5+
<source>sources</source>
6+
</sources>
7+
<packages>
8+
<package name="3" line-rate="1" branch-rate="1">
9+
<classes>
10+
<class name="cc.js" filename="cc.js" line-rate="1" branch-rate="1">
11+
<methods>
12+
<method name="normalize" hits="11" signature="()V">
13+
<lines>
14+
<line number="1" hits="11" />
15+
</lines>
16+
</method>
17+
<method name="getBrand" hits="7" signature="()V">
18+
<lines>
19+
<line number="5" hits="7" />
20+
</lines>
21+
</method>
22+
</methods>
23+
<lines>
24+
<line number="1" hits="1" branch="false" />
25+
<line number="2" hits="11" branch="false" />
26+
<line number="5" hits="1" branch="false" />
27+
<line number="6" hits="7" branch="false" />
28+
<line number="15" hits="7" branch="false" />
29+
<line number="17" hits="7" branch="false" />
30+
<line number="18" hits="25" branch="true" condition-coverage="100% (4/4)" />
31+
<line number="20" hits="6" branch="false" />
32+
</lines>
33+
</class>
34+
</classes>
35+
</package>
36+
</packages>
37+
</coverage>

0 commit comments

Comments
 (0)