mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22f6ff10ac | ||
|
|
0ceca4b5d3 | ||
|
|
3658bafacb | ||
|
|
ef3b48314f | ||
|
|
dbf1ddee08 | ||
|
|
cc6b0c11d2 | ||
|
|
f532c3a145 | ||
|
|
143333ba90 | ||
|
|
a50851cfd8 | ||
|
|
6914527afb | ||
|
|
fff75f1901 | ||
|
|
1804a456ff | ||
|
|
d1b4c72fc5 | ||
|
|
6fd09f835d | ||
|
|
e866b3854d | ||
|
|
608816e426 | ||
|
|
2ce3b3807d | ||
|
|
0e6a911c9b | ||
|
|
d04135f7cf | ||
|
|
7938e79f4c | ||
|
|
a3a6becb2c | ||
|
|
bf0e754c09 | ||
|
|
daa5098552 | ||
|
|
71d5dea6af |
18
.github/workflows/main.yml
vendored
18
.github/workflows/main.yml
vendored
@@ -4,11 +4,13 @@ jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Upload coverage to Codecov
|
||||
uses: ./
|
||||
with:
|
||||
#commenting out token because tokenless uploads are now supported
|
||||
#token: ${{secrets.CODECOV_TOKEN}}
|
||||
flags: unittest
|
||||
name: codecov-1
|
||||
- uses: actions/checkout@master
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Upload coverage to Codecov
|
||||
uses: ./
|
||||
with:
|
||||
#commenting out token because tokenless uploads are now supported
|
||||
#token: ${{secrets.CODECOV_TOKEN}}
|
||||
flags: unittest
|
||||
name: codecov-1
|
||||
|
||||
13
README.md
13
README.md
@@ -3,7 +3,7 @@
|
||||
[](https://github.com/marketplace/actions/codecov)
|
||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||
|
||||
>The latest release of this Action adds support for macOS + Windows builds and tokenless uploads for public repos!
|
||||
>The latest release of this Action adds support for tokenless uploads from GitHub Actions!
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -30,15 +30,16 @@ steps:
|
||||
|
||||
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:
|
||||
|
||||
>**Update**: We've removed the `yml` paramter with the latest release of this action. Please put your custom codecov yaml file at the root of the repo because other locations will no longer be supported in the future.
|
||||
>**Update**: We've removed the `yml` parameter with the latest release of this action. Please put your custom codecov yaml file at the root of the repo because other locations will no longer be supported in the future.
|
||||
|
||||
| Input | Description | Usage |
|
||||
| :---: | :---: | :---: |
|
||||
| `token` | Used to authorize coverage report uploads | *Required for private repos* |
|
||||
| `file` | Path to the coverage report(s) | Optional
|
||||
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.) | 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
|
||||
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||
|
||||
### Example `workflow.yml` with Codecov Action
|
||||
|
||||
@@ -51,6 +52,9 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
PYTHON: '3.7'
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Setup Python
|
||||
@@ -68,6 +72,7 @@ jobs:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./coverage.xml
|
||||
flags: unittests
|
||||
env_vars: OS,PYTHON
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: true
|
||||
```
|
||||
|
||||
@@ -14,6 +14,9 @@ inputs:
|
||||
flags:
|
||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||
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
|
||||
@@ -23,4 +26,3 @@ branding:
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
|
||||
49418
dist/index.js
vendored
49418
dist/index.js
vendored
File diff suppressed because one or more lines are too long
33
index.js
33
index.js
@@ -1,7 +1,9 @@
|
||||
const core = require("@actions/core");
|
||||
const exec = require("@actions/exec");
|
||||
const request = require("request");
|
||||
const fs = require("fs");
|
||||
const request = require('retry-request', {
|
||||
request: require('request')
|
||||
});
|
||||
|
||||
let fail_ci;
|
||||
try {
|
||||
@@ -9,6 +11,8 @@ try {
|
||||
const token = core.getInput("token");
|
||||
const flags = core.getInput("flags");
|
||||
const file = core.getInput("file");
|
||||
const env_vars = core.getInput("env_vars");
|
||||
|
||||
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||
|
||||
if (
|
||||
@@ -23,7 +27,11 @@ try {
|
||||
fail_ci = false;
|
||||
}
|
||||
|
||||
request("https://codecov.io/bash", (error, response, body) => {
|
||||
const retryOpts = {
|
||||
retries: 3
|
||||
};
|
||||
|
||||
request("https://codecov.io/bash", retryOpts, (error, response, body) => {
|
||||
if (error && fail_ci) {
|
||||
throw error;
|
||||
} else if (error) {
|
||||
@@ -49,19 +57,28 @@ try {
|
||||
}
|
||||
};
|
||||
|
||||
options.env = {
|
||||
options.env = Object.assign(process.env, {
|
||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||
GITHUB_REF: process.env.GITHUB_REF,
|
||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || ''
|
||||
};
|
||||
});
|
||||
|
||||
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"];
|
||||
if (file) {
|
||||
execArgs.push(
|
||||
@@ -80,6 +97,12 @@ try {
|
||||
);
|
||||
}
|
||||
|
||||
if (env_vars_arg.length) {
|
||||
execArgs.push(
|
||||
"-e", env_vars_arg.join(",")
|
||||
);
|
||||
}
|
||||
|
||||
exec.exec("bash", execArgs, options)
|
||||
.catch(err => {
|
||||
if (fail_ci) {
|
||||
@@ -92,7 +115,7 @@ try {
|
||||
})
|
||||
.then(() => {
|
||||
unlinkFile();
|
||||
});;
|
||||
});
|
||||
|
||||
const unlinkFile = () => {
|
||||
fs.unlink("codecov.sh", err => {
|
||||
|
||||
59
package-lock.json
generated
59
package-lock.json
generated
@@ -92,6 +92,14 @@
|
||||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@@ -178,6 +186,11 @@
|
||||
"sshpk": "^1.7.0"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"is-typedarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||
@@ -232,6 +245,11 @@
|
||||
"mime-db": "1.42.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
|
||||
@@ -257,6 +275,16 @@
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
|
||||
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
|
||||
"requires": {
|
||||
"inherits": "^2.0.3",
|
||||
"string_decoder": "^1.1.1",
|
||||
"util-deprecate": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"request": {
|
||||
"version": "2.88.0",
|
||||
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
|
||||
@@ -284,6 +312,15 @@
|
||||
"uuid": "^3.3.2"
|
||||
}
|
||||
},
|
||||
"retry-request": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/retry-request/-/retry-request-4.1.1.tgz",
|
||||
"integrity": "sha512-BINDzVtLI2BDukjWmjAIRZ0oglnCAkpP2vQjM3jdLhmT62h0xnQgciPwBRDAvHqpkPT2Wo1XuUyLyn6nbGrZQQ==",
|
||||
"requires": {
|
||||
"debug": "^4.1.1",
|
||||
"through2": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
|
||||
@@ -310,6 +347,23 @@
|
||||
"tweetnacl": "~0.14.0"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
||||
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.2.0"
|
||||
}
|
||||
},
|
||||
"through2": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz",
|
||||
"integrity": "sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==",
|
||||
"requires": {
|
||||
"inherits": "^2.0.4",
|
||||
"readable-stream": "2 || 3"
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
|
||||
@@ -347,6 +401,11 @@
|
||||
"punycode": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codecov-action",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.9",
|
||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -23,7 +23,8 @@
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@zeit/ncc": "^0.20.5",
|
||||
"fs": "0.0.1-security",
|
||||
"request": "^2.88.0"
|
||||
"request": "^2.88.0",
|
||||
"retry-request": "^4.1.1"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user