Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Sep 25, 2019
1 parent 82e9841 commit 7c5b875
Show file tree
Hide file tree
Showing 19 changed files with 6,173 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
max_line_length = 80
indent_size = 4

[*.yml]
indent_size = 2
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://svartalf.info/donate/
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Continuous integration

on: [pull_request, push]

jobs:
check_pr:
runs-on: ubuntu-latest
steps:
- name: Create npm configuration
run: echo "//npm.pkg.github.com/:_authToken=${token}" >> ~/.npmrc
env:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v1

- name: "npm ci"
run: npm ci

- name: "npm run build"
run: npm run build

- name: "npm run test"
run: npm run test
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
__tests__/runner/*

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@actions-rs:registry=https://npm.pkg.github.com
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- First public version
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2019 actions-rs team and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
151 changes: 149 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,149 @@
# grcov
[Work in process]
# `grcov` Action

![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)
[![Gitter](https://badges.gitter.im/actions-rs/community.svg)](https://gitter.im/actions-rs/community)
![Experimental status](https://img.shields.io/badge/status-experimental-yellow.svg)

This GitHub Action collects and aggregates code coverage data with the
[grcov](https://github.com/mozilla/grcov) tool.

## Example workflow

```yaml
on: [push]

name: Code Coverage

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
'CARGO_INCREMENTAL': '0'
'RUSTFLAGS': '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads'
- uses: actions-rs/[email protected]
```
## Usage
1. As `grcov` works with coverage data generated by the unstable [`-Z profile` feature](https://github.com/rust-lang/rust/issues/42524),
you need to install `nightly` toolchain, for example,
with the [`actions-rs/toolchain`](https://github.com/actions-rs/toolchain) Action:

```yaml
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
```

2. It is strongly recommended to call `cargo clean` command
if any of `cargo check`, `cargo build`, `cargo test`
or other similar commands were executed already in this workspace.

```yaml
- uses: actions-rs/cargo@v1
with:
command: clean
```

3. Create a configuration file for `grcov`, see [config section](#config) for details.

4. Execute the `cargo test` command.
It is required to add `CARGO_INCREMENTAL` and `RUSTFLAGS` environment variables
for this command, see [grcov](https://github.com/mozilla/grcov) page for details.

```yaml
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast # Customize args for your own needs
env:
'CARGO_INCREMENTAL': '0'
'RUSTFLAGS': '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads'
```

Note that `-Clink-dead-code` flag might be broken for macOS environments,
see [#63047](https://github.com/rust-lang/rust/issues/63047)

5. Add the `actions-rs@grcov` Action to the workflow.

```yaml
- id: coverage
uses: actions-rs/[email protected]
```

6. After the successful execution, `actions-rs@grcov`
will set an Action output called `report`
with an absolute path to the coverage report file.

This file can be uploaded to any code coverage service,
ex. with [codecov](https://github.com/marketplace/actions/codecov) or [coveralls](https://github.com/marketplace/actions/coveralls-github-action) Actions help:

```yaml
- name: Coveralls upload
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage.outputs.report }}
```

## Inputs

* `config`: Configuration file path (relative to repository root, default to `.github/actions-rs/grcov.yml`)

## Outputs

* `report`: Absolute path to the report file

## Config

`grcov` execution can be tuned with the configuration file.\
By default this Action tries to load it from the `.github/actions-rs/grcov.yml` path
(relative to the repository root directory); you can change file location with the [`config`](#inputs) input, ex.

```yaml
- uses: actions-rs/[email protected]
with:
config: configs/grcov.yml
```

If configuration file is missing, default values will be used by the `grcov`.

All possible keys in the config are optional and directly mapped
to the [grcov](https://github.com/mozilla/grcov#usage) flags and options.\
Note that not all parameters can be changed via this file, see [example](#example) below
for config file format and available options.

### Example

```yaml
branch: true
ignore-not-existing: true
llvm: true
filter: covered
output-type: lcov
prefix-dir: /home/user/build/
ignore-dir:
- "/*"
- "C:/*"
- "../*"
path-mapping:
- "/path1"
- "/path2"
```

## Notes

1. [Coveralls](https://github.com/marketplace/actions/coveralls-github-action) Action is expecting `LCOV` format,
do not use the `coveralls` or `coveralls+` output type for the `grcov`.\
Instead, set the `output-type` config value to `lcov`.
12 changes: 12 additions & 0 deletions __tests__/args.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const testEnvVars = {
}

describe('actions-rs/grcov', () => {
beforeEach(() => {
for (const key in testEnvVars)
process.env[key] = testEnvVars[key as keyof typeof testEnvVars]
})

it('Should do something', async () => {
});
});
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'rust-grcov'
description: 'Collect and aggregate code coverage information with the Mozilla grcov tool'
author: 'actions-rs team'
branding:
icon: play-circle
color: black
inputs:
config:
description: Path to the configuration file (optional, relative to the repository root)
required: false
default: .github/actions-rs/grcov.yml

outputs:
report:
description: Absolute path to the generated code coverage file

runs:
using: 'node12'
main: 'dist/index.js'
1 change: 1 addition & 0 deletions dist/index.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}
Loading

0 comments on commit 7c5b875

Please sign in to comment.