mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
111 Commits
v4.0.0-bet
...
v4.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0b68c6749 | ||
|
|
1f9f5573d1 | ||
|
|
09686fcfcb | ||
|
|
f30e4959ba | ||
|
|
a7b945cea4 | ||
|
|
98ab2c591b | ||
|
|
43235cc5ae | ||
|
|
0cf8684c82 | ||
|
|
8e1e730371 | ||
|
|
61293af0e8 | ||
|
|
7a070cbe5b | ||
|
|
909716592c | ||
|
|
ac042eaf0f | ||
|
|
2ee76754cf | ||
|
|
ed33b8792b | ||
|
|
205d0f3bf2 | ||
|
|
f7a40362d5 | ||
|
|
347aed814d | ||
|
|
240e6ae968 | ||
|
|
22b99ac1d7 | ||
|
|
c256d56669 | ||
|
|
b655832634 | ||
|
|
f3c893f625 | ||
|
|
d64049153d | ||
|
|
082211867f | ||
|
|
36c4c273ec | ||
|
|
3557dec46e | ||
|
|
d09fc58aca | ||
|
|
53405dd159 | ||
|
|
9cae541a7d | ||
|
|
7a6de893e7 | ||
|
|
67144c77f4 | ||
|
|
7574dbd6ec | ||
|
|
bbeaa14035 | ||
|
|
560836068e | ||
|
|
bd76fb6ca2 | ||
|
|
81da1cc4bc | ||
|
|
6b11576289 | ||
|
|
ab88a5b6c7 | ||
|
|
e9a38394a1 | ||
|
|
35eb77e000 | ||
|
|
eb2fd70b01 | ||
|
|
2d2a8f93e1 | ||
|
|
4a1b7c9084 | ||
|
|
6e1433e83b | ||
|
|
6a5356fcde | ||
|
|
05c8e34a27 | ||
|
|
bc023a2d94 | ||
|
|
b0466b47a0 | ||
|
|
f33d135af5 | ||
|
|
438fa9e3ac | ||
|
|
4df8175b4e | ||
|
|
b414989bf5 | ||
|
|
8474edbadb | ||
|
|
8656f6c1c6 | ||
|
|
9234907bdc | ||
|
|
3789238b3b | ||
|
|
920a494b79 | ||
|
|
83b6689bed | ||
|
|
fdcdb22cba | ||
|
|
7d665f44bb | ||
|
|
4b48428164 | ||
|
|
4646528f20 | ||
|
|
f8eb26ef37 | ||
|
|
5e2c2ecdbd | ||
|
|
f4993f1f51 | ||
|
|
11e76d658b | ||
|
|
94d82392c4 | ||
|
|
34bba43c95 | ||
|
|
028beb0e20 | ||
|
|
b98ba29eaf | ||
|
|
70827de827 | ||
|
|
eef87f60cd | ||
|
|
35d91fd4ea | ||
|
|
6dacea127a | ||
|
|
ca9e0edcd3 | ||
|
|
aca8ff1dcc | ||
|
|
83d30f0e41 | ||
|
|
aceeca9bb1 | ||
|
|
d7fb5255d7 | ||
|
|
4a43355a6e | ||
|
|
d4985dcf35 | ||
|
|
535356c890 | ||
|
|
cdcd85ee2a | ||
|
|
525bbfffeb | ||
|
|
03dadc24b6 | ||
|
|
277c1b5977 | ||
|
|
f79a6d89b1 | ||
|
|
5bafa6898e | ||
|
|
0bd02822a2 | ||
|
|
d128348047 | ||
|
|
838dde6607 | ||
|
|
12886f0366 | ||
|
|
74d2e8d453 | ||
|
|
392e27ba63 | ||
|
|
72c1031b41 | ||
|
|
9ae347ac89 | ||
|
|
9701436596 | ||
|
|
32bfff88bd | ||
|
|
cafbda5927 | ||
|
|
ef2b0df87f | ||
|
|
f8c4fc3b04 | ||
|
|
4682b7b2df | ||
|
|
356138457c | ||
|
|
2f1c584520 | ||
|
|
b6dbf98f30 | ||
|
|
76d318c315 | ||
|
|
df7f1afac7 | ||
|
|
10187ae73d | ||
|
|
0b0064c1d1 | ||
|
|
44a150985a |
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -37,11 +37,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2.21.7
|
uses: github/codeql-action/init@v3.23.2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v2.21.7
|
uses: github/codeql-action/autobuild@v3.23.2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -66,4 +66,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2.21.7
|
uses: github/codeql-action/analyze@v3.23.2
|
||||||
|
|||||||
14
.github/workflows/enforce-license-compliance.yml
vendored
Normal file
14
.github/workflows/enforce-license-compliance.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: Enforce License Compliance
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main, master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
enforce-license-compliance:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 'Enforce License Compliance'
|
||||||
|
uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main
|
||||||
|
with:
|
||||||
|
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
|
||||||
39
.github/workflows/main.yml
vendored
39
.github/workflows/main.yml
vendored
@@ -1,49 +1,14 @@
|
|||||||
name: Workflow for Codecov Action
|
name: Workflow for Codecov Action
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
no-deps:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4.0.0
|
|
||||||
- name: Upload coverage to Codecov (script)
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
files: ./coverage/script/coverage-final.json
|
|
||||||
flags: script,${{ matrix.os }}
|
|
||||||
name: codecov-script
|
|
||||||
verbose: true
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
- 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,${{ matrix.os }}
|
|
||||||
name: codecov-demo
|
|
||||||
verbose: true
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
- name: Upload coverage to Codecov (version)
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
|
||||||
file: ./coverage/coverage-final.json
|
|
||||||
flags: version,${{ matrix.os }}
|
|
||||||
name: codecov-version
|
|
||||||
version: v0.2.0
|
|
||||||
verbose: true
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest, macos-latest-xlarge]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Lint
|
- name: Lint
|
||||||
|
|||||||
8
.github/workflows/scorecards-analysis.yml
vendored
8
.github/workflows/scorecards-analysis.yml
vendored
@@ -24,12 +24,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v4.0.0 # v3.0.0
|
uses: actions/checkout@v4.1.1 # v3.0.0
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run analysis"
|
- name: "Run analysis"
|
||||||
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0
|
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
|
||||||
with:
|
with:
|
||||||
results_file: results.sarif
|
results_file: results.sarif
|
||||||
results_format: sarif
|
results_format: sarif
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||||
# format to the repository Actions tab.
|
# format to the repository Actions tab.
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
|
||||||
with:
|
with:
|
||||||
name: SARIF file
|
name: SARIF file
|
||||||
path: results.sarif
|
path: results.sarif
|
||||||
@@ -56,6 +56,6 @@ jobs:
|
|||||||
|
|
||||||
# Upload the results to GitHub's code scanning dashboard.
|
# Upload the results to GitHub's code scanning dashboard.
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@v2.21.7 # v1.0.26
|
uses: github/codeql-action/upload-sarif@v3.23.2 # v1.0.26
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -1,7 +1,7 @@
|
|||||||
deploy:
|
deploy:
|
||||||
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
||||||
git tag -d v3
|
git tag -d v4
|
||||||
git push origin :v3
|
git push origin :v4
|
||||||
git tag v3
|
git tag v4
|
||||||
git tag v$(VERSION) -s -m ""
|
git tag v$(VERSION) -s -m ""
|
||||||
git push origin --tags
|
git push origin --tags
|
||||||
|
|||||||
56
README.md
56
README.md
@@ -5,45 +5,59 @@
|
|||||||
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
[](https://github.com/codecov/codecov-action/actions/workflows/main.yml)
|
||||||
### Easily upload coverage reports to Codecov from GitHub Actions
|
### Easily upload coverage reports to Codecov from GitHub Actions
|
||||||
|
|
||||||
## v4 Beta Release
|
## v4 Release
|
||||||
`v4` of the Codecov GitHub Action will use the [Codecov CLI](https://github.com/codecov/codecov-cli) to upload coverage reports to Codecov. Currently, `v4` is in beta.
|
`v4` of the Codecov GitHub Action will use the [Codecov CLI](https://github.com/codecov/codecov-cli) to upload coverage reports to Codecov.
|
||||||
|
|
||||||
Breaking Changes
|
Breaking Changes
|
||||||
- No current support for `aarch64` and `alpine` architectures.
|
- Tokenless uploading is unsupported. However, PRs made from forks to the upstream public repos will support tokenless (e.g. contributors to OS projects do not need the upstream repo's Codecov token)
|
||||||
- Tokenless uploading is unsupported
|
|
||||||
- Various arguments to the Action have been removed
|
- Various arguments to the Action have been removed
|
||||||
|
|
||||||
`v3` versions and below will not have access to CLI features (e.g. global upload token).
|
`v3` versions and below will not have access to CLI features (e.g. global upload token, ATS).
|
||||||
|
|
||||||
## ⚠️ Deprecation of v1
|
|
||||||
**As of February 1, 2022, v1 has been fully sunset and no longer functions**
|
|
||||||
|
|
||||||
Due to the [deprecation](https://about.codecov.io/blog/introducing-codecovs-new-uploader/) of the underlying bash uploader,
|
|
||||||
the Codecov GitHub Action has released `v2`/`v3` which will use the new [uploader](https://github.com/codecov/uploader). You can learn
|
|
||||||
more about our deprecation plan and the new uploader on our [blog](https://about.codecov.io/blog/introducing-codecovs-new-uploader/).
|
|
||||||
|
|
||||||
We will be restricting any updates to the `v1` Action to security updates and hotfixes.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (`@v3` is recommended) as a `step` within your `workflow.yml` file.
|
To integrate Codecov with your Actions pipeline, specify the name of this repository with a tag number (`@v4` 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**
|
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](https://docs.codecov.com/docs/adding-the-codecov-token#github-actions) as a `secret`).
|
||||||
|
|
||||||
|
Currently, the Action will identify linux, macos, and windows runners. However, the Action may misidentify other architectures. The OS can be specified as
|
||||||
|
- alpine
|
||||||
|
- alpine-arm64
|
||||||
|
- linux
|
||||||
|
- linux-arm64
|
||||||
|
- macos
|
||||||
|
- windows
|
||||||
|
|
||||||
Inside your `.github/workflows/workflow.yml` file:
|
Inside your `.github/workflows/workflow.yml` file:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
- uses: codecov/codecov-action@v3
|
- uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
fail_ci_if_error: true # optional (default = false)
|
||||||
files: ./coverage1.xml,./coverage2.xml # optional
|
files: ./coverage1.xml,./coverage2.xml # optional
|
||||||
flags: unittests # optional
|
flags: unittests # optional
|
||||||
name: codecov-umbrella # optional
|
name: codecov-umbrella # optional
|
||||||
fail_ci_if_error: true # optional (default = false)
|
token: ${{ secrets.CODECOV_TOKEN }} # required
|
||||||
verbose: true # optional (default = false)
|
verbose: true # optional (default = false)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The Codecov token can also be passed in via environment variables:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- uses: codecov/codecov-action@v4
|
||||||
|
with:
|
||||||
|
fail_ci_if_error: true # optional (default = false)
|
||||||
|
files: ./coverage1.xml,./coverage2.xml # optional
|
||||||
|
flags: unittests # optional
|
||||||
|
name: codecov-umbrella # optional
|
||||||
|
verbose: true # optional (default = false)
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
```
|
||||||
>**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.
|
>**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
|
||||||
@@ -118,15 +132,15 @@ jobs:
|
|||||||
pip install pytest-cov
|
pip install pytest-cov
|
||||||
pytest --cov=./ --cov-report=xml
|
pytest --cov=./ --cov-report=xml
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
directory: ./coverage/reports/
|
directory: ./coverage/reports/
|
||||||
env_vars: OS,PYTHON
|
env_vars: OS,PYTHON
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: true
|
||||||
files: ./coverage1.xml,./coverage2.xml,!./cache
|
files: ./coverage1.xml,./coverage2.xml,!./cache
|
||||||
flags: unittests
|
flags: unittests
|
||||||
name: codecov-umbrella
|
name: codecov-umbrella
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
verbose: true
|
verbose: true
|
||||||
```
|
```
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|||||||
51
action.yml
51
action.yml
@@ -5,17 +5,20 @@ inputs:
|
|||||||
token:
|
token:
|
||||||
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
||||||
required: false
|
required: false
|
||||||
file:
|
codecov_yml_path:
|
||||||
description: 'Path to coverage file to upload'
|
description: 'Specify the path to the Codecov YML'
|
||||||
required: false
|
required: false
|
||||||
files:
|
commit_parent:
|
||||||
description: 'Comma-separated list of files to upload'
|
description: 'Override to specify the parent commit SHA'
|
||||||
required: false
|
required: false
|
||||||
directory:
|
directory:
|
||||||
description: 'Directory to search for coverage reports.'
|
description: 'Directory to search for coverage reports.'
|
||||||
required: false
|
required: false
|
||||||
flags:
|
disable_search:
|
||||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option.'
|
||||||
|
required: false
|
||||||
|
disable_file_fixes:
|
||||||
|
description: 'Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)'
|
||||||
required: false
|
required: false
|
||||||
dry_run:
|
dry_run:
|
||||||
description: "Don't upload files to Codecov"
|
description: "Don't upload files to Codecov"
|
||||||
@@ -23,11 +26,26 @@ inputs:
|
|||||||
env_vars:
|
env_vars:
|
||||||
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
||||||
required: false
|
required: false
|
||||||
|
exclude:
|
||||||
|
description: 'Folders to exclude from search'
|
||||||
|
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
|
||||||
gcov:
|
file:
|
||||||
description: 'Run with gcov support'
|
description: 'Path to coverage file to upload'
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: 'Comma-separated list of files to upload'
|
||||||
|
required: false
|
||||||
|
flags:
|
||||||
|
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||||
|
required: false
|
||||||
|
handle_no_reports_found:
|
||||||
|
description: 'Raise no exceptions when no coverage reports found'
|
||||||
|
required: false
|
||||||
|
job_code:
|
||||||
|
description: 'The job code'
|
||||||
required: false
|
required: false
|
||||||
name:
|
name:
|
||||||
description: 'User defined upload name. Visible in Codecov UI'
|
description: 'User defined upload name. Visible in Codecov UI'
|
||||||
@@ -41,21 +59,36 @@ inputs:
|
|||||||
override_build:
|
override_build:
|
||||||
description: 'Specify the build number'
|
description: 'Specify the build number'
|
||||||
required: false
|
required: false
|
||||||
|
override_build_url:
|
||||||
|
description: 'The URL of the build where this is running'
|
||||||
|
required: false
|
||||||
override_commit:
|
override_commit:
|
||||||
description: 'Specify the commit SHA'
|
description: 'Specify the commit SHA'
|
||||||
required: false
|
required: false
|
||||||
override_pr:
|
override_pr:
|
||||||
description: 'Specify the pull request number'
|
description: 'Specify the pull request number'
|
||||||
required: false
|
required: false
|
||||||
|
plugin:
|
||||||
|
description: 'plugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all.'
|
||||||
|
required: false
|
||||||
plugins:
|
plugins:
|
||||||
description: 'Comma-separated list of plugins for use during upload.'
|
description: 'Comma-separated list of plugins for use during upload.'
|
||||||
required: false
|
required: false
|
||||||
|
report_code:
|
||||||
|
description: 'The code of the report. If unsure, do not include'
|
||||||
|
required: false
|
||||||
root_dir:
|
root_dir:
|
||||||
description: 'Used when not in git/hg project to identify project root directory'
|
description: 'Used when not in git/hg project to identify project root directory'
|
||||||
required: false
|
required: false
|
||||||
slug:
|
slug:
|
||||||
description: 'Specify the slug manually (Enterprise use)'
|
description: 'Specify the slug manually (Enterprise use)'
|
||||||
required: false
|
required: false
|
||||||
|
url:
|
||||||
|
description: 'Specify the base url to upload (Enterprise use)'
|
||||||
|
required: false
|
||||||
|
use_legacy_upload_endpoint:
|
||||||
|
description: 'Use the legacy upload endpoint'
|
||||||
|
required: false
|
||||||
verbose:
|
verbose:
|
||||||
description: 'Specify whether the Codecov output should be verbose'
|
description: 'Specify whether the Codecov output should be verbose'
|
||||||
required: false
|
required: false
|
||||||
@@ -69,5 +102,5 @@ branding:
|
|||||||
color: 'red'
|
color: 'red'
|
||||||
icon: 'umbrella'
|
icon: 'umbrella'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
45015
dist/index.js
vendored
45015
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
1262
package-lock.json
generated
1262
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "4.0.0-beta.3",
|
"version": "4.0.1",
|
||||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -25,21 +25,20 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^6.0.0",
|
||||||
"node-fetch": "^3.3.2",
|
"gpg": "^0.6.0",
|
||||||
"openpgp": "5.10"
|
"undici": "5.28.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.5",
|
"@types/jest": "^29.5.11",
|
||||||
"@types/node": "^20.6.3",
|
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.7.2",
|
"@typescript-eslint/parser": "^6.20.0",
|
||||||
"@typescript-eslint/parser": "^6.7.2",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"@vercel/ncc": "^0.38.0",
|
"eslint": "^8.56.0",
|
||||||
"eslint": "^8.49.0",
|
|
||||||
"eslint-config-google": "^0.14.0",
|
"eslint-config-google": "^0.14.0",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-junit": "^16.0.0",
|
"jest-junit": "^16.0.0",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.2",
|
||||||
"typescript": "^5.2.0"
|
"typescript": "^5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const context = github.context;
|
|||||||
|
|
||||||
test('general args', () => {
|
test('general args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
codecov_yml_path: 'dev/codecov.yml',
|
||||||
url: 'https://codecov.enterprise.com',
|
url: 'https://codecov.enterprise.com',
|
||||||
verbose: 't',
|
verbose: 't',
|
||||||
};
|
};
|
||||||
@@ -23,6 +24,8 @@ test('general args', () => {
|
|||||||
|
|
||||||
expect(args).toEqual(
|
expect(args).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
|
'--codecov-yml-path',
|
||||||
|
'dev/codecov.yml',
|
||||||
'--enterprise-url',
|
'--enterprise-url',
|
||||||
'https://codecov.enterprise.com',
|
'https://codecov.enterprise.com',
|
||||||
'-v',
|
'-v',
|
||||||
@@ -50,25 +53,38 @@ test('upload args using context', () => {
|
|||||||
|
|
||||||
test('upload args', () => {
|
test('upload args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
'codecov_yml_path': 'dev/codecov.yml',
|
||||||
|
'commit_parent': 'fakeparentcommit',
|
||||||
'directory': 'coverage/',
|
'directory': 'coverage/',
|
||||||
|
'disable_file_fixes': 'true',
|
||||||
|
'disable_search': 'true',
|
||||||
'dry_run': 'true',
|
'dry_run': 'true',
|
||||||
'env_vars': 'OS,PYTHON',
|
'env_vars': 'OS,PYTHON',
|
||||||
|
'exclude': 'node_modules/',
|
||||||
'fail_ci_if_error': 'true',
|
'fail_ci_if_error': 'true',
|
||||||
'file': 'coverage.xml',
|
'file': 'coverage.xml',
|
||||||
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
||||||
'flags': 'test,test2',
|
'flags': 'test,test2',
|
||||||
|
'handle_no_reports_found': 'true',
|
||||||
|
'job_code': '32',
|
||||||
'name': 'codecov',
|
'name': 'codecov',
|
||||||
|
'os': 'macos',
|
||||||
'override_branch': 'thomasrockhu/test',
|
'override_branch': 'thomasrockhu/test',
|
||||||
'override_build': '1',
|
'override_build': '1',
|
||||||
|
'override_build_url': 'https://example.com/build/2',
|
||||||
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'override_pr': '2',
|
'override_pr': '2',
|
||||||
|
'plugin': 'xcode',
|
||||||
'plugins': 'pycoverage,compress-pycoverage',
|
'plugins': 'pycoverage,compress-pycoverage',
|
||||||
|
'report_code': 'testCode',
|
||||||
'root_dir': 'root/',
|
'root_dir': 'root/',
|
||||||
'slug': 'fakeOwner/fakeRepo',
|
'slug': 'fakeOwner/fakeRepo',
|
||||||
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
'url': 'https://enterprise.example.com',
|
||||||
|
'use_legacy_upload_endpoint': 'true',
|
||||||
|
'verbose': 'true',
|
||||||
|
'version': '0.1.2',
|
||||||
'working-directory': 'src',
|
'working-directory': 'src',
|
||||||
'plugin': 'xcode',
|
|
||||||
'exclude': 'src',
|
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
@@ -76,11 +92,13 @@ test('upload args', () => {
|
|||||||
|
|
||||||
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
||||||
const expectedArgs = [
|
const expectedArgs = [
|
||||||
'-n',
|
'--disable-file-fixes',
|
||||||
'codecov',
|
'--disable-search',
|
||||||
'-d',
|
'-d',
|
||||||
'-e',
|
'-e',
|
||||||
'OS,PYTHON',
|
'OS,PYTHON',
|
||||||
|
'--exclude',
|
||||||
|
'node_modules/',
|
||||||
'-Z',
|
'-Z',
|
||||||
'-f',
|
'-f',
|
||||||
'coverage.xml',
|
'coverage.xml',
|
||||||
@@ -92,28 +110,36 @@ test('upload args', () => {
|
|||||||
'test',
|
'test',
|
||||||
'-F',
|
'-F',
|
||||||
'test2',
|
'test2',
|
||||||
|
'--handle-no-reports-found',
|
||||||
|
'--job-code',
|
||||||
|
'32',
|
||||||
|
'-n',
|
||||||
|
'codecov',
|
||||||
'-B',
|
'-B',
|
||||||
'thomasrockhu/test',
|
'thomasrockhu/test',
|
||||||
'-b',
|
'-b',
|
||||||
'1',
|
'1',
|
||||||
|
'--build-url',
|
||||||
|
'https://example.com/build/2',
|
||||||
'-C',
|
'-C',
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'-P',
|
'-P',
|
||||||
'2',
|
'2',
|
||||||
'--plugin',
|
'--plugin',
|
||||||
|
'xcode',
|
||||||
|
'--plugin',
|
||||||
'pycoverage',
|
'pycoverage',
|
||||||
'--plugin',
|
'--plugin',
|
||||||
'compress-pycoverage',
|
'compress-pycoverage',
|
||||||
|
'--report-code',
|
||||||
|
'testCode',
|
||||||
'--network-root-folder',
|
'--network-root-folder',
|
||||||
'root/',
|
'root/',
|
||||||
'-s',
|
'-s',
|
||||||
'coverage/',
|
'coverage/',
|
||||||
'-r',
|
'-r',
|
||||||
'fakeOwner/fakeRepo',
|
'fakeOwner/fakeRepo',
|
||||||
'--plugin',
|
'--legacy',
|
||||||
'xcode',
|
|
||||||
'--exclude',
|
|
||||||
'src',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
expect(uploadExecArgs).toEqual(expectedArgs);
|
expect(uploadExecArgs).toEqual(expectedArgs);
|
||||||
@@ -127,8 +153,10 @@ test('upload args', () => {
|
|||||||
test('report args', () => {
|
test('report args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
override_pr: 'fakePR',
|
||||||
slug: 'fakeOwner/fakeRepo',
|
slug: 'fakeOwner/fakeRepo',
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
fail_ci_if_error: 'true',
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
@@ -136,13 +164,17 @@ test('report args', () => {
|
|||||||
|
|
||||||
const {reportExecArgs, reportCommand} = buildReportExec();
|
const {reportExecArgs, reportCommand} = buildReportExec();
|
||||||
|
|
||||||
expect(reportExecArgs).toEqual(
|
const expectedArgs = [
|
||||||
expect.arrayContaining([
|
|
||||||
'-C',
|
'-C',
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
'-P',
|
||||||
|
'fakePR',
|
||||||
'--slug',
|
'--slug',
|
||||||
'fakeOwner/fakeRepo',
|
'fakeOwner/fakeRepo',
|
||||||
]));
|
'-Z',
|
||||||
|
];
|
||||||
|
|
||||||
|
expect(reportExecArgs).toEqual(expectedArgs);
|
||||||
expect(reportCommand).toEqual('create-report');
|
expect(reportCommand).toEqual('create-report');
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
@@ -174,32 +206,34 @@ test('report args using context', () => {
|
|||||||
|
|
||||||
test('commit args', () => {
|
test('commit args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
||||||
|
override_branch: 'thomasrockhu/test',
|
||||||
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
override_pr: '2',
|
||||||
slug: 'fakeOwner/fakeRepo',
|
slug: 'fakeOwner/fakeRepo',
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
override_branch: 'thomasrockhu/test',
|
fail_ci_if_error: 'true',
|
||||||
override_pr: '2',
|
|
||||||
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
}
|
}
|
||||||
|
|
||||||
const {commitExecArgs, commitCommand} = buildCommitExec();
|
const {commitExecArgs, commitCommand} = buildCommitExec();
|
||||||
|
const expectedArgs = [
|
||||||
expect(commitExecArgs).toEqual(
|
|
||||||
expect.arrayContaining([
|
|
||||||
'-C',
|
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
|
||||||
'--slug',
|
|
||||||
'fakeOwner/fakeRepo',
|
|
||||||
'-B',
|
|
||||||
'thomasrockhu/test',
|
|
||||||
'--pr',
|
|
||||||
'2',
|
|
||||||
'--parent-sha',
|
'--parent-sha',
|
||||||
'83231650328f11695dfb754ca0f540516f188d27',
|
'83231650328f11695dfb754ca0f540516f188d27',
|
||||||
]));
|
'-B',
|
||||||
|
'thomasrockhu/test',
|
||||||
|
'-C',
|
||||||
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
'--pr',
|
||||||
|
'2',
|
||||||
|
'--slug',
|
||||||
|
'fakeOwner/fakeRepo',
|
||||||
|
'-Z',
|
||||||
|
];
|
||||||
|
|
||||||
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
expect(commitCommand).toEqual('create-commit');
|
expect(commitCommand).toEqual('create-commit');
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const buildCommitExec = () => {
|
|||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
|
||||||
const commitCommand = 'create-commit';
|
const commitCommand = 'create-commit';
|
||||||
const commitExecArgs = [];
|
const commitExecArgs = [];
|
||||||
@@ -69,16 +69,23 @@ const buildCommitExec = () => {
|
|||||||
if (slug) {
|
if (slug) {
|
||||||
commitExecArgs.push('--slug', `${slug}`);
|
commitExecArgs.push('--slug', `${slug}`);
|
||||||
}
|
}
|
||||||
|
if (failCi) {
|
||||||
|
commitExecArgs.push('-Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {commitExecArgs, commitOptions, commitCommand};
|
return {commitExecArgs, commitOptions, commitCommand};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildGeneralExec = () => {
|
const buildGeneralExec = () => {
|
||||||
|
const codecovYmlPath = core.getInput('codecov_yml_path');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
||||||
|
if (codecovYmlPath) {
|
||||||
|
args.push('--codecov-yml-path', `${codecovYmlPath}`);
|
||||||
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
args.push('--enterprise-url', `${url}`);
|
args.push('--enterprise-url', `${url}`);
|
||||||
}
|
}
|
||||||
@@ -90,8 +97,10 @@ const buildGeneralExec = () => {
|
|||||||
|
|
||||||
const buildReportExec = () => {
|
const buildReportExec = () => {
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
|
||||||
|
|
||||||
const reportCommand = 'create-report';
|
const reportCommand = 'create-report';
|
||||||
@@ -119,35 +128,54 @@ const buildReportExec = () => {
|
|||||||
) {
|
) {
|
||||||
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
}
|
}
|
||||||
|
if (overridePr) {
|
||||||
|
reportExecArgs.push('-P', `${overridePr}`);
|
||||||
|
} else if (
|
||||||
|
`${context.eventName}` == 'pull_request_target'
|
||||||
|
) {
|
||||||
|
reportExecArgs.push('-P', `${context.payload.number}`);
|
||||||
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
reportExecArgs.push('--slug', `${slug}`);
|
reportExecArgs.push('--slug', `${slug}`);
|
||||||
}
|
}
|
||||||
|
if (failCi) {
|
||||||
|
reportExecArgs.push('-Z');
|
||||||
|
}
|
||||||
|
|
||||||
return {reportExecArgs, reportOptions, reportCommand};
|
return {reportExecArgs, reportOptions, reportCommand};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildUploadExec = () => {
|
const buildUploadExec = () => {
|
||||||
const envVars = core.getInput('env_vars');
|
const disableFileFixes = isTrue(core.getInput('disable_file_fixes'));
|
||||||
|
const disableSearch = isTrue(core.getInput('disable_search'));
|
||||||
const dryRun = isTrue(core.getInput('dry_run'));
|
const dryRun = isTrue(core.getInput('dry_run'));
|
||||||
|
const envVars = core.getInput('env_vars');
|
||||||
|
const exclude = core.getInput('exclude');
|
||||||
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
const file = core.getInput('file');
|
const file = core.getInput('file');
|
||||||
const files = core.getInput('files');
|
const files = core.getInput('files');
|
||||||
const flags = core.getInput('flags');
|
const flags = core.getInput('flags');
|
||||||
|
const handleNoReportsFound = isTrue(core.getInput('handle_no_reports_found'));
|
||||||
|
const jobCode = core.getInput('job_code');
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
const os = core.getInput('os');
|
const os = core.getInput('os');
|
||||||
const overrideBranch = core.getInput('override_branch');
|
const overrideBranch = core.getInput('override_branch');
|
||||||
const overrideBuild = core.getInput('override_build');
|
const overrideBuild = core.getInput('override_build');
|
||||||
|
const overrideBuildUrl = core.getInput('override_build_url');
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
|
const plugin = core.getInput('plugin');
|
||||||
const plugins = core.getInput('plugins');
|
const plugins = core.getInput('plugins');
|
||||||
|
const reportCode = core.getInput('report_code');
|
||||||
const rootDir = core.getInput('root_dir');
|
const rootDir = core.getInput('root_dir');
|
||||||
const searchDir = core.getInput('directory');
|
const searchDir = core.getInput('directory');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
let uploaderVersion = core.getInput('version');
|
let uploaderVersion = core.getInput('version');
|
||||||
|
const useLegacyUploadEndpoint = isTrue(
|
||||||
|
core.getInput('use_legacy_upload_endpoint'),
|
||||||
|
);
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
const plugin = core.getInput('plugin');
|
|
||||||
const exclude = core.getInput('exclude');
|
|
||||||
|
|
||||||
const uploadExecArgs = [];
|
const uploadExecArgs = [];
|
||||||
const uploadCommand = 'do-upload';
|
const uploadCommand = 'do-upload';
|
||||||
@@ -169,21 +197,24 @@ const buildUploadExec = () => {
|
|||||||
envVarsArg.push(envVarClean);
|
envVarsArg.push(envVarClean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name) {
|
|
||||||
uploadExecArgs.push(
|
|
||||||
'-n',
|
|
||||||
`${name}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (token) {
|
if (token) {
|
||||||
uploadOptions.env.CODECOV_TOKEN = token;
|
uploadOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
}
|
||||||
|
if (disableFileFixes) {
|
||||||
|
uploadExecArgs.push('--disable-file-fixes');
|
||||||
|
}
|
||||||
|
if (disableSearch) {
|
||||||
|
uploadExecArgs.push('--disable-search');
|
||||||
|
}
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
uploadExecArgs.push('-d');
|
uploadExecArgs.push('-d');
|
||||||
}
|
}
|
||||||
if (envVarsArg.length) {
|
if (envVarsArg.length) {
|
||||||
uploadExecArgs.push('-e', envVarsArg.join(','));
|
uploadExecArgs.push('-e', envVarsArg.join(','));
|
||||||
}
|
}
|
||||||
|
if (exclude) {
|
||||||
|
uploadExecArgs.push('--exclude', `${exclude}`);
|
||||||
|
}
|
||||||
if (failCi) {
|
if (failCi) {
|
||||||
uploadExecArgs.push('-Z');
|
uploadExecArgs.push('-Z');
|
||||||
}
|
}
|
||||||
@@ -200,12 +231,24 @@ const buildUploadExec = () => {
|
|||||||
uploadExecArgs.push('-F', `${f}`);
|
uploadExecArgs.push('-F', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (handleNoReportsFound) {
|
||||||
|
uploadExecArgs.push('--handle-no-reports-found');
|
||||||
|
}
|
||||||
|
if (jobCode) {
|
||||||
|
uploadExecArgs.push('--job-code', `${jobCode}`);
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
uploadExecArgs.push('-n', `${name}`);
|
||||||
|
}
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
uploadExecArgs.push('-B', `${overrideBranch}`);
|
uploadExecArgs.push('-B', `${overrideBranch}`);
|
||||||
}
|
}
|
||||||
if (overrideBuild) {
|
if (overrideBuild) {
|
||||||
uploadExecArgs.push('-b', `${overrideBuild}`);
|
uploadExecArgs.push('-b', `${overrideBuild}`);
|
||||||
}
|
}
|
||||||
|
if (overrideBuildUrl) {
|
||||||
|
uploadExecArgs.push('--build-url', `${overrideBuildUrl}`);
|
||||||
|
}
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
uploadExecArgs.push('-C', `${overrideCommit}`);
|
uploadExecArgs.push('-C', `${overrideCommit}`);
|
||||||
} else if (
|
} else if (
|
||||||
@@ -221,11 +264,17 @@ const buildUploadExec = () => {
|
|||||||
) {
|
) {
|
||||||
uploadExecArgs.push('-P', `${context.payload.number}`);
|
uploadExecArgs.push('-P', `${context.payload.number}`);
|
||||||
}
|
}
|
||||||
|
if (plugin) {
|
||||||
|
uploadExecArgs.push('--plugin', `${plugin}`);
|
||||||
|
}
|
||||||
if (plugins) {
|
if (plugins) {
|
||||||
plugins.split(',').map((p) => p.trim()).forEach((p) => {
|
plugins.split(',').map((p) => p.trim()).forEach((p) => {
|
||||||
uploadExecArgs.push('--plugin', `${p}`);
|
uploadExecArgs.push('--plugin', `${p}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (reportCode) {
|
||||||
|
uploadExecArgs.push('--report-code', `${reportCode}`);
|
||||||
|
}
|
||||||
if (rootDir) {
|
if (rootDir) {
|
||||||
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
||||||
}
|
}
|
||||||
@@ -238,16 +287,12 @@ const buildUploadExec = () => {
|
|||||||
if (workingDir) {
|
if (workingDir) {
|
||||||
uploadOptions.cwd = workingDir;
|
uploadOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
if (plugin) {
|
|
||||||
uploadExecArgs.push('--plugin', `${plugin}`);
|
|
||||||
}
|
|
||||||
if (exclude) {
|
|
||||||
uploadExecArgs.push('--exclude', `${exclude}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uploaderVersion == '') {
|
if (uploaderVersion == '') {
|
||||||
uploaderVersion = 'latest';
|
uploaderVersion = 'latest';
|
||||||
}
|
}
|
||||||
|
if (useLegacyUploadEndpoint) {
|
||||||
|
uploadExecArgs.push('--legacy');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uploadExecArgs,
|
uploadExecArgs,
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ test('getBaseUrl', () => {
|
|||||||
'https://cli.codecov.io/latest/linux/codecov',
|
'https://cli.codecov.io/latest/linux/codecov',
|
||||||
'https://cli.codecov.io/latest/macos/codecov',
|
'https://cli.codecov.io/latest/macos/codecov',
|
||||||
'https://cli.codecov.io/latest/windows/codecov.exe',
|
'https://cli.codecov.io/latest/windows/codecov.exe',
|
||||||
|
'https://cli.codecov.io/latest/alpine/codecov',
|
||||||
|
'https://cli.codecov.io/latest/linux-arm64/codecov',
|
||||||
|
'https://cli.codecov.io/latest/alpine-arm64/codecov',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
@@ -51,19 +54,22 @@ test('getBaseUrl', () => {
|
|||||||
'https://cli.codecov.io/v0.1.0_8880/linux/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/linux/codecov',
|
||||||
'https://cli.codecov.io/v0.1.0_8880/macos/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/macos/codecov',
|
||||||
'https://cli.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
'https://cli.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
||||||
|
'https://cli.codecov.io/v0.1.0_8880/alpine/codecov',
|
||||||
|
'https://cli.codecov.io/v0.1.0_8880/linux-arm64/codecov',
|
||||||
|
'https://cli.codecov.io/v0.1.0_8880/alpine-arm64/codecov',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isWindows', () => {
|
test('isWindows', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return isWindows(platform);
|
return isWindows(platform);
|
||||||
})).toEqual([false, false, true]);
|
})).toEqual([false, false, true, false, false, false]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isValidPlatform', () => {
|
test('isValidPlatform', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return isValidPlatform(platform);
|
return isValidPlatform(platform);
|
||||||
})).toEqual([true, true, true]);
|
})).toEqual([true, true, true, true, true, true]);
|
||||||
|
|
||||||
expect(isValidPlatform('fakeos')).toBeFalsy();
|
expect(isValidPlatform('fakeos')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ const PLATFORMS = [
|
|||||||
'linux',
|
'linux',
|
||||||
'macos',
|
'macos',
|
||||||
'windows',
|
'windows',
|
||||||
|
'alpine',
|
||||||
|
'linux-arm64',
|
||||||
|
'alpine-arm64',
|
||||||
];
|
];
|
||||||
|
|
||||||
const setFailure = (message: string, failCi: boolean): void => {
|
const setFailure = (message: string, failCi: boolean): void => {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as gpg from 'gpg';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as openpgp from 'openpgp';
|
import {request} from 'undici';
|
||||||
import * as fetch from 'node-fetch';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
@@ -22,45 +22,33 @@ const verify = async (
|
|||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName(platform);
|
const uploaderName = getUploaderName(platform);
|
||||||
|
|
||||||
// Read in public key
|
|
||||||
const publicKeyArmored = await fs.readFileSync(
|
|
||||||
path.join(__dirname, 'pgp_keys.asc'),
|
|
||||||
'utf-8',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get SHASUM and SHASUM signature files
|
// Get SHASUM and SHASUM signature files
|
||||||
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
|
||||||
const shasumRes = await fetch.default(
|
const shasumRes = await request(
|
||||||
`${getBaseUrl(platform, version)}.SHA256SUM`,
|
`${getBaseUrl(platform, version)}.SHA256SUM`,
|
||||||
);
|
);
|
||||||
const shasum = await shasumRes.text();
|
const shasum = await shasumRes.body.text();
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
console.log(`Received SHA256SUM ${shasum}`);
|
console.log(`Received SHA256SUM ${shasum}`);
|
||||||
}
|
}
|
||||||
|
await fs.writeFileSync(
|
||||||
|
path.join(__dirname, `${uploaderName}.SHA256SUM`),
|
||||||
|
shasum,
|
||||||
|
);
|
||||||
|
|
||||||
const shaSigRes = await fetch.default(
|
const shaSigRes = await request(
|
||||||
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
|
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
|
||||||
);
|
);
|
||||||
const shaSig = await shaSigRes.text();
|
const shaSig = await shaSigRes.body.text();
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
console.log(`Received SHA256SUM signature ${shaSig}`);
|
console.log(`Received SHA256SUM signature ${shaSig}`);
|
||||||
}
|
}
|
||||||
|
await fs.writeFileSync(
|
||||||
// Verify shasum
|
path.join(__dirname, `${uploaderName}.SHA256SUM.sig`),
|
||||||
const verified = await openpgp.verify({
|
shaSig,
|
||||||
message: await openpgp.createMessage({text: shasum}),
|
|
||||||
signature: await openpgp.readSignature({armoredSignature: shaSig}),
|
|
||||||
verificationKeys: await openpgp.readKeys({armoredKeys: publicKeyArmored}),
|
|
||||||
});
|
|
||||||
const valid = await verified.signatures[0].verified;
|
|
||||||
if (valid) {
|
|
||||||
core.info('==> SHASUM file signed by key id ' +
|
|
||||||
verified.signatures[0].keyID.toHex(),
|
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
setFailure('Codecov: Error validating SHASUM signature', failCi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const validateSha = async () => {
|
||||||
const calculateHash = async (filename: string) => {
|
const calculateHash = async (filename: string) => {
|
||||||
const stream = fs.createReadStream(filename);
|
const stream = fs.createReadStream(filename);
|
||||||
const uploaderSha = crypto.createHash(`sha256`);
|
const uploaderSha = crypto.createHash(`sha256`);
|
||||||
@@ -74,7 +62,9 @@ const verify = async (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const hash = await calculateHash(filename);
|
const hash = await calculateHash(
|
||||||
|
path.join(__dirname, `${uploaderName}`),
|
||||||
|
);
|
||||||
if (hash === shasum) {
|
if (hash === shasum) {
|
||||||
core.info(`==> Uploader SHASUM verified (${hash})`);
|
core.info(`==> Uploader SHASUM verified (${hash})`);
|
||||||
} else {
|
} else {
|
||||||
@@ -84,6 +74,38 @@ const verify = async (
|
|||||||
failCi,
|
failCi,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const verifySignature = () => {
|
||||||
|
gpg.call('', [
|
||||||
|
'--logger-fd',
|
||||||
|
'1',
|
||||||
|
'--verify',
|
||||||
|
path.join(__dirname, `${uploaderName}.SHA256SUM.sig`),
|
||||||
|
path.join(__dirname, `${uploaderName}.SHA256SUM`),
|
||||||
|
], async (err, verifyResult) => {
|
||||||
|
if (err) {
|
||||||
|
setFailure('Codecov: Error importing pgp key', failCi);
|
||||||
|
}
|
||||||
|
core.info(verifyResult);
|
||||||
|
await validateSha();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Import gpg key
|
||||||
|
gpg.call('', [
|
||||||
|
'--logger-fd',
|
||||||
|
'1',
|
||||||
|
'--no-default-keyring',
|
||||||
|
'--import',
|
||||||
|
path.join(__dirname, 'pgp_keys.asc'),
|
||||||
|
], async (err, importResult) => {
|
||||||
|
if (err) {
|
||||||
|
setFailure('Codecov: Error importing pgp key', failCi);
|
||||||
|
}
|
||||||
|
core.info(importResult);
|
||||||
|
verifySignature();
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setFailure(`Codecov: Error validating uploader: ${err.message}`, failCi);
|
setFailure(`Codecov: Error validating uploader: ${err.message}`, failCi);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as fetch from 'node-fetch';
|
import {request} from 'undici';
|
||||||
|
|
||||||
const versionInfo = async (
|
const versionInfo = async (
|
||||||
platform: string,
|
platform: string,
|
||||||
@@ -10,10 +10,10 @@ const versionInfo = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const metadataRes = await fetch.default( `https://uploader.codecov.io/${platform}/latest`, {
|
const metadataRes = await request(`https://cli.codecov.io/${platform}/latest`, {
|
||||||
headers: {'Accept': 'application/json'},
|
headers: {'Accept': 'application/json'},
|
||||||
});
|
});
|
||||||
const metadata = await metadataRes.json();
|
const metadata = await metadataRes.body.json();
|
||||||
core.info(`==> Running version ${metadata['version']}`);
|
core.info(`==> Running version ${metadata['version']}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.info(`Could not pull latest version information: ${err}`);
|
core.info(`Could not pull latest version information: ${err}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user