Skip to content

im-open javascript action standards #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @im-open/swat @im-open/infra-purple
/.github/CODEOWNERS @im-open/swat
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and Test
on:
pull_request:
paths-ignore:
- '**.md'
jobs:
build:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js 14
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Build
run: npm run build
- name: Format
run: npm run format
- name: Check for unstaged changes
if: runner.os != 'windows'
run: ./check-for-unstaged-changes.sh
49 changes: 49 additions & 0 deletions .github/workflows/increment-version-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Increment Version on Merge
on:
pull_request:
types: [closed]

jobs:
increment-version:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'

runs-on: [ubuntu-20.04]

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Increment the version
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const util = require('util');
const exec = util.promisify(require('child_process').exec);

let newTag;
try {
({ stdout: tag } = await exec(`git describe --tags --abbrev=0`));

tag = tag.replace('\n', '').trim();
core.info(`The latest tag is: ${tag}`);
const majorMinorPatch = tag.split('.');
const patch = parseInt(majorMinorPatch[2]) + 1;
newTag = `${majorMinorPatch[0]}.${majorMinorPatch[1]}.${patch}`
core.info(`The new tag is: ${newTag}`);
}
catch (error) {
newTag = 'v1.0.0';
core.info('An error occurred getting the tags for the repo. It most likely does not have any tags to use. Defaulting to v1.0.0.');
core.info(error);
}

core.info(`Pushing tag '${newTag}' to the repository...`)
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${newTag}`,
sha: context.sha
});
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid",
"printWidth": 125
}
95 changes: 76 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,93 @@
# ReportGenerator

[ReportGenerator](https://github.com/danielpalme/ReportGenerator) converts coverage reports generated by OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
This action is based on [danielpalme/ReportGenerator-GitHub-Action].

[ReportGenerator] converts coverage reports generated by OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.

This action does not generate the code coverage reports itself, those must be created by a previous action.

## Inputs
| Parameter | Is Required | Default Value | Description |
| ----------------- | ----------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `reports` | false | */**/coverage.opencover.xml | The coverage reports that should be parsed (separated by semicolon). Globbing is supported. |
| `targetdir` | false | coverage-results | The directory where the generated report should be saved. |
| `reporttypes` | false | Html;MarkdownSummary; | The output formats and scope (separated by semicolon)<br/>Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary |
| `sourcedirs` | false | '' | Optional directories which contain the corresponding source code (separated by semicolon). The source directories are used if coverage report contains classes without path information. |
| `historydir` | false | '' | Optional directory for storing persistent coverage information. Can be used in future reports to show coverage evolution. |
| `plugins` | false | '' | Optional plugin files for custom reports or custom history storage (separated by semicolon). |
| `assemblyfilters` | false | +* | Optional list of assemblies that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed. |
| `classfilters` | false | +* | Optional list of classes that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed. |
| `filefilters` | false | +* | Optional list of files that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed. |
| `verbosity` | false | Info | The verbosity level of the log messages. <br/>Values: Verbose, Info, Warning, Error, Off |
| `title` | false | '' | Optional title. |
| `tag` | false | ${{ github.run_number }}_${{ github.run_id }} | Optional tag or build version. |
| `customSettings` | false | '' | Optional custom settings (separated by semicolon). See [Settings]. |
| `toolpath` | false | reportgeneratortool | Default directory for installing the dotnet tool. |

## Usage

```yml
- name: Setup .NET Core # Required to execute ReportGenerator
- name: Setup .NET Core # Required to execute ReportGenerator
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.301

- name: dotnet test with coverage
continue-on-error: true
run: dotnet test ${{ env.SOLUTION }} --no-restore --logger trx --configuration Release /property:CollectCoverage=True /property:CoverletOutputFormat=opencover

