Compare commits
180 Commits
node-action
...
v1.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fc7722ded | |||
| 08574d831c | |||
| 0c1af46295 | |||
| f8c87eb84e | |||
| 8b988c28b0 | |||
| 4686d7034c | |||
| 4ef30f27a0 | |||
| 58cd650984 | |||
| efb844969e | |||
| c6de3f8548 | |||
| 7de43a7373 | |||
| d3e4a774c5 | |||
| 09facdbe25 | |||
| c770ad46b3 | |||
| 55dde41e2b | |||
| beb5a9626e | |||
| a869df4496 | |||
| a116b3286f | |||
| a6c42c7a01 | |||
| 3c9462a34c | |||
| 5155bd4dd2 | |||
| c047d5942e | |||
| d9b5cc1d8b | |||
| 0d4ed40235 | |||
| 239febf655 | |||
| 089f66bf94 | |||
| 3db8e6c626 | |||
| 97477378d5 | |||
| 5aab34a5de | |||
| 7bd0b70f4c | |||
| e1530fdc6a | |||
| 4093ac2f32 | |||
| f1824ac807 | |||
| 3fbed96f43 | |||
| 54f44cc9f4 | |||
| a74dfd1451 | |||
| 5bdef2c17a | |||
| 7d5dfa5490 | |||
| 5f38498d62 | |||
| 8b6b12970b | |||
| 283d2693b9 | |||
| dade30aaa0 | |||
| 45781c3764 | |||
| 4ebd4afddb | |||
| 55d6a07412 | |||
| becb93ba4e | |||
| a7c76ea20b | |||
| 36d7ee02e2 | |||
| 2c9a90e8ef | |||
| c76d967024 | |||
| 182414a4c5 | |||
| 1daf42f4a6 | |||
| 0445c85879 | |||
| ec5dd54001 | |||
| 563896ed23 | |||
| 7051d617d5 | |||
| e251b2328e | |||
| 9c8364c4b9 | |||
| 2ce6928a47 | |||
| 97889d423a | |||
| f32c526fb6 | |||
| f40be2e051 | |||
| c838bce9ba | |||
| a10ae7dc1c | |||
| 7b58dd4615 | |||
| 4c21e05017 | |||
| c5e41a8c86 | |||
| 59ad392722 | |||
| 2df0a7632f | |||
| b9325ac3dd | |||
| 1d594a8c0e | |||
| d02c2109fe | |||
| 529a536f37 | |||
| dba9e16939 | |||
| 6ebb0218c1 | |||
| 59241bde96 | |||
| 6228851670 | |||
| 5e530f4a66 | |||
| f08bd0b1cb | |||
| 48269c03b1 | |||
| abd3026ea7 | |||
| 076efa6234 | |||
| ff34c520be | |||
| 703dcd27a4 | |||
| e2ce2d2a09 | |||
| d035c0b282 | |||
| ef391107f0 | |||
| 912b097972 | |||
| 86a2fa8deb | |||
| 6004246f47 | |||
| 5d3f01ccdc | |||
| 2d80980946 | |||
| fadbb25281 | |||
| ad774549da | |||
| 07127fde53 | |||
| 9128542d5d | |||
| 6d208f5b52 | |||
| 8ddda09c14 | |||
| e16d515d3b | |||
| 6b30325ebb | |||
| 95f699a0a9 | |||
| 273443b325 | |||
| a258ec8bb8 | |||
| 89692c91b7 | |||
| 85ec2c8d83 | |||
| f3570723ef | |||
| f40f110376 | |||
| 4f81def87b | |||
| ddc46b3107 | |||
| 1b088680d5 | |||
| 22f6ff10ac | |||
| 0ceca4b5d3 | |||
| 3658bafacb | |||
| ef3b48314f | |||
| dbf1ddee08 | |||
| cc6b0c11d2 | |||
| f532c3a145 | |||
| 143333ba90 | |||
| a50851cfd8 | |||
| 6914527afb | |||
| fff75f1901 | |||
| 1804a456ff | |||
| d1b4c72fc5 | |||
| 6fd09f835d | |||
| e866b3854d | |||
| 608816e426 | |||
| 2ce3b3807d | |||
| 0e6a911c9b | |||
| d04135f7cf | |||
| 7938e79f4c | |||
| a3a6becb2c | |||
| bf0e754c09 | |||
| daa5098552 | |||
| 71d5dea6af | |||
| e34ee48524 | |||
| d7c91c57ee | |||
| d9faadf52a | |||
| c70450d006 | |||
| a6d365dd4c | |||
| 94278ffe1b | |||
| ebea5cacdf | |||
| 6a65fa4d50 | |||
| 4623a4dc3d | |||
| c98408608b | |||
| 49c86d6a5f | |||
| 6ec347819d | |||
| 44ca3d2c84 | |||
| 66879ff350 | |||
| 797e92895e | |||
| a6337803aa | |||
| 2613f978c9 | |||
| 4c6a7296af | |||
| 4fec3dfa96 | |||
| 355d574b25 | |||
| a497b16d77 | |||
| ab46201142 | |||
| ecf5f576a0 | |||
| 8c950ae5c5 | |||
| 3d303911df | |||
| eb1ea256cb | |||
| 5f55456d46 | |||
| ade1ebf812 | |||
| 31d7d88849 | |||
| d608de8763 | |||
| 08a0ecb0f3 | |||
| 3dfea70b3f | |||
| f291e7ca9d | |||
| 78d806df69 | |||
| dd4242c61d | |||
| fc0e9fde50 | |||
| cf0e744e2c | |||
| fd07c5fc0c | |||
| 3d11715b9e | |||
| cec654a0a7 | |||
| 41a31f1ccf | |||
| d073b23c28 | |||
| 11d69070bf | |||
| dd2a59ac10 | |||
| 3ec2345d08 | |||
| aea83764c6 |
+23
-19
@@ -1,23 +1,27 @@
|
|||||||
name: Example workflow for Codecov
|
name: Workflow for Codecov Action
|
||||||
on: [push]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
# - name: Setup Python
|
- name: Install dependencies
|
||||||
# uses: actions/setup-python@master
|
run: npm install
|
||||||
|
- name: Run tests and collect coverage
|
||||||
# - name: Generate coverage report
|
run: yarn run test-all
|
||||||
# run: |
|
- name: Upload coverage to Codecov
|
||||||
# pip install pytest
|
uses: ./
|
||||||
# pip install pytest-cov
|
with:
|
||||||
# pytest --cov=./ --cov-report=xml
|
files: ./coverage/calculator/coverage-final.json,./coverage/index/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
- name: Upload coverage to Codecov
|
flags: unittest
|
||||||
uses: ./
|
name: codecov-1
|
||||||
with:
|
- name: Upload coverage to Codecov (verbose)
|
||||||
token: ${{secrets.CODECOV_TOKEN}}
|
uses: ./
|
||||||
flags: unittest
|
with:
|
||||||
name: codecov-1
|
files: ./coverage/calculator/coverage-final.json,./coverage/index/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: unittest
|
||||||
|
name: codecov-1
|
||||||
|
verbose: true
|
||||||
|
|||||||
+5
-2
@@ -76,7 +76,7 @@ typings/
|
|||||||
# nuxt.js build output
|
# nuxt.js build output
|
||||||
.nuxt
|
.nuxt
|
||||||
|
|
||||||
# react / gatsby
|
# react / gatsby
|
||||||
public/
|
public/
|
||||||
|
|
||||||
# vuepress build output
|
# vuepress build output
|
||||||
@@ -89,4 +89,7 @@ public/
|
|||||||
.fusebox/
|
.fusebox/
|
||||||
|
|
||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|
||||||
|
# macOS Finder metadata
|
||||||
|
.DS_Store
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
### 1.1.1
|
||||||
|
|
||||||
|
#### Fixes
|
||||||
|
- #184 Add automations ensure proper builds and deployments
|
||||||
|
- #184 Fixes verbose flag
|
||||||
|
|
||||||
|
### 1.1.0
|
||||||
|
|
||||||
|
#### Features
|
||||||
|
- #110 Add "working-directory:" input
|
||||||
|
- #174 Support Xcode specificed parameters
|
||||||
|
|
||||||
|
#### Fixes
|
||||||
|
- #172 File is saved as text
|
||||||
|
|
||||||
|
#### Dependencies and Misc
|
||||||
|
- #166 Bump requestretry from 4.1.1 to 4.1.2
|
||||||
|
- #169 Bump typescript from 4.0.5 to 4.1.2
|
||||||
|
- #178 Bump @types/jest from 26.0.15 to 26.0.19
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019 Codecov
|
Copyright (c) 2019-2020 Codecov
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
# Codecov GitHub Action
|
# Codecov GitHub Action
|
||||||
|
|
||||||
[](https://github.com/marketplace/actions/codecov)
|
[](https://github.com/marketplace/actions/codecov)
|
||||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
||||||
|
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||||
|
|
||||||
|
>The latest release of this Action adds support for tokenless uploads from GitHub Actions!
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number as a `step` within your `workflow.yml` file. This Action also requires you to [provide an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) from [codecov.io](https://www.codecov.io) (tip: in order to avoid exposing your token, store it as a `secret`). Optionally, you can choose to include up to four additional inputs to customize the upload context.
|
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (`@v1` is recommended) as a `step` within your `workflow.yml` file.
|
||||||
|
|
||||||
|
If you have a *private repository*, this Action also requires you to [provide an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) from [codecov.io](https://www.codecov.io) (tip: in order to avoid exposing your token, store it as a `secret`). Optionally, you can choose to include up to four additional inputs to customize the upload context. **For public repositories, no token is needed**
|
||||||
|
|
||||||
Inside your `.github/workflows/workflow.yml` file:
|
Inside your `.github/workflows/workflow.yml` file:
|
||||||
|
|
||||||
@@ -14,28 +19,37 @@ steps:
|
|||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- uses: codecov/codecov-action@v1
|
- uses: codecov/codecov-action@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }} #required
|
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||||
file: ./coverage.xml #optional
|
file: ./coverage.xml # optional
|
||||||
flags: unittests #optional
|
files: ./coverage1.xml,./coverage2.xml # optional
|
||||||
name: codecov-umbrella #optional
|
flags: unittests # optional
|
||||||
yml: ./codecov.yml #optional
|
name: codecov-umbrella # optional
|
||||||
|
fail_ci_if_error: true # optional (default = false)
|
||||||
|
verbose: true # optional (default = false)
|
||||||
```
|
```
|
||||||
>**Note**: This assumes that you've set your Codecov token inside *Settings > Secrets* as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io).
|
>**Note**: This assumes that you've set your Codecov token inside *Settings > Secrets* as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are *not* available to forks of repositories.
|
||||||
|
|
||||||
## Arguments
|
## Arguments
|
||||||
|
|
||||||
Codecov's Action currently supports five inputs from the user: `token`, `file`, `flags`,`name`, and `yml`. These inputs, along with their descriptions and usage contexts, are listed in the table below:
|
Codecov's Action currently supports five inputs from the user: `token`, `file`, `flags`,`name`, and `fail_ci_if_error`. These inputs, along with their descriptions and usage contexts, are listed in the table below:
|
||||||
|
|
||||||
| Input | Description | Usage |
|
| Input | Description | Usage |
|
||||||
| :---: | :---: | :---: |
|
| :---: | :---: | :---: |
|
||||||
| `token` | Used to authorize coverage report uploads | *Required* |
|
| `token` | Used to authorize coverage report uploads | *Required for private repos* |
|
||||||
| `file` | Path to the coverage report(s) | Optional
|
| `file` | Path to the coverage report(s) | Optional
|
||||||
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.) | Optional
|
| `files` | Comma-separated paths to the coverage report(s) | Optional
|
||||||
| `name` | Custom defined name for the build | Optional
|
| `directory` | Directory to search for coverage reports. | Optional
|
||||||
| `yml` | Path to codecov.yml config file | Optional
|
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | Optional
|
||||||
|
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
|
||||||
|
| `name` | Custom defined name for the upload | Optional
|
||||||
|
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||||
|
| `path_to_write_report` | Write upload file to path before uploading | Optional
|
||||||
|
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
||||||
|
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
||||||
|
| `xcode_derived_data` | Custom Derived Data Path for Coverage.profdata and gcov processing | Optional
|
||||||
|
| `xcode_package` | Specify packages to build coverage. Uploader will only build these packages. This can significantly reduces time to build coverage reports. -J 'MyAppName' Will match "MyAppName" and "MyAppNameTests" -J '^ExampleApp$' Will match only "ExampleApp" not "ExampleAppTests" | Optional
|
||||||
|
|
||||||
### Example `workflow.yml` with Codecov Action
|
### Example `workflow.yml` with Codecov Action
|
||||||
>**Note**: The latest release of this Action adds support for macOS and Windows builds!
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: Example workflow for Codecov
|
name: Example workflow for Codecov
|
||||||
@@ -44,32 +58,43 @@ jobs:
|
|||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
env:
|
||||||
|
OS: ${{ matrix.os }}
|
||||||
|
PYTHON: '3.7'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@master
|
uses: actions/setup-python@master
|
||||||
with:
|
with:
|
||||||
version: 3.7
|
python-version: 3.7
|
||||||
- name: Generate coverage report
|
- name: Generate coverage report
|
||||||
run: |
|
run: |
|
||||||
pip install pytest
|
pip install pytest
|
||||||
pip install pytest-cov
|
pip install pytest-cov
|
||||||
pytest --cov=./ --cov-report=xml
|
pytest --cov=./ --cov-report=xml
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
file: ./coverage.xml
|
file: ./coverage.xml
|
||||||
|
files: ./coverage1.xml,./coverage2.xml
|
||||||
|
directory: ./coverage/reports/
|
||||||
flags: unittests
|
flags: unittests
|
||||||
|
env_vars: OS,PYTHON
|
||||||
name: codecov-umbrella
|
name: codecov-umbrella
|
||||||
yml: ./codecov.yml
|
fail_ci_if_error: true
|
||||||
|
path_to_write_report: ./coverage/codecov_report.txt
|
||||||
|
verbose: true
|
||||||
```
|
```
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome! Check out the [Contribution Guide](CONTRIBUTING.md).
|
Contributions are welcome! Check out the [Contribution Guide](CONTRIBUTING.md).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The code in this project is released under the [MIT License](LICENSE).
|
The code in this project is released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
|
||||||
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_large)
|
||||||
|
|||||||
+26
-9
@@ -1,26 +1,43 @@
|
|||||||
name: 'Codecov'
|
name: 'Codecov'
|
||||||
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
|
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
|
||||||
author: 'Ibrahim Ali <@ibrahim0814> | Codecov'
|
author: 'Ibrahim Ali <@ibrahim0814> & Thomas Hu <@thomasrockhu> | Codecov'
|
||||||
inputs:
|
inputs:
|
||||||
name:
|
name:
|
||||||
description: 'User defined upload name. Visible in Codecov UI'
|
description: 'User defined upload name. Visible in Codecov UI'
|
||||||
required: false
|
required: false
|
||||||
token:
|
token:
|
||||||
description: 'Repository upload token - get it from codecov.io'
|
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
||||||
required: true
|
required: false
|
||||||
file:
|
file:
|
||||||
description: 'Path to coverage file to upload'
|
description: 'Path to coverage file to upload'
|
||||||
required: false
|
required: false
|
||||||
|
files:
|
||||||
|
description: 'Comma-separated list of files to upload'
|
||||||
|
required: false
|
||||||
|
directory:
|
||||||
|
description: 'Directory to search for coverage reports.'
|
||||||
|
required: false
|
||||||
flags:
|
flags:
|
||||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||||
required: false
|
required: false
|
||||||
yml:
|
path_to_write_report:
|
||||||
description: 'Specify the location of the .codecov.yml config file'
|
description: 'Write upload file to path before uploading'
|
||||||
|
required: false
|
||||||
|
env_vars:
|
||||||
|
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
||||||
|
required: false
|
||||||
|
fail_ci_if_error:
|
||||||
|
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||||
|
required: false
|
||||||
|
verbose:
|
||||||
|
description: 'Specify whether the Codecov output should be verbose'
|
||||||
|
required: false
|
||||||
|
working-directory:
|
||||||
|
description: 'Directory in which to execute codecov.sh'
|
||||||
required: false
|
required: false
|
||||||
branding:
|
branding:
|
||||||
color: 'red'
|
color: 'red'
|
||||||
icon: 'umbrella'
|
icon: 'umbrella'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
||||||
|
|||||||
Vendored
+46394
-25011
File diff suppressed because one or more lines are too long
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
npm i --package-lock-only
|
||||||
|
npm run build
|
||||||
|
git add dist/index.js
|
||||||
@@ -1,72 +1,206 @@
|
|||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const exec = require("@actions/exec");
|
const exec = require("@actions/exec");
|
||||||
const request = require("request");
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const request = require('requestretry');
|
||||||
|
|
||||||
|
let fail_ci;
|
||||||
|
let verbose;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const name = core.getInput("name");
|
const name = core.getInput("name");
|
||||||
const token = core.getInput("token");
|
const token = core.getInput("token");
|
||||||
const flags = core.getInput("flags");
|
const flags = core.getInput("flags");
|
||||||
const file = core.getInput("file");
|
const file = core.getInput("file");
|
||||||
const yml = core.getInput("yml");
|
const files = core.getInput("files");
|
||||||
|
const env_vars = core.getInput("env_vars");
|
||||||
|
const dir = core.getInput("directory");
|
||||||
|
const write_path = core.getInput("path_to_write_report");
|
||||||
|
const working_dir = core.getInput("working-directory");
|
||||||
|
const xcode_derived_data = core.getInput("xcode_derived_data");
|
||||||
|
const xcode_package = core.getInput("xcode_package");
|
||||||
|
|
||||||
request("https://codecov.io/bash", (error, response, body) => {
|
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||||
if (error) throw error;
|
verbose = core.getInput("verbose").toLowerCase();
|
||||||
|
|
||||||
fs.writeFile("codecov.sh", body, err => {
|
if (
|
||||||
if (err) throw err;
|
fail_ci === "yes" ||
|
||||||
|
fail_ci === "y" ||
|
||||||
|
fail_ci === "true" ||
|
||||||
|
fail_ci === "t" ||
|
||||||
|
fail_ci === "1"
|
||||||
|
) {
|
||||||
|
fail_ci = true;
|
||||||
|
} else {
|
||||||
|
fail_ci = false;
|
||||||
|
}
|
||||||
|
|
||||||
let output = "";
|
if (
|
||||||
let execError = "";
|
verbose === "yes" ||
|
||||||
const options = {};
|
verbose === "y" ||
|
||||||
options.listeners = {
|
verbose === "true" ||
|
||||||
stdout: data => {
|
verbose === "t" ||
|
||||||
output += data.toString();
|
verbose === "1"
|
||||||
},
|
) {
|
||||||
stderr: data => {
|
verbose = true;
|
||||||
execError += data.toString();
|
} else {
|
||||||
|
verbose = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
request({
|
||||||
|
json: false,
|
||||||
|
maxAttempts: 10,
|
||||||
|
timeout: 3000,
|
||||||
|
url: "https://codecov.io/bash"
|
||||||
|
}, (error, response, body) => {
|
||||||
|
try {
|
||||||
|
if (error && fail_ci) {
|
||||||
|
throw error;
|
||||||
|
} else if (error) {
|
||||||
|
core.warning(`Codecov warning: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFile("codecov.sh", body, err => {
|
||||||
|
if (err && fail_ci) {
|
||||||
|
throw err;
|
||||||
|
} else if (err) {
|
||||||
|
core.warning(`Codecov warning: ${err.message}`);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
options.env = {
|
let output = "";
|
||||||
CODECOV_TOKEN: `${token}`,
|
let execError = "";
|
||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
const options = {};
|
||||||
GITHUB_REF: process.env.GITHUB_REF,
|
options.listeners = {
|
||||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
stdout: data => {
|
||||||
GITHUB_SHA: process.env.GITHUB_SHA
|
output += data.toString();
|
||||||
};
|
},
|
||||||
|
stderr: data => {
|
||||||
|
execError += data.toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (file) {
|
options.env = Object.assign(process.env, {
|
||||||
exec
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
.exec(
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
"bash",
|
GITHUB_REF: process.env.GITHUB_REF,
|
||||||
["codecov.sh", "-f", `${file}`, "-n", `${name}`, "-F", `${flags}`, '-y', `${yml}`],
|
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||||
options
|
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||||
)
|
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || ''
|
||||||
.then(() => {
|
|
||||||
unlinkFile()
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
exec
|
|
||||||
.exec(
|
|
||||||
"bash",
|
|
||||||
["codecov.sh", "-n", `${name}`, "-F", `${flags}`, '-y', `${yml}`],
|
|
||||||
options
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
unlinkFile()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const unlinkFile = () => {
|
|
||||||
fs.unlink("codecov.sh", err => {
|
|
||||||
if (err) throw err;
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
});
|
if(token){
|
||||||
|
options.env.CODECOV_TOKEN = token
|
||||||
|
}
|
||||||
|
|
||||||
|
const env_vars_arg = []
|
||||||
|
for (let env_var of env_vars.split(",")) {
|
||||||
|
let env_var_clean = env_var.trim();
|
||||||
|
if (env_var_clean) {
|
||||||
|
options.env[env_var_clean] = process.env[env_var_clean];
|
||||||
|
env_vars_arg.push(env_var_clean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const execArgs = ["codecov.sh"];
|
||||||
|
execArgs.push("-Q", "github-action");
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
execArgs.push(
|
||||||
|
"-f", `${file}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (files) {
|
||||||
|
files.split(',').forEach(f => {
|
||||||
|
execArgs.push(
|
||||||
|
"-f", `${f}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dir) {
|
||||||
|
execArgs.push(
|
||||||
|
"-s", `${dir}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
execArgs.push(
|
||||||
|
"-n", `${name}`,
|
||||||
|
"-F", `${flags}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fail_ci) {
|
||||||
|
execArgs.push(
|
||||||
|
"-Z"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env_vars_arg.length) {
|
||||||
|
execArgs.push(
|
||||||
|
"-e", env_vars_arg.join(",")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (write_path) {
|
||||||
|
execArgs.push(
|
||||||
|
"-q", `${write_path}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
execArgs.push(
|
||||||
|
"-v"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (working_dir) {
|
||||||
|
options.cwd = working_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xcode_derived_data) {
|
||||||
|
execArgs.push(
|
||||||
|
"-D", `${xcode_derived_data}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xcode_package) {
|
||||||
|
execArgs.push(
|
||||||
|
"-J", `${xcode_package}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
exec.exec("bash", execArgs, options)
|
||||||
|
.catch(err => {
|
||||||
|
if (fail_ci) {
|
||||||
|
core.setFailed(
|
||||||
|
`Codecov failed with the following error: ${err.message}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.warning(`Codecov warning: ${err.message}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
unlinkFile();
|
||||||
|
});
|
||||||
|
|
||||||
|
const unlinkFile = () => {
|
||||||
|
fs.unlink("codecov.sh", err => {
|
||||||
|
if (err && fail_ci) {
|
||||||
|
throw err;
|
||||||
|
} else if (err) {
|
||||||
|
core.warning(`Codecov warning: ${err.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(
|
||||||
|
`Codecov failed with the following error: ${error.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
if (fail_ci) {
|
||||||
|
core.setFailed(`Codecov failed with the following error: ${error.message}`);
|
||||||
|
} else {
|
||||||
|
core.warning(`Codecov warning: ${error.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if ! [ -e .git ]; then
|
||||||
|
echo "Please run this from repo root directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd .git/hooks
|
||||||
|
for i in pre-commit; do
|
||||||
|
rm -fv $i
|
||||||
|
ln -sv ../../hooks/$i
|
||||||
|
done
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
}
|
||||||
Generated
+5040
-213
File diff suppressed because it is too large
Load Diff
+23
-10
@@ -1,26 +1,39 @@
|
|||||||
{
|
{
|
||||||
"name": "test2",
|
"name": "codecov-action",
|
||||||
"version": "1.0.0",
|
"version": "1.1.1",
|
||||||
"description": "[](https://github.com/marketplace/actions/codecov) ### Easily upload coverage reports to Codecov from GitHub Actions",
|
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "jest --coverage",
|
||||||
|
"test-calculator": "jest --testPathPattern=src/calculator/ --coverage --coverageDirectory=coverage/calculator",
|
||||||
|
"test-index": "jest --testPathPattern=src/index --coverage --coverageDirectory=coverage/index",
|
||||||
|
"test-all": "yarn run test && yarn run test-calculator && yarn run test-index",
|
||||||
|
"build": "ncc build index.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/codecov/codecov-action.git"
|
"url": "git+https://github.com/codecov/codecov-action.git"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "Ibrahim Ali",
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/codecov/codecov-action/issues"
|
"url": "https://github.com/codecov/codecov-action/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/codecov/codecov-action#readme",
|
"homepage": "https://github.com/codecov/codecov-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.4",
|
||||||
|
"@types/jest": "^26.0.19",
|
||||||
|
"@zeit/ncc": "^0.22.3",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
"request": "^2.88.0"
|
"jest": "^26.6.3",
|
||||||
}
|
"jest-junit": "^12.0.0",
|
||||||
|
"request": "^2.88.2",
|
||||||
|
"requestretry": "^4.1.2",
|
||||||
|
"ts-jest": "^26.4.4",
|
||||||
|
"typescript": "^4.1.2",
|
||||||
|
"yarn": "^1.22.10"
|
||||||
|
},
|
||||||
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import Calculator from './calculator'
|
||||||
|
|
||||||
|
test('adds 2 + 3 to equal 5', () => {
|
||||||
|
const calc = new Calculator()
|
||||||
|
expect(calc.add(2, 3)).toBe(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtracts 2 - 3 to equal -1', () => {
|
||||||
|
const calc = new Calculator()
|
||||||
|
expect(calc.subtract(2, 3)).toBe(-1);
|
||||||
|
});
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export default class Calculator {
|
||||||
|
|
||||||
|
add(x : number, y : number) : number {
|
||||||
|
return x + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
subtract(x: number, y: number) : number {
|
||||||
|
return x - y;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import Index from "./index";
|
||||||
|
|
||||||
|
test('test uncovered if', () => {
|
||||||
|
const indexObj = new Index();
|
||||||
|
expect(indexObj.uncovered_if()).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fully covered', () => {
|
||||||
|
const indexObj = new Index();
|
||||||
|
expect(indexObj.fully_covered()).toEqual(true);
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export default class Index {
|
||||||
|
|
||||||
|
//This function is tested and part of it is uncovered
|
||||||
|
uncovered_if = (a = true) => {
|
||||||
|
if (a == true) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//This function will be fully covered
|
||||||
|
fully_covered = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
//This function will not be tested by unit tests
|
||||||
|
uncovered = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user