Compare commits
36
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -1,5 +1,5 @@
|
||||
name: Example workflow for Codecov
|
||||
on: [push]
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+5
-2
@@ -76,7 +76,7 @@ typings/
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# react / gatsby
|
||||
# react / gatsby
|
||||
public/
|
||||
|
||||
# vuepress build output
|
||||
@@ -89,4 +89,7 @@ public/
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
.dynamodb/
|
||||
|
||||
# macOS Finder metadata
|
||||
.DS_Store
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# Codecov GitHub Action
|
||||
|
||||
[](https://github.com/marketplace/actions/codecov)
|
||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||
[](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 and Windows builds!
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -18,24 +20,23 @@ steps:
|
||||
file: ./coverage.xml #optional
|
||||
flags: unittests #optional
|
||||
name: codecov-umbrella #optional
|
||||
yml: ./codecov.yml #optional
|
||||
fail_ci_if_error: 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
|
||||
|
||||
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 |
|
||||
| :---: | :---: | :---: |
|
||||
| `token` | Used to authorize coverage report uploads | *Required* |
|
||||
| `file` | Path to the coverage report(s) | Optional
|
||||
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.) | Optional
|
||||
| `name` | Custom defined name for the build | Optional
|
||||
| `yml` | Path to codecov.yml config file | 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
|
||||
|
||||
### Example `workflow.yml` with Codecov Action
|
||||
>**Note**: The latest release of this Action adds support for macOS and Windows builds!
|
||||
|
||||
```yaml
|
||||
name: Example workflow for Codecov
|
||||
@@ -51,7 +52,7 @@ jobs:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@master
|
||||
with:
|
||||
version: 3.7
|
||||
python-version: 3.7
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
pip install pytest
|
||||
@@ -64,7 +65,7 @@ jobs:
|
||||
file: ./coverage.xml
|
||||
flags: unittests
|
||||
name: codecov-umbrella
|
||||
yml: ./codecov.yml
|
||||
fail_ci_if_error: true
|
||||
```
|
||||
## Contributing
|
||||
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ inputs:
|
||||
flags:
|
||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||
required: false
|
||||
yml:
|
||||
description: 'Specify the location of the .codecov.yml config file'
|
||||
fail_ci_if_error:
|
||||
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||
required: false
|
||||
branding:
|
||||
color: 'red'
|
||||
|
||||
Vendored
+78
-33531
File diff suppressed because one or more lines are too long
@@ -3,19 +3,39 @@ const exec = require("@actions/exec");
|
||||
const request = require("request");
|
||||
const fs = require("fs");
|
||||
|
||||
let fail_ci;
|
||||
try {
|
||||
|
||||
const name = core.getInput("name");
|
||||
const token = core.getInput("token");
|
||||
const flags = core.getInput("flags");
|
||||
const file = core.getInput("file");
|
||||
const yml = core.getInput("yml");
|
||||
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||
|
||||
if (
|
||||
fail_ci === "yes" ||
|
||||
fail_ci === "y" ||
|
||||
fail_ci === "true" ||
|
||||
fail_ci === "t" ||
|
||||
fail_ci === "1"
|
||||
) {
|
||||
fail_ci = true;
|
||||
} else {
|
||||
fail_ci = false;
|
||||
}
|
||||
|
||||
request("https://codecov.io/bash", (error, response, body) => {
|
||||
if (error) throw error;
|
||||
if (error && fail_ci) {
|
||||
throw error;
|
||||
} else if (error) {
|
||||
core.warning(`Codecov warning: ${error.message}`);
|
||||
}
|
||||
|
||||
fs.writeFile("codecov.sh", body, err => {
|
||||
if (err) throw err;
|
||||
if (err && fail_ci) {
|
||||
throw err;
|
||||
} else if (err) {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
|
||||
let output = "";
|
||||
let execError = "";
|
||||
@@ -34,39 +54,57 @@ try {
|
||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||
GITHUB_REF: process.env.GITHUB_REF,
|
||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||
GITHUB_SHA: process.env.GITHUB_SHA
|
||||
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || ''
|
||||
};
|
||||
|
||||
const execArgs = ["codecov.sh"];
|
||||
if (file) {
|
||||
exec
|
||||
.exec(
|
||||
"bash",
|
||||
["codecov.sh", "-f", `${file}`, "-n", `${name}`, "-F", `${flags}`, '-y', `${yml}`],
|
||||
options
|
||||
)
|
||||
.then(() => {
|
||||
unlinkFile()
|
||||
});
|
||||
} else {
|
||||
exec
|
||||
.exec(
|
||||
"bash",
|
||||
["codecov.sh", "-n", `${name}`, "-F", `${flags}`, '-y', `${yml}`],
|
||||
options
|
||||
)
|
||||
.then(() => {
|
||||
unlinkFile()
|
||||
});
|
||||
execArgs.push(
|
||||
"-f", `${file}`
|
||||
);
|
||||
}
|
||||
|
||||
execArgs.push(
|
||||
"-n", `${name}`,
|
||||
"-F", `${flags}`
|
||||
);
|
||||
|
||||
if (fail_ci) {
|
||||
execArgs.push(
|
||||
"-Z"
|
||||
);
|
||||
}
|
||||
|
||||
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) throw err;
|
||||
if (err && fail_ci) {
|
||||
throw err;
|
||||
} else if (err) {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
});
|
||||
} 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}`);
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+6
-469
File diff suppressed because it is too large
Load Diff
+6
-4
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "test2",
|
||||
"version": "1.0.0",
|
||||
"description": "[](https://github.com/marketplace/actions/codecov) ### Easily upload coverage reports to Codecov from GitHub Actions",
|
||||
"name": "codecov-action",
|
||||
"version": "1.0.5",
|
||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "ncc build index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -20,6 +21,7 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@zeit/ncc": "^0.20.5",
|
||||
"fs": "0.0.1-security",
|
||||
"request": "^2.88.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user