mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
@@ -37,6 +37,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
|
|||||||
| `token` | Used to authorize coverage report uploads | *Required for private repos* |
|
| `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.). Multiple flags are separated by a comma (ui,chrome) | 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
|
| `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
|
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||||
|
|
||||||
@@ -51,6 +52,9 @@ jobs:
|
|||||||
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
|
||||||
@@ -68,6 +72,7 @@ jobs:
|
|||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
file: ./coverage.xml
|
file: ./coverage.xml
|
||||||
flags: unittests
|
flags: unittests
|
||||||
|
env_vars: OS,PYTHON
|
||||||
name: codecov-umbrella
|
name: codecov-umbrella
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ inputs:
|
|||||||
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
|
||||||
|
env_vars:
|
||||||
|
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
||||||
|
required: false
|
||||||
fail_ci_if_error:
|
fail_ci_if_error:
|
||||||
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||||
required: false
|
required: false
|
||||||
@@ -23,4 +26,3 @@ branding:
|
|||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
||||||
|
|||||||
49432
dist/index.js
vendored
49432
dist/index.js
vendored
File diff suppressed because one or more lines are too long
19
index.js
19
index.js
@@ -9,6 +9,8 @@ try {
|
|||||||
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 env_vars = core.getInput("env_vars");
|
||||||
|
|
||||||
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -62,6 +64,15 @@ try {
|
|||||||
options.env.CODECOV_TOKEN = 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"];
|
const execArgs = ["codecov.sh"];
|
||||||
if (file) {
|
if (file) {
|
||||||
execArgs.push(
|
execArgs.push(
|
||||||
@@ -80,6 +91,12 @@ try {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (env_vars_arg.length) {
|
||||||
|
execArgs.push(
|
||||||
|
"-e", env_vars_arg.join(",")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
exec.exec("bash", execArgs, options)
|
exec.exec("bash", execArgs, options)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (fail_ci) {
|
if (fail_ci) {
|
||||||
@@ -92,7 +109,7 @@ try {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
unlinkFile();
|
unlinkFile();
|
||||||
});;
|
});
|
||||||
|
|
||||||
const unlinkFile = () => {
|
const unlinkFile = () => {
|
||||||
fs.unlink("codecov.sh", err => {
|
fs.unlink("codecov.sh", err => {
|
||||||
|
|||||||
Reference in New Issue
Block a user