Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 16, 2021
0 parents commit 3f58b0e
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2020 Codacy.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# codacy-coverage-reporter action

> 🤖 Automated multi-language coverage reporter for Codacy
This action runs the [codacy-coverage-reporter](https://github.com/codacy/codacy-coverage-reporter) for all commits and pull requests with your Codacy configuration.

## Usage

Create a new workflow `.yml` file in the `.github/workflows/` directory.

### .github/workflows/codacy-coverage-reporter.yml

```yml
name: codacy-coverage-reporter

on: ["push"]

jobs:
codacy-coverage-reporter:
runs-on: ubuntu-latest
name: codacy-coverage-reporter
steps:
- uses: actions/checkout@master
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# or
# api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: cobertura.xml
```

## Workflow options

Change these options in the workflow `.yml` file to meet your GitHub project needs.

| Setting | Description | Default value |
| ------------------ | ------------------------------------------------ | ------------------------------------- |
| `api-token` | An account API token | `${{ secrets.CODACY_API_TOKEN }}` |
| `project-token` | The project API token | `${{ secrets.CODACY_PROJECT_TOKEN }}` |
| `coverage-reports` | Optional Comma separated list of reports to send | `''` |
52 changes: 52 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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 retrieve your remote Codacy configuration for the project being analyzed"
api-token:
required: false
description: "API account token to retrieve your remote Codacy configuration for the project being analyzed"
coverage-reports:
description: 'Optional comma separated list of coverage reports to send to Codacy'
required: false
default: ''
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
- name: "Run coverage-reporter"
shell: bash
run: |
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
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth $params --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth
37 changes: 37 additions & 0 deletions cobertura.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<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">
<sources>
<source>sources</source>
</sources>
<packages>
<package name="3" line-rate="1" branch-rate="1">
<classes>
<class name="cc.js" filename="cc.js" line-rate="1" branch-rate="1">
<methods>
<method name="normalize" hits="11" signature="()V">
<lines>
<line number="1" hits="11" />
</lines>
</method>
<method name="getBrand" hits="7" signature="()V">
<lines>
<line number="5" hits="7" />
</lines>
</method>
</methods>
<lines>
<line number="1" hits="1" branch="false" />
<line number="2" hits="11" branch="false" />
<line number="5" hits="1" branch="false" />
<line number="6" hits="7" branch="false" />
<line number="15" hits="7" branch="false" />
<line number="17" hits="7" branch="false" />
<line number="18" hits="25" branch="true" condition-coverage="100% (4/4)" />
<line number="20" hits="6" branch="false" />
</lines>
</class>
</classes>
</package>
</packages>
</coverage>

0 comments on commit 3f58b0e

Please sign in to comment.