mirror of
https://github.com/codecov/codecov-action.git
synced 2026-03-28 17:05:07 +00:00
Compare commits
9 Commits
add-fail-i
...
branch-sup
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49c86d6a5f | ||
|
|
6ec347819d | ||
|
|
44ca3d2c84 | ||
|
|
66879ff350 | ||
|
|
797e92895e | ||
|
|
a6337803aa | ||
|
|
2613f978c9 | ||
|
|
4c6a7296af | ||
|
|
4fec3dfa96 |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -1,5 +1,5 @@
|
|||||||
name: Example workflow for Codecov
|
name: Example workflow for Codecov
|
||||||
on: [push]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
@@ -1,19 +0,0 @@
|
|||||||
on: create
|
|
||||||
|
|
||||||
name: Release
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
name: Release Codecov GitHub Action
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
with:
|
|
||||||
fetch-depth: 3
|
|
||||||
- name: Release Action
|
|
||||||
uses: technote-space/release-github-actions@v1
|
|
||||||
with:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
CREATE_MINOR_VERSION_TAG: false
|
|
||||||
COMMIT_NAME: Release GitHub Action
|
|
||||||
BRANCH_NAME: master
|
|
||||||
11
README.md
11
README.md
@@ -1,13 +1,13 @@
|
|||||||
# 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
|
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||||
|
|
||||||
>The latest release of this Action adds support for macOS and Windows builds!
|
>The latest release of this Action adds support for macOS and Windows builds!
|
||||||
|
|
||||||
## 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 five additional inputs to customize the upload context.
|
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.
|
||||||
|
|
||||||
Inside your `.github/workflows/workflow.yml` file:
|
Inside your `.github/workflows/workflow.yml` file:
|
||||||
|
|
||||||
@@ -20,14 +20,13 @@ steps:
|
|||||||
file: ./coverage.xml #optional
|
file: ./coverage.xml #optional
|
||||||
flags: unittests #optional
|
flags: unittests #optional
|
||||||
name: codecov-umbrella #optional
|
name: codecov-umbrella #optional
|
||||||
yml: ./codecov.yml #optional
|
|
||||||
fail_ci_if_error: true #optional (default = false)
|
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
|
## Arguments
|
||||||
|
|
||||||
Codecov's Action currently supports five inputs from the user: `token`, `file`, `flags`,`name`, `yml`, and `fail_ci_if_error`. 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 |
|
||||||
| :---: | :---: | :---: |
|
| :---: | :---: | :---: |
|
||||||
@@ -35,7 +34,6 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
|
|||||||
| `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
|
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.) | Optional
|
||||||
| `name` | Custom defined name for the upload | Optional
|
| `name` | Custom defined name for the upload | Optional
|
||||||
| `yml` | Path to codecov.yml config file | 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
|
### Example `workflow.yml` with Codecov Action
|
||||||
@@ -67,7 +65,6 @@ jobs:
|
|||||||
file: ./coverage.xml
|
file: ./coverage.xml
|
||||||
flags: unittests
|
flags: unittests
|
||||||
name: codecov-umbrella
|
name: codecov-umbrella
|
||||||
yml: ./codecov.yml
|
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
```
|
```
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ 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
|
||||||
yml:
|
|
||||||
description: 'Specify the location of the .codecov.yml config file'
|
|
||||||
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
|
||||||
|
|||||||
33641
dist/index.js
vendored
33641
dist/index.js
vendored
File diff suppressed because one or more lines are too long
122
index.js
122
index.js
@@ -9,7 +9,6 @@ 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 yml = core.getInput("yml");
|
|
||||||
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -55,101 +54,42 @@ try {
|
|||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
GITHUB_REF: process.env.GITHUB_REF,
|
GITHUB_REF: process.env.GITHUB_REF,
|
||||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
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) {
|
if (file) {
|
||||||
if (fail_ci) {
|
execArgs.push(
|
||||||
exec
|
"-f", `${file}`
|
||||||
.exec(
|
);
|
||||||
"bash",
|
|
||||||
[
|
|
||||||
"codecov.sh",
|
|
||||||
"-f",
|
|
||||||
`${file}`,
|
|
||||||
"-n",
|
|
||||||
`${name}`,
|
|
||||||
"-F",
|
|
||||||
`${flags}`,
|
|
||||||
"-y",
|
|
||||||
`${yml}`,
|
|
||||||
"-Z"
|
|
||||||
],
|
|
||||||
options
|
|
||||||
)
|
|
||||||
.catch(err => {
|
|
||||||
core.setFailed(
|
|
||||||
`Codecov failed with the following error: ${err.message}`
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
unlinkFile();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
exec
|
|
||||||
.exec(
|
|
||||||
"bash",
|
|
||||||
[
|
|
||||||
"codecov.sh",
|
|
||||||
"-f",
|
|
||||||
`${file}`,
|
|
||||||
"-n",
|
|
||||||
`${name}`,
|
|
||||||
"-F",
|
|
||||||
`${flags}`,
|
|
||||||
"-y",
|
|
||||||
`${yml}`
|
|
||||||
],
|
|
||||||
options
|
|
||||||
)
|
|
||||||
.catch(err => {
|
|
||||||
core.warning(`Codecov warning: ${err.message}`);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
unlinkFile();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (fail_ci) {
|
|
||||||
exec
|
|
||||||
.exec(
|
|
||||||
"bash",
|
|
||||||
[
|
|
||||||
"codecov.sh",
|
|
||||||
"-n",
|
|
||||||
`${name}`,
|
|
||||||
"-F",
|
|
||||||
`${flags}`,
|
|
||||||
"-y",
|
|
||||||
`${yml}`,
|
|
||||||
"-Z"
|
|
||||||
],
|
|
||||||
options
|
|
||||||
)
|
|
||||||
.catch(err => {
|
|
||||||
core.setFailed(
|
|
||||||
`Codecov failed with the following error: ${err.message}`
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
unlinkFile();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
exec
|
|
||||||
.exec(
|
|
||||||
"bash",
|
|
||||||
["codecov.sh", "-n", `${name}`, "-F", `${flags}`, "-y", `${yml}`],
|
|
||||||
options
|
|
||||||
)
|
|
||||||
.catch(err => {
|
|
||||||
core.warning(`Codecov warning: ${err.message}`);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
unlinkFile();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = () => {
|
const unlinkFile = () => {
|
||||||
fs.unlink("codecov.sh", err => {
|
fs.unlink("codecov.sh", err => {
|
||||||
if (err && fail_ci) {
|
if (err && fail_ci) {
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "test2",
|
"name": "codecov-action",
|
||||||
"version": "1.0.0",
|
"version": "1.0.5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user