- name: ReportGenerator
uses: danielpalme/ReportGenerator-GitHub-Action@4.8.12
uses: im-open/code-coverage-report-generator@4.8.12
with:
reports: 'coverage.xml' # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: 'coveragereport' # REQUIRED # The directory where the generated report should be saved.
reporttypes: 'HtmlInline;Cobertura' # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
sourcedirs: '' # Optional directories which contain the corresponding source code (separated by semicolon). The source directories are used if coverage report contains classes without path information.
historydir: '' # Optional directory for storing persistent coverage information. Can be used in future reports to show coverage evolution.
plugins: '' # Optional plugin files for custom reports or custom history storage (separated by semicolon).
assemblyfilters: '+*' # Optional list of assemblies that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
classfilters: '+*' # Optional list of classes that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
filefilters: '+*' # Optional list of files that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
verbosity: 'Info' # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: '' # Optional title.
tag: '${{ github.run_number }}_${{ github.run_id }}' # Optional tag or build version.
customSettings: '' # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: 'reportgeneratortool' # Default directory for installing the dotnet tool.
reports: '*/**/coverage.opencover.xml'
targetdir: ${{ env.CODE_COVERAGE_DIR }}'
reporttypes: 'Html;MarkdownSummary'
sourcedirs: ''
historydir: ''
plugins: ''
assemblyfilters: '-xunit*;-Dapper;'
classfilters: '+*'
filefilters: '-Startup.cs;-Program.cs;-*.cshtml'
verbosity: 'Warning'
title: ${{ env.CODE_COVERAGE_REPORT_NAME }}
tag: '${{ github.workflow}}_${{ github.run_id }}'
customSettings: ''
toolpath: 'reportgeneratortool'

- name: Upload coverage report artifact
uses: actions/upload-artifact@v2.2.3
with:
name: CoverageReport # Artifact name
path: coveragereport # Directory containing files to upload
name: Coverage Report
path: ${{ env.CODE_COVERAGE_DIR }}

- name: Create a PR comment from the summary file
uses: im-open/process-code-coverage-summary@v1.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-file: '${{ env.CODE_COVERAGE_DIR }}/Summary.md'
create-pr-comment: true
create-status-check: false
```

## Recompiling

If changes are made to the action's code in this repository, or its dependencies, you will need to re-compile the action.

```sh
# Installs dependencies and bundles the code
npm run build
```

These commands utilize [ncc](https://github.com/vercel/ncc) to bundle the action and its dependencies into a single file located in the `dist` folder.

## Code of Conduct

This project has adopted the [im-open's Code of Conduct](https://github.com/im-open/.github/blob/master/CODE_OF_CONDUCT.md).

## License

Copyright &copy; 2021, Extend Health, LLC. Code released under the [MIT license](LICENSE).

[danielpalme/ReportGenerator-GitHub-Action]: https://github.com/danielpalme/ReportGenerator-GitHub-Action
[ReportGenerator]: https://github.com/danielpalme/ReportGenerator
[Settings]: https://github.com/danielpalme/ReportGenerator/wiki/Settings
11 changes: 5 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name: 'ReportGenerator'
author: 'danielpalme'
name: 'code-coverage-report-generator'
description: 'Creates coverage reports from tools like OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov'
inputs:
reports:
description: 'The coverage reports that should be parsed (separated by semicolon). Globbing is supported.'
required: true
default: 'coverage.xml'
default: '*/**/coverage.opencover.xml'
targetdir:
description: 'The directory where the generated report should be saved.'
required: true
default: 'coveragereport'
default: 'coverage-results'
reporttypes:
description: 'The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary'
required: false
default: 'HtmlInline;Cobertura'
default: 'Html;MarkdownSummary'
sourcedirs:
description: 'Optional directories which contain the corresponding source code (separated by semicolon). The source directories are used if coverage report contains classes without path information.'
required: false
Expand Down Expand Up @@ -62,5 +61,5 @@ runs:
using: 'node12'
main: 'dist/index.js'
branding:
icon: 'bar-chart-2'
icon: 'bar-chart-2'
color: 'green'
17 changes: 17 additions & 0 deletions check-for-unstaged-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [[ "$(git status --porcelain)" != "" ]]; then
echo ----------------------------------------
echo git status
echo ----------------------------------------
git status
echo ----------------------------------------
echo git diff
echo ----------------------------------------
git diff
echo ----------------------------------------
echo Troubleshooting
echo ----------------------------------------
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && npm run build && npm run format"
exit 1
fi
Loading