mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
283 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ed0d16b40 | ||
|
|
79a0ba12c8 | ||
|
|
1f8f3abccc | ||
|
|
763298c6f6 | ||
|
|
3207ad4e60 | ||
|
|
ab3cfafc5b | ||
|
|
b708b7e81f | ||
|
|
65f43cece2 | ||
|
|
21a1e2948d | ||
|
|
227f879cd0 | ||
|
|
87fff2e891 | ||
|
|
50212c96c8 | ||
|
|
e77dab65bf | ||
|
|
ddfe212d72 | ||
|
|
71a6279758 | ||
|
|
6a50e6841d | ||
|
|
482a90585e | ||
|
|
b977d6544b | ||
|
|
4c6543136b | ||
|
|
28d300eaea | ||
|
|
36360aa09d | ||
|
|
f215202b84 | ||
|
|
7cd1dd7eac | ||
|
|
98c0755768 | ||
|
|
9347908382 | ||
|
|
ae688b209d | ||
|
|
d7eb181d2f | ||
|
|
a231e699a2 | ||
|
|
29fb46218a | ||
|
|
ad2aaf2f71 | ||
|
|
ca774cf8f0 | ||
|
|
44d1ae6c73 | ||
|
|
ed0e49eac0 | ||
|
|
ed1a046a3f | ||
|
|
16636eb6e0 | ||
|
|
b3274555d8 | ||
|
|
53f9cbed3c | ||
|
|
14434e0c72 | ||
|
|
2838b54ec2 | ||
|
|
33faa01b4d | ||
|
|
ebab471b65 | ||
|
|
1789bbabef | ||
|
|
eedcbd59dc | ||
|
|
83e6a29c16 | ||
|
|
dd9b809996 | ||
|
|
61b20ce181 | ||
|
|
e156083f13 | ||
|
|
e9131c5f9c | ||
|
|
a92c414703 | ||
|
|
8d13d6a7ba | ||
|
|
1acc162055 | ||
|
|
6961e2c698 | ||
|
|
431265badf | ||
|
|
5dca80cf76 | ||
|
|
4dcb7122e5 | ||
|
|
be4e2a5e02 | ||
|
|
40b489d797 | ||
|
|
853e99ac9d | ||
|
|
1794277aa5 | ||
|
|
27a4acecbb | ||
|
|
0ad87e5850 | ||
|
|
25cb7e3abf | ||
|
|
a0e7a095bd | ||
|
|
2e67f32735 | ||
|
|
7a024964de | ||
|
|
e16afe2276 | ||
|
|
c0466185ef | ||
|
|
56353bc0f0 | ||
|
|
d9d5217980 | ||
|
|
8ad88ccc68 | ||
|
|
6a4eded237 | ||
|
|
25b873867a | ||
|
|
8323165032 | ||
|
|
5b42a305f9 | ||
|
|
29c457e537 | ||
|
|
b3ee0b08ef | ||
|
|
133f89a6b7 | ||
|
|
a03d57cdbd | ||
|
|
1fc7722ded | ||
|
|
08574d831c | ||
|
|
0c1af46295 | ||
|
|
f8c87eb84e | ||
|
|
8b988c28b0 | ||
|
|
4686d7034c | ||
|
|
4ef30f27a0 | ||
|
|
58cd650984 | ||
|
|
efb844969e | ||
|
|
c6de3f8548 | ||
|
|
7de43a7373 | ||
|
|
d3e4a774c5 | ||
|
|
09facdbe25 | ||
|
|
c770ad46b3 | ||
|
|
55dde41e2b | ||
|
|
11de6e2a71 | ||
|
|
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 | ||
|
|
e6cea4aaed | ||
|
|
70f2402e00 | ||
|
|
e6af53269a | ||
|
|
7ab923356b | ||
|
|
8676a5a946 | ||
|
|
6afe2e0d90 | ||
|
|
67a2282699 | ||
|
|
e1a57b8a47 | ||
|
|
1be0517b99 | ||
|
|
889584d6f9 | ||
|
|
c4ca0425e1 | ||
|
|
8d062b28e1 | ||
|
|
a3ae14ab33 | ||
|
|
1259587051 | ||
|
|
dd61d9f90b | ||
|
|
6e83ad2f33 | ||
|
|
747c905e39 | ||
|
|
29e36a5e71 | ||
|
|
f0ee262b3a | ||
|
|
bab0bf56a8 | ||
|
|
efc5cbe89b | ||
|
|
3d61f3d4c8 | ||
|
|
db0171f588 | ||
|
|
7ba41fc0d6 |
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"commonjs": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": [
|
||||
"google"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
42
.github/workflows/main.yml
vendored
42
.github/workflows/main.yml
vendored
@@ -1,23 +1,27 @@
|
||||
name: Example workflow for Codecov
|
||||
on: [push]
|
||||
name: Workflow for Codecov Action
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
# - name: Setup Python
|
||||
# uses: actions/setup-python@master
|
||||
|
||||
# - name: Generate coverage report
|
||||
# run: |
|
||||
# pip install pytest
|
||||
# pip install pytest-cov
|
||||
# pytest --cov=./ --cov-report=xml
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: ./
|
||||
with:
|
||||
token: ${{secrets.CODECOV_TOKEN}}
|
||||
flags: unittest
|
||||
name: codecov-1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
- name: Run tests and collect coverage
|
||||
run: yarn run test
|
||||
- name: Upload coverage to Codecov (demo)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||
file: ./coverage/coverage-final.json
|
||||
flags: demo
|
||||
name: codecov-demo
|
||||
- name: Upload coverage to Codecov (script)
|
||||
uses: ./
|
||||
with:
|
||||
files: ./coverage/script/coverage-final.json
|
||||
flags: script
|
||||
name: codecov-script
|
||||
|
||||
95
.gitignore
vendored
Normal file
95
.gitignore
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# react / gatsby
|
||||
public/
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# macOS Finder metadata
|
||||
.DS_Store
|
||||
43
CHANGELOG.md
Normal file
43
CHANGELOG.md
Normal file
@@ -0,0 +1,43 @@
|
||||
### 1.3.0
|
||||
|
||||
#### Features
|
||||
- #252 Add "network_filter" input
|
||||
|
||||
### 1.2.2
|
||||
|
||||
#### Fixes
|
||||
- #241 pass root_dir using proper bash arg
|
||||
- #244 Overwrite the commit on pull_request* events
|
||||
|
||||
### 1.2.1
|
||||
|
||||
#### Fixes
|
||||
- #196 Add parameters to the action.yml
|
||||
|
||||
### 1.2.0
|
||||
|
||||
#### Features
|
||||
- #193 Add all the bash params
|
||||
|
||||
#### Fixes
|
||||
- #193 Fixes issue with working-directory
|
||||
|
||||
### 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
|
||||
@@ -6,8 +6,8 @@ The following is a set of guidelines for contributing to this repository, which
|
||||
|
||||
## What does this repo do?
|
||||
|
||||
This repo is a GitHub Action, meaning it integrates with the GitHub Actions CI/CD pipeline. It's meant to take formatted reports with code coverage stats and upload them to codecov.io. What's essentially happening in the background is that Actions is spinning up a Linux Docker container with the contents of this repository. Inside that container, we then call a shell scipt that runs Codecov's Bash uploader.
|
||||
This repo is a GitHub Action, meaning it integrates with the GitHub Actions CI/CD pipeline. It's meant to take formatted reports with code coverage stats and upload them to codecov.io. Our Node action uses the Actions toolkit to make system calls that allow us to run Codecov's bash uploader inside of Node. Essentially what we're doing in this action is downloading Codecov's bash uploader script from codecov.io/bash, saving it as a file in the current directory, executing the file via `exec` calls, then removing the script from the current directory.
|
||||
|
||||
## PRs and Support
|
||||
## PRs, Issues, and Support
|
||||
|
||||
Feel free to clone, modify code and request a PR to this repository. All PRs will be reviewed by the Codecov team. If your PR has been sitting for a while or if you have any questions, ping us at support@codecov.io
|
||||
Feel free to clone, modify code and request a PR to this repository. All PRs and issues will be reviewed by the Codecov team. If your PR/issue has been sitting for a while or if you have any questions, ping us at support@codecov.io
|
||||
|
||||
15
Dockerfile
15
Dockerfile
@@ -1,15 +0,0 @@
|
||||
# Codecov @codecov
|
||||
|
||||
FROM debian:stretch-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
curl \
|
||||
git \
|
||||
mercurial \
|
||||
--no-install-recommends && rm -r /var/lib/apt/lists/*
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Codecov
|
||||
Copyright (c) 2019-2020 Codecov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
deploy:
|
||||
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
||||
git tag -d v1
|
||||
git push origin :v1
|
||||
git tag v1
|
||||
git tag v$(VERSION) -m ""
|
||||
git push origin --tags
|
||||
90
README.md
90
README.md
@@ -1,36 +1,78 @@
|
||||
# Codecov GitHub Action
|
||||
|
||||
[](https://github.com/marketplace/actions/codecov)
|
||||
[](https://github.com/marketplace/actions/codecov)
|
||||
[](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
|
||||
|
||||
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 three 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:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: codecov/codecov-action@v1.0.3
|
||||
- uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{secrets.CODECOV_TOKEN}} #required
|
||||
file: ./coverage.xml #optional
|
||||
flags: unittests #optional
|
||||
name: codecov-umbrella #optional
|
||||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
|
||||
files: ./coverage1.xml,./coverage2.xml # optional
|
||||
flags: unittests # 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
|
||||
|
||||
Codecov's Action currently supports four inputs from the user: `token`, `file`, `flags`, and `name`. 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` | Location of the coverage report | Optional
|
||||
| `flags` | Flag upload under a certain group | Optional
|
||||
| `token` | Used to authorize coverage report uploads | *Required for private repos* |
|
||||
| `files` | Comma-separated paths to the coverage report(s) | Optional
|
||||
| `directory` | Directory to search for coverage reports. | Optional
|
||||
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | Optional
|
||||
| | |
|
||||
| `aws_curl_args` | Extra curl arguments to communicate with AWS. | Optional
|
||||
| `codecov_curl_args` | Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy" | Optional
|
||||
| `commit_parent` | The commit SHA of the parent for which you are uploading coverage. If not present, the parent will be determined using the API of your repository provider. When using the repository provider's API, the parent is determined via finding the closest ancestor to the commit. | Optional
|
||||
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
|
||||
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||
| `functionalities` | Toggle functionalities | Optional
|
||||
| | `coveragepy` Disable python coverage |
|
||||
| | `fix` Disable report fixing |
|
||||
| | `gcov` Disable gcov |
|
||||
| | `gcovout` Disable gcov output |
|
||||
| | `html` Enable coverage for HTML files |
|
||||
| | `network` Disable uploading the file network |
|
||||
| | `recursesubs` Enable recurse submodules in git projects when searching for source files | |
|
||||
| | `search` Disable searching for reports |
|
||||
| | `xcode` Disable xcode processing |
|
||||
| `gcov_path_include` | Paths to include during gcov gathering (as a glob) | Optional
|
||||
| `gcov_args` | extra arguments to pass to gcov | Optional
|
||||
| `gcov_executable` | gcov executable to run. Defaults to 'gcov' | Optional
|
||||
| `gcov_path_exclude` | Paths to ignore during gcov gathering (as a glob) | Optional
|
||||
| `gcov_prefix` | Prefix filepaths to help resolve path fixing | Optional
|
||||
| `gcov_root_dir` | Project root directory, also used when preparing gcov | Optional
|
||||
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
|
||||
| `name` | Custom defined name for the upload | Optional
|
||||
| `override_branch` | Specify the branch name | Optional
|
||||
| `override_build` | Specify the build number | Optional
|
||||
| `override_commit` | Specify the commit SHA | Optional
|
||||
| `override_pr` | Specify the pull request number | Optional
|
||||
| `override_tag` | Specify the git tag | Optional
|
||||
| `path_to_write_report` | Write upload file to path before uploading | Optional
|
||||
| `root_dir` | Used when not in git/hg project to identify project root directory | 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
|
||||
|
||||
@@ -39,25 +81,36 @@ name: Example workflow for Codecov
|
||||
on: [push]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
PYTHON: '3.7'
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@master
|
||||
with:
|
||||
version: 3.7
|
||||
python-version: 3.7
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
pip install pytest
|
||||
pip install pytest-cov
|
||||
pytest --cov=./ --cov-report=xml
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1.0.3
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{secrets.CODECOV_TOKEN}}
|
||||
file: ./coverage.xml
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage1.xml,./coverage2.xml
|
||||
directory: ./coverage/reports/
|
||||
flags: unittests
|
||||
env_vars: OS,PYTHON
|
||||
name: codecov-umbrella
|
||||
fail_ci_if_error: true
|
||||
path_to_write_report: ./coverage/codecov_report.txt
|
||||
verbose: true
|
||||
```
|
||||
## Contributing
|
||||
|
||||
@@ -66,3 +119,6 @@ Contributions are welcome! Check out the [Contribution Guide](CONTRIBUTING.md).
|
||||
## 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)
|
||||
|
||||
104
action.yml
104
action.yml
@@ -1,28 +1,100 @@
|
||||
name: 'Codecov'
|
||||
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:
|
||||
name:
|
||||
description: 'User defined upload name. Visible in Codecov UI'
|
||||
required: false
|
||||
token:
|
||||
description: 'Repository upload token - get it from codecov.io'
|
||||
required: true
|
||||
file:
|
||||
description: 'Path to coverage file to upload'
|
||||
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
||||
required: false
|
||||
files:
|
||||
description: 'Comma-separated list of files to upload'
|
||||
required: false
|
||||
directory:
|
||||
description: 'Directory to search for coverage reports.'
|
||||
required: false
|
||||
flags:
|
||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||
required: false
|
||||
aws_curl_args:
|
||||
description: 'Extra curl arguments to communicate with AWS.'
|
||||
required: false
|
||||
codecov_curl_args:
|
||||
description: 'Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy"'
|
||||
required: false
|
||||
commit_parent:
|
||||
description: 'The commit SHA of the parent for which you are uploading coverage. If not present, the parent will be determined using the API of your repository provider. When using the repository providers API, the parent is determined via finding the closest ancestor to the commit.'
|
||||
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
|
||||
file:
|
||||
description: 'Path to coverage file to upload'
|
||||
required: false
|
||||
functionalities:
|
||||
description: 'Comma-separated list, see the README for options and their usage'
|
||||
required: false
|
||||
gcov_args:
|
||||
description: 'extra arguments to pass to gcov'
|
||||
required: false
|
||||
gcov_executable:
|
||||
description: 'gcov executable to run. Defaults to gcov'
|
||||
required: false
|
||||
gcov_path_exclude:
|
||||
description: 'Paths to ignore during gcov gathering (as a glob)'
|
||||
required: false
|
||||
gcov_path_include:
|
||||
description: 'Paths to include during gcov gathering (as a glob)'
|
||||
required: false
|
||||
gcov_prefix:
|
||||
description: 'Prefix filepaths to help resolve path fixing'
|
||||
required: false
|
||||
gcov_root_dir:
|
||||
description: 'Project root directory, also used when preparing gcov'
|
||||
required: false
|
||||
move_coverage_to_trash:
|
||||
description: 'Move discovered coverage reports to the trash'
|
||||
required: false
|
||||
name:
|
||||
description: 'User defined upload name. Visible in Codecov UI'
|
||||
required: false
|
||||
override_branch:
|
||||
description: 'Specify the branch name'
|
||||
required: false
|
||||
override_build:
|
||||
description: 'Specify the build number'
|
||||
required: false
|
||||
override_commit:
|
||||
description: 'Specify the commit SHA'
|
||||
required: false
|
||||
override_pr:
|
||||
description: 'Specify the pull request number'
|
||||
required: false
|
||||
override_tag:
|
||||
description: 'Specify the git tag'
|
||||
required: false
|
||||
path_to_write_report:
|
||||
description: 'Write upload file to path before uploading'
|
||||
required: false
|
||||
root_dir:
|
||||
description: 'Used when not in git/hg project to identify project root directory'
|
||||
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
|
||||
xcode_derived_data:
|
||||
description: 'Custom Derived Data Path for Coverage.profdata and gcov processing'
|
||||
required: false
|
||||
xcode_package:
|
||||
description: 'Specify packages to build coverage. Uploader will only build these packages'
|
||||
required: false
|
||||
branding:
|
||||
color: 'red'
|
||||
icon: 'umbrella'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.name }}
|
||||
- ${{ inputs.token }}
|
||||
- ${{ inputs.file }}
|
||||
- ${{ inputs.flags }}
|
||||
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
11
demo/calculator/calculator.test.ts
Normal file
11
demo/calculator/calculator.test.ts
Normal file
@@ -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);
|
||||
});
|
||||
10
demo/calculator/calculator.ts
Normal file
10
demo/calculator/calculator.ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
11
demo/coverage-test/coverage.test.ts
Normal file
11
demo/coverage-test/coverage.test.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import Coverage from "./coverage";
|
||||
|
||||
test('test uncovered if', () => {
|
||||
const coverageObj = new Coverage();
|
||||
expect(coverageObj.uncovered_if()).toEqual(false);
|
||||
});
|
||||
|
||||
test('fully covered', () => {
|
||||
const coverageObj = new Coverage();
|
||||
expect(coverageObj.fully_covered()).toEqual(true);
|
||||
});
|
||||
21
demo/coverage-test/coverage.ts
Normal file
21
demo/coverage-test/coverage.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export default class Coverage {
|
||||
|
||||
//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
|
||||
}
|
||||
}
|
||||
60482
dist/index.js
vendored
Normal file
60482
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Codecov @codecov
|
||||
|
||||
set -eu
|
||||
|
||||
if [ "x$INPUT_FILE" != 'x' ]; then
|
||||
curl -s https://codecov.io/bash | bash -s -- \
|
||||
-f "$INPUT_FILE" \
|
||||
-t "$INPUT_TOKEN" \
|
||||
-n "$INPUT_NAME" \
|
||||
-F "$INPUT_FLAGS" \
|
||||
-Z || echo 'Codecov upload failed'
|
||||
else
|
||||
curl -s https://codecov.io/bash | bash -s -- \
|
||||
-t "$INPUT_TOKEN" \
|
||||
-n "$INPUT_NAME" \
|
||||
-F "$INPUT_FLAGS" \
|
||||
-Z || echo 'Codecov upload failed'
|
||||
fi
|
||||
8
hooks/pre-commit
Executable file
8
hooks/pre-commit
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
npm i --package-lock-only
|
||||
npm run lint --fix
|
||||
npm run build
|
||||
git add src/
|
||||
git add dist/index.js
|
||||
git add package-lock.json
|
||||
12
install.sh
Executable file
12
install.sh
Executable file
@@ -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
|
||||
4
jest.config.js
Normal file
4
jest.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
}
|
||||
6634
package-lock.json
generated
Normal file
6634
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
package.json
Normal file
46
package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "codecov-action",
|
||||
"version": "1.3.0",
|
||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint src/*.*",
|
||||
"test": "yarn run test-script && yarn run test-calculator && yarn run test-coverage",
|
||||
"test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator",
|
||||
"test-coverage": "jest --testPathPattern=demo/coverage-test/ --coverage --coverageDirectory=coverage/coverage-test",
|
||||
"test-script": "jest --testPathPattern=src/ --coverage --coverageDirectory=coverage/script",
|
||||
"build": "ncc build src/index.ts"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/codecov/codecov-action.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Ibrahim Ali",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/codecov/codecov-action/issues"
|
||||
},
|
||||
"homepage": "https://github.com/codecov/codecov-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"fs": "0.0.1-security",
|
||||
"jest": "^26.6.3",
|
||||
"jest-junit": "^12.0.0",
|
||||
"request": "^2.88.2",
|
||||
"requestretry": "^5.0.0",
|
||||
"ts-jest": "^26.5.3",
|
||||
"typescript": "^4.2.3",
|
||||
"yarn": "^1.22.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
||||
"@typescript-eslint/parser": "^4.16.1",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-config-google": "^0.14.0"
|
||||
}
|
||||
}
|
||||
148
src/buildExec.test.ts
Normal file
148
src/buildExec.test.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
import buildExec from './buildExec';
|
||||
const github = require('@actions/github');
|
||||
const context = github.context;
|
||||
|
||||
test('no arguments', () => {
|
||||
const {execArgs, filepath, failCi} = buildExec();
|
||||
|
||||
const args = [
|
||||
'codecov.sh',
|
||||
'-n',
|
||||
'',
|
||||
'-F',
|
||||
'',
|
||||
'-Q',
|
||||
'github-action',
|
||||
];
|
||||
if (context.eventName == 'pull_request') {
|
||||
args.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||
}
|
||||
expect(execArgs).toEqual(args);
|
||||
expect(filepath).toEqual('codecov.sh');
|
||||
expect(failCi).toBeFalsy();
|
||||
});
|
||||
|
||||
test('all arguments', () => {
|
||||
const envs = {
|
||||
'move_coverage_to_trash': 'true',
|
||||
'commit_parent': '83231650328f11695dfb754ca0f540516f188d27',
|
||||
'aws_curl_args': '--timeout 1',
|
||||
'codecov_curl_args': '--timeout 2',
|
||||
'env_vars': 'OS,PYTHON',
|
||||
'fail_ci_if_error': 'true',
|
||||
'file': 'coverage.xml',
|
||||
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
||||
'flags': 'test',
|
||||
'functionalities':
|
||||
'gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs',
|
||||
'gcov_args': '--timeout 3',
|
||||
'gcov_root_dr': 'gcov_dir/',
|
||||
'gcov_path_exclude': '**/exclude-dir/*.*',
|
||||
'gcov_executable': 'gcov',
|
||||
'gcov_path_include': '**/include-dir/*.*',
|
||||
'gcov_prefix': 'demo',
|
||||
'name': 'codecov',
|
||||
'network_filter': 'dir1',
|
||||
'override_branch': 'thomasrockhu/test',
|
||||
'override_build': '1',
|
||||
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||
'override_pr': '2',
|
||||
'override_tag': 'v1.2',
|
||||
'root_dir': 'root/',
|
||||
'directory': 'coverage/',
|
||||
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||
'verbose': 't',
|
||||
'working-directory': 'src',
|
||||
'path_to_write_report': 'codecov/',
|
||||
'xcode_derived_data': '~/Library/Developer/Xcode/DerivedData',
|
||||
'xcode_package': 'MyApp',
|
||||
};
|
||||
|
||||
for (const env of Object.keys(envs)) {
|
||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||
}
|
||||
|
||||
const {execArgs, filepath, failCi} = buildExec();
|
||||
expect(execArgs).toEqual([
|
||||
'src/codecov.sh',
|
||||
'-n',
|
||||
'codecov',
|
||||
'-F',
|
||||
'test',
|
||||
'-Q',
|
||||
'github-action',
|
||||
'-c',
|
||||
'-N',
|
||||
'83231650328f11695dfb754ca0f540516f188d27',
|
||||
'-A',
|
||||
'--timeout 1',
|
||||
'-U',
|
||||
'--timeout 2',
|
||||
'-e',
|
||||
'OS,PYTHON',
|
||||
'-Z',
|
||||
'-f',
|
||||
'coverage.xml',
|
||||
'-f',
|
||||
'dir1/coverage.xml',
|
||||
'-f',
|
||||
'dir2/coverage.xml',
|
||||
'-X',
|
||||
'gcov',
|
||||
'-X',
|
||||
'coveragepy',
|
||||
'-X',
|
||||
'fix',
|
||||
'-X',
|
||||
'search',
|
||||
'-X',
|
||||
'code',
|
||||
'-X',
|
||||
'network',
|
||||
'-X',
|
||||
'gcovout',
|
||||
'-X',
|
||||
'html',
|
||||
'-X',
|
||||
'recursesubs',
|
||||
'-a',
|
||||
'--timeout 3',
|
||||
'-g',
|
||||
'**/exclude-dir/*.*',
|
||||
'-x',
|
||||
'gcov',
|
||||
'-G',
|
||||
'**/include-dir/*.*',
|
||||
'-k',
|
||||
'demo',
|
||||
'-i',
|
||||
'dir1',
|
||||
'-B',
|
||||
'thomasrockhu/test',
|
||||
'-b',
|
||||
'1',
|
||||
'-C',
|
||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||
'-P',
|
||||
'2',
|
||||
'-T',
|
||||
'v1.2',
|
||||
'-R',
|
||||
'root/',
|
||||
'-s',
|
||||
'coverage/',
|
||||
'-v',
|
||||
'-q',
|
||||
'codecov/',
|
||||
'-D',
|
||||
'~/Library/Developer/Xcode/DerivedData',
|
||||
'-J',
|
||||
'MyApp',
|
||||
]);
|
||||
expect(filepath).toEqual('src/codecov.sh');
|
||||
expect(failCi).toBeTruthy();
|
||||
|
||||
for (const env of Object.keys(envs)) {
|
||||
delete process.env['INPUT_' + env.toUpperCase()];
|
||||
}
|
||||
});
|
||||
175
src/buildExec.ts
Normal file
175
src/buildExec.ts
Normal file
@@ -0,0 +1,175 @@
|
||||
const core = require('@actions/core');
|
||||
const github = require('@actions/github');
|
||||
|
||||
const context = github.context;
|
||||
|
||||
const isTrue = (variable) => {
|
||||
const lowercase = variable.toLowerCase();
|
||||
return (
|
||||
lowercase === '1' ||
|
||||
lowercase === 't' ||
|
||||
lowercase === 'true' ||
|
||||
lowercase === 'y' ||
|
||||
lowercase === 'yes'
|
||||
);
|
||||
};
|
||||
|
||||
const buildExec = () => {
|
||||
const clean = core.getInput('move_coverage_to_trash');
|
||||
const commitParent = core.getInput('commit_parent');
|
||||
const curlAwsArgs = core.getInput('aws_curl_args');
|
||||
const curlCodecovArgs = core.getInput('codecov_curl_args');
|
||||
const envVars = core.getInput('env_vars');
|
||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||
const file = core.getInput('file');
|
||||
const files = core.getInput('files');
|
||||
const flags = core.getInput('flags');
|
||||
const functionalities = core.getInput('functionalities');
|
||||
const gcovArgs = core.getInput('gcov_args');
|
||||
const gcovDir = core.getInput('gcov_root_dir');
|
||||
const gcovExclude = core.getInput('gcov_path_exclude');
|
||||
const gcovExec = core.getInput('gcov_executable');
|
||||
const gcovInclude = core.getInput('gcov_path_include');
|
||||
const gcovPrefix = core.getInput('gcov_prefix');
|
||||
const name = core.getInput('name');
|
||||
const networkFilter = core.getInput('network_filter');
|
||||
const overrideBranch = core.getInput('override_branch');
|
||||
const overrideBuild = core.getInput('override_build');
|
||||
const overrideCommit = core.getInput('override_commit');
|
||||
const overridePr = core.getInput('override_pr');
|
||||
const overrideTag = core.getInput('override_tag');
|
||||
const rootDir = core.getInput('root_dir');
|
||||
const searchDir = core.getInput('directory');
|
||||
const token = core.getInput('token');
|
||||
const verbose = isTrue(core.getInput('verbose'));
|
||||
const workingDir = core.getInput('working-directory');
|
||||
const writePath = core.getInput('path_to_write_report');
|
||||
const xcodeDerivedData = core.getInput('xcode_derived_data');
|
||||
const xcodePackage = core.getInput('xcode_package');
|
||||
|
||||
const filepath = workingDir ?
|
||||
workingDir + '/codecov.sh' : 'codecov.sh';
|
||||
|
||||
const execArgs = [filepath];
|
||||
execArgs.push( '-n', `${name}`, '-F', `${flags}`, '-Q', 'github-action' );
|
||||
|
||||
const options:any = {};
|
||||
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 || '',
|
||||
});
|
||||
|
||||
const envVarsArg = [];
|
||||
for (const envVar of envVars.split(',')) {
|
||||
const envVarClean = envVar.trim();
|
||||
if (envVarClean) {
|
||||
options.env[envVarClean] = process.env[envVarClean];
|
||||
envVarsArg.push(envVarClean);
|
||||
}
|
||||
}
|
||||
|
||||
if (token) {
|
||||
options.env.CODECOV_TOKEN = token;
|
||||
}
|
||||
if (clean) {
|
||||
execArgs.push('-c');
|
||||
}
|
||||
if (commitParent) {
|
||||
execArgs.push('-N', `${commitParent}`);
|
||||
}
|
||||
if (curlAwsArgs) {
|
||||
execArgs.push('-A', `${curlAwsArgs}`);
|
||||
}
|
||||
if (curlCodecovArgs) {
|
||||
execArgs.push('-U', `${curlCodecovArgs}`);
|
||||
}
|
||||
if (envVarsArg.length) {
|
||||
execArgs.push('-e', envVarsArg.join(','));
|
||||
}
|
||||
if (failCi) {
|
||||
execArgs.push('-Z');
|
||||
}
|
||||
if (file) {
|
||||
execArgs.push('-f', `${file}`);
|
||||
}
|
||||
if (files) {
|
||||
files.split(',').forEach((f) => {
|
||||
execArgs.push('-f', `${f}`);
|
||||
});
|
||||
}
|
||||
if (functionalities) {
|
||||
functionalities.split(',').forEach((f) => {
|
||||
execArgs.push('-X', `${f}`);
|
||||
});
|
||||
}
|
||||
if (gcovArgs) {
|
||||
execArgs.push('-a', `${gcovArgs}`);
|
||||
}
|
||||
if (gcovDir) {
|
||||
execArgs.push('-p', `${gcovDir}`);
|
||||
}
|
||||
if (gcovExclude) {
|
||||
execArgs.push('-g', `${gcovExclude}`);
|
||||
}
|
||||
if (gcovExec) {
|
||||
execArgs.push('-x', `${gcovExec}`);
|
||||
}
|
||||
if (gcovInclude) {
|
||||
execArgs.push('-G', `${gcovInclude}`);
|
||||
}
|
||||
if (gcovPrefix) {
|
||||
execArgs.push('-k', `${gcovPrefix}`);
|
||||
}
|
||||
if (networkFilter) {
|
||||
execArgs.push('-i', `${networkFilter}`);
|
||||
}
|
||||
if (overrideBranch) {
|
||||
execArgs.push('-B', `${overrideBranch}`);
|
||||
}
|
||||
if (overrideBuild) {
|
||||
execArgs.push('-b', `${overrideBuild}`);
|
||||
}
|
||||
if (overrideCommit) {
|
||||
execArgs.push('-C', `${overrideCommit}`);
|
||||
} else if (
|
||||
`${context.eventName}` == 'pull_request' ||
|
||||
`${context.eventName}` == 'pull_request_target'
|
||||
) {
|
||||
execArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||
}
|
||||
if (overridePr) {
|
||||
execArgs.push('-P', `${overridePr}`);
|
||||
}
|
||||
if (overrideTag) {
|
||||
execArgs.push('-T', `${overrideTag}`);
|
||||
}
|
||||
if (rootDir) {
|
||||
execArgs.push('-R', `${rootDir}`);
|
||||
}
|
||||
if (searchDir) {
|
||||
execArgs.push('-s', `${searchDir}`);
|
||||
}
|
||||
if (verbose) {
|
||||
execArgs.push('-v');
|
||||
}
|
||||
if (workingDir) {
|
||||
options.cwd = workingDir;
|
||||
}
|
||||
if (writePath) {
|
||||
execArgs.push('-q', `${writePath}`);
|
||||
}
|
||||
if (xcodeDerivedData) {
|
||||
execArgs.push('-D', `${xcodeDerivedData}`);
|
||||
}
|
||||
if (xcodePackage) {
|
||||
execArgs.push('-J', `${xcodePackage}`);
|
||||
}
|
||||
|
||||
return {execArgs, options, filepath, failCi};
|
||||
};
|
||||
|
||||
export default buildExec;
|
||||
69
src/index.ts
Normal file
69
src/index.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
const core = require('@actions/core');
|
||||
const exec = require('@actions/exec');
|
||||
|
||||
const fs = require('fs');
|
||||
const request = require('requestretry');
|
||||
|
||||
import buildExec from './buildExec';
|
||||
|
||||
let failCi;
|
||||
try {
|
||||
request({
|
||||
json: false,
|
||||
maxAttempts: 10,
|
||||
timeout: 3000,
|
||||
url: 'https://codecov.io/bash',
|
||||
}, (error, response, body) => {
|
||||
const {execArgs, options, filepath, failCi} = buildExec();
|
||||
|
||||
try {
|
||||
if (error && failCi) {
|
||||
throw error;
|
||||
} else if (error) {
|
||||
core.warning(`Codecov warning: ${error.message}`);
|
||||
}
|
||||
|
||||
fs.writeFile(filepath, body, (err) => {
|
||||
if (err && failCi) {
|
||||
throw err;
|
||||
} else if (err) {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
|
||||
exec.exec('bash', execArgs, options)
|
||||
.catch((err) => {
|
||||
if (failCi) {
|
||||
core.setFailed(
|
||||
`Codecov failed with the following error: ${err.message}`,
|
||||
);
|
||||
} else {
|
||||
core.warning(`Codecov warning: ${err.message}`);
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
unlinkFile();
|
||||
});
|
||||
|
||||
const unlinkFile = () => {
|
||||
fs.unlink(filepath, (err) => {
|
||||
if (err && failCi) {
|
||||
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) {
|
||||
if (failCi) {
|
||||
core.setFailed(`Codecov failed with the following error: ${error.message}`);
|
||||
} else {
|
||||
core.warning(`Codecov warning: ${error.message}`);
|
||||
}
|
||||
}
|
||||
5
tsconfig.json
Normal file
5
tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user