mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-08 16:16:24 +00:00
Compare commits
35 Commits
v3.1.4
...
v4.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0016507ac7 | ||
|
|
c9e4b73267 | ||
|
|
c9e0f0b3cf | ||
|
|
da8479a5b3 | ||
|
|
8e29a53ea6 | ||
|
|
162bda9838 | ||
|
|
46acd9de81 | ||
|
|
904bf5a031 | ||
|
|
267c1ae7ba | ||
|
|
398b9de041 | ||
|
|
a08d532ca1 | ||
|
|
db68c7a205 | ||
|
|
7811627418 | ||
|
|
c3a18848b8 | ||
|
|
36dbb833d4 | ||
|
|
04adcebd9b | ||
|
|
836e505c14 | ||
|
|
3d80684171 | ||
|
|
0a6ec24b18 | ||
|
|
f257191299 | ||
|
|
030fc6b0c7 | ||
|
|
6991c70c83 | ||
|
|
2b88a0bb95 | ||
|
|
de1b515b0f | ||
|
|
8a36907d84 | ||
|
|
8ccb892add | ||
|
|
c17956f54f | ||
|
|
e1dd05cde2 | ||
|
|
8f4394ce71 | ||
|
|
5f0db07700 | ||
|
|
c47ccb92bf | ||
|
|
223b2a5870 | ||
|
|
dc7955ad4d | ||
|
|
5b168f78a6 | ||
|
|
6a48e74ab1 |
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@v3
|
uses: actions/checkout@v4.0.0
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2.21.5
|
||||||
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
|
uses: github/codeql-action/autobuild@v2.21.5
|
||||||
|
|
||||||
# ℹ️ 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
|
uses: github/codeql-action/analyze@v2.21.5
|
||||||
|
|||||||
14
.github/workflows/main.yml
vendored
14
.github/workflows/main.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
|||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4.0.0
|
||||||
- name: Upload coverage to Codecov (script)
|
- name: Upload coverage to Codecov (script)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -16,6 +16,7 @@ jobs:
|
|||||||
flags: script,${{ matrix.os }}
|
flags: script,${{ matrix.os }}
|
||||||
name: codecov-script
|
name: codecov-script
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
- name: Upload coverage to Codecov (demo)
|
- name: Upload coverage to Codecov (demo)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -24,6 +25,7 @@ jobs:
|
|||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
name: codecov-demo
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
- name: Upload coverage to Codecov (version)
|
- name: Upload coverage to Codecov (version)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -31,8 +33,9 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: version,${{ matrix.os }}
|
flags: version,${{ matrix.os }}
|
||||||
name: codecov-version
|
name: codecov-version
|
||||||
version: v0.1.0_8880
|
version: v0.2.0
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -40,7 +43,7 @@ jobs:
|
|||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4.0.0
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
- name: Lint
|
- name: Lint
|
||||||
@@ -54,6 +57,7 @@ jobs:
|
|||||||
flags: script,${{ matrix.os }}
|
flags: script,${{ matrix.os }}
|
||||||
name: codecov-script
|
name: codecov-script
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
- name: Upload coverage to Codecov (demo)
|
- name: Upload coverage to Codecov (demo)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -62,6 +66,7 @@ jobs:
|
|||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
name: codecov-demo
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
- name: Upload coverage to Codecov (version)
|
- name: Upload coverage to Codecov (version)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -69,5 +74,6 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: version,${{ matrix.os }}
|
flags: version,${{ matrix.os }}
|
||||||
name: codecov-version
|
name: codecov-version
|
||||||
version: v0.1.0_8880
|
version: v0.2.0
|
||||||
verbose: true
|
verbose: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
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@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0
|
uses: actions/checkout@v4.0.0 # v3.0.0
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run analysis"
|
- name: "Run analysis"
|
||||||
uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3
|
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0
|
||||||
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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
||||||
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@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
|
uses: github/codeql-action/upload-sarif@v2.21.5 # v1.0.26
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
## 4.0.0-beta.1
|
||||||
|
|
||||||
|
`v4` represents a move from the [universal uploader](https://github.com/codecov/uploader) to the [Codecov CLI](https://github.com/codecov/codecov-cli). Although this will unlock new features for our users, the CLI is not yet at feature parity with the universal uploader.
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
- No current support for `aarch64` and `alpine` architectures.
|
||||||
|
- Tokenless uploading is unsuported
|
||||||
|
- Various arguments to the Action have been removed
|
||||||
|
|
||||||
## 3.1.4
|
## 3.1.4
|
||||||
### Fixes
|
### Fixes
|
||||||
- #967 Fix typo in README.md
|
- #967 Fix typo in README.md
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -5,7 +5,15 @@
|
|||||||
[](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
|
||||||
|
|
||||||
>The latest release of this Action adds support for tokenless uploads from GitHub Actions!
|
## v4 Beta 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.
|
||||||
|
|
||||||
|
Breaking Changes
|
||||||
|
- No current support for `aarch64` and `alpine` architectures.
|
||||||
|
- Tokenless uploading is unsupported
|
||||||
|
- Various arguments to the Action have been removed
|
||||||
|
|
||||||
|
`v3` versions and below will not have access to CLI features (e.g. global upload token).
|
||||||
|
|
||||||
## ⚠️ Deprecation of v1
|
## ⚠️ Deprecation of v1
|
||||||
**As of February 1, 2022, v1 has been fully sunset and no longer functions**
|
**As of February 1, 2022, v1 has been fully sunset and no longer functions**
|
||||||
@@ -16,12 +24,6 @@ more about our deprecation plan and the new uploader on our [blog](https://about
|
|||||||
|
|
||||||
We will be restricting any updates to the `v1` Action to security updates and hotfixes.
|
We will be restricting any updates to the `v1` Action to security updates and hotfixes.
|
||||||
|
|
||||||
### Migration from `v1` to `v3`
|
|
||||||
The `v3` uploader has a few breaking changes for users
|
|
||||||
- Multiple fields have not been transferred from the bash uploader or have been deprecated. Notably
|
|
||||||
many of the `functionalities` and `gcov_` arguments have been removed. Please check the documentation
|
|
||||||
below for the full list.
|
|
||||||
|
|
||||||
## 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 (`@v3` is recommended) as a `step` within your `workflow.yml` file.
|
||||||
|
|||||||
58
action.yml
58
action.yml
@@ -17,12 +17,6 @@ inputs:
|
|||||||
flags:
|
flags:
|
||||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||||
required: false
|
required: false
|
||||||
full_report:
|
|
||||||
description: Specify the path of a full Codecov report to re-upload
|
|
||||||
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
|
|
||||||
dry_run:
|
dry_run:
|
||||||
description: "Don't upload files to Codecov"
|
description: "Don't upload files to Codecov"
|
||||||
required: false
|
required: false
|
||||||
@@ -32,38 +26,14 @@ inputs:
|
|||||||
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
|
||||||
functionalities:
|
|
||||||
description: 'Comma-separated list, see the README for options and their usage. Options include `network`, `fixes`, `search`.'
|
|
||||||
required: false
|
|
||||||
gcov:
|
gcov:
|
||||||
description: 'Run with gcov support'
|
description: 'Run with gcov support'
|
||||||
required: false
|
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_ignore:
|
|
||||||
description: 'Paths to ignore during gcov gathering'
|
|
||||||
required: false
|
|
||||||
gcov_include:
|
|
||||||
description: 'Paths to include during gcov gathering'
|
|
||||||
required: false
|
|
||||||
move_coverage_to_trash:
|
|
||||||
description: 'Move discovered coverage reports to the trash'
|
|
||||||
required: false
|
|
||||||
name:
|
name:
|
||||||
description: 'User defined upload name. Visible in Codecov UI'
|
description: 'User defined upload name. Visible in Codecov UI'
|
||||||
required: false
|
required: false
|
||||||
network_filter:
|
|
||||||
description: 'Specify a filter on the files listed in the network section of the Codecov report. Useful for upload-specific path fixing'
|
|
||||||
required: false
|
|
||||||
network_prefix:
|
|
||||||
description: 'Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing'
|
|
||||||
required: false
|
|
||||||
os:
|
os:
|
||||||
description: 'Override the assumed OS. Options are aarch64 | alpine | linux | macos | windows.'
|
description: 'Override the assumed OS. Options are linux | macos | windows.'
|
||||||
required: false
|
required: false
|
||||||
override_branch:
|
override_branch:
|
||||||
description: 'Specify the branch name'
|
description: 'Specify the branch name'
|
||||||
@@ -77,45 +47,21 @@ inputs:
|
|||||||
override_pr:
|
override_pr:
|
||||||
description: 'Specify the pull request number'
|
description: 'Specify the pull request number'
|
||||||
required: false
|
required: false
|
||||||
override_tag:
|
|
||||||
description: 'Specify the git tag'
|
|
||||||
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
|
||||||
swift:
|
|
||||||
description: 'Run with swift coverage support'
|
|
||||||
required: false
|
|
||||||
swift_project:
|
|
||||||
description: 'Specify the swift project to speed up coverage conversion'
|
|
||||||
required: false
|
|
||||||
upstream_proxy:
|
|
||||||
description: 'The upstream http proxy server to connect through'
|
|
||||||
required: false
|
|
||||||
url:
|
|
||||||
description: 'Change the upload host (Enterprise use)'
|
|
||||||
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
|
||||||
version:
|
version:
|
||||||
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
|
description: 'Specify which version of the Codecov CLI should be used. Defaults to `latest`'
|
||||||
required: false
|
required: false
|
||||||
working-directory:
|
working-directory:
|
||||||
description: 'Directory in which to execute codecov.sh'
|
description: 'Directory in which to execute codecov.sh'
|
||||||
required: false
|
required: false
|
||||||
xcode:
|
|
||||||
description: 'Run with xcode support'
|
|
||||||
required: false
|
|
||||||
xcode_archive_path:
|
|
||||||
description: 'Specify the xcode archive path. Likely specified as the -resultBundlePath and should end in .xcresult'
|
|
||||||
required: false
|
|
||||||
xtra_args:
|
|
||||||
description: 'Add additional uploader args that may be missing in the Action'
|
|
||||||
required: false
|
|
||||||
branding:
|
branding:
|
||||||
color: 'red'
|
color: 'red'
|
||||||
icon: 'umbrella'
|
icon: 'umbrella'
|
||||||
|
|||||||
291
dist/index.js
vendored
291
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
10759
package-lock.json
generated
10759
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "3.1.4",
|
"version": "4.0.0-beta.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": {
|
||||||
@@ -23,23 +23,23 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/codecov/codecov-action#readme",
|
"homepage": "https://github.com/codecov/codecov-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^5.1.1",
|
"@actions/github": "^5.1.1",
|
||||||
"node-fetch": "^3.3.1",
|
"node-fetch": "^3.3.2",
|
||||||
"openpgp": "5.8"
|
"openpgp": "5.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.5.0",
|
"@types/jest": "^29.5.4",
|
||||||
"@types/node": "^20.1.4",
|
"@types/node": "^20.6.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.29.2",
|
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
||||||
"@typescript-eslint/parser": "^4.29.2",
|
"@typescript-eslint/parser": "^6.7.0",
|
||||||
"@vercel/ncc": "^0.36.1",
|
"@vercel/ncc": "^0.38.0",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^8.49.0",
|
||||||
"eslint-config-google": "^0.14.0",
|
"eslint-config-google": "^0.14.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^29.6.4",
|
||||||
"jest-junit": "^16.0.0",
|
"jest-junit": "^16.0.0",
|
||||||
"ts-jest": "^26.5.6",
|
"ts-jest": "^29.1.1",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^5.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,58 @@
|
|||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
|
||||||
import buildExec from './buildExec';
|
import {
|
||||||
|
buildCommitExec,
|
||||||
|
buildGeneralExec,
|
||||||
|
buildReportExec,
|
||||||
|
buildUploadExec,
|
||||||
|
} from './buildExec';
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
||||||
const {version} = require('../package.json');
|
|
||||||
|
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
|
||||||
test('no arguments', () => {
|
test('general args', () => {
|
||||||
const {execArgs, failCi} = buildExec();
|
const envs = {
|
||||||
|
url: 'https://codecov.enterprise.com',
|
||||||
const args = [
|
verbose: 't',
|
||||||
'-n',
|
};
|
||||||
'',
|
for (const env of Object.keys(envs)) {
|
||||||
'-Q',
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
`github-action-${version}`,
|
}
|
||||||
];
|
|
||||||
if (context.eventName == 'pull_request') {
|
const {args, verbose} = buildGeneralExec();
|
||||||
args.push('-C', `${context.payload.pull_request.head.sha}`);
|
|
||||||
|
expect(args).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
'--enterprise-url',
|
||||||
|
'https://codecov.enterprise.com',
|
||||||
|
'-v',
|
||||||
|
]));
|
||||||
|
expect(verbose).toBeTruthy();
|
||||||
|
for (const env of Object.keys(envs)) {
|
||||||
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
}
|
}
|
||||||
expect(execArgs).toEqual(args);
|
|
||||||
expect(failCi).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('all arguments', () => {
|
|
||||||
|
test('upload args using context', () => {
|
||||||
|
const expectedArgs = [
|
||||||
|
'-n',
|
||||||
|
'',
|
||||||
|
];
|
||||||
|
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
||||||
|
if (context.eventName == 'pull_request') {
|
||||||
|
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
|
}
|
||||||
|
if (context.eventName == 'pull_request_target') {
|
||||||
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(uploadExecArgs).toEqual(expectedArgs);
|
||||||
|
expect(uploadCommand).toEqual('do-upload');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('upload args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
'commit_parent': '83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
'directory': 'coverage/',
|
'directory': 'coverage/',
|
||||||
'dry_run': 'true',
|
'dry_run': 'true',
|
||||||
'env_vars': 'OS,PYTHON',
|
'env_vars': 'OS,PYTHON',
|
||||||
@@ -33,53 +60,29 @@ test('all arguments', () => {
|
|||||||
'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',
|
||||||
'functionalities': 'network',
|
|
||||||
'full_report': 'oldDir/oldReport.json',
|
|
||||||
'gcov': 'true',
|
|
||||||
'gcov_args': '-v',
|
|
||||||
'gcov_ignore': '*.fake',
|
|
||||||
'gcov_include': 'real_file',
|
|
||||||
'gcov_executable': 'gcov2',
|
|
||||||
'move_coverage_to_trash': 'true',
|
|
||||||
'name': 'codecov',
|
'name': 'codecov',
|
||||||
'network_filter': 'src/',
|
|
||||||
'network_prefix': 'build/',
|
|
||||||
'override_branch': 'thomasrockhu/test',
|
'override_branch': 'thomasrockhu/test',
|
||||||
'override_build': '1',
|
'override_build': '1',
|
||||||
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'override_pr': '2',
|
'override_pr': '2',
|
||||||
'override_tag': 'v1.2',
|
|
||||||
'root_dir': 'root/',
|
'root_dir': 'root/',
|
||||||
'swift': 'true',
|
|
||||||
'swift_project': 'MyApp',
|
|
||||||
'slug': 'fakeOwner/fakeRepo',
|
'slug': 'fakeOwner/fakeRepo',
|
||||||
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
'upstream_proxy': 'https://codecov.example.com',
|
'working-directory': 'src',
|
||||||
'url': 'https://codecov.enterprise.com',
|
'plugin': 'xcode',
|
||||||
'verbose': 't',
|
'exclude': 'src',
|
||||||
'xcode': 'true',
|
|
||||||
'xcode_archive_path': '/test.xcresult',
|
|
||||||
'xtra_args': '--some --other --args',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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 {execArgs, failCi} = buildExec();
|
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
||||||
expect(execArgs).toEqual([
|
const expectedArgs = [
|
||||||
'-n',
|
'-n',
|
||||||
'codecov',
|
'codecov',
|
||||||
'-Q',
|
|
||||||
`github-action-${version}`,
|
|
||||||
'-c',
|
|
||||||
'-N',
|
|
||||||
'83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
'-d',
|
'-d',
|
||||||
'-e',
|
'-e',
|
||||||
'OS,PYTHON',
|
'OS,PYTHON',
|
||||||
'-X',
|
|
||||||
'network',
|
|
||||||
'-Z',
|
'-Z',
|
||||||
'-f',
|
'-f',
|
||||||
'coverage.xml',
|
'coverage.xml',
|
||||||
@@ -87,25 +90,10 @@ test('all arguments', () => {
|
|||||||
'dir1/coverage.xml',
|
'dir1/coverage.xml',
|
||||||
'-f',
|
'-f',
|
||||||
'dir2/coverage.xml',
|
'dir2/coverage.xml',
|
||||||
'--full',
|
|
||||||
'oldDir/oldReport.json',
|
|
||||||
'-F',
|
'-F',
|
||||||
'test',
|
'test',
|
||||||
'-F',
|
'-F',
|
||||||
'test2',
|
'test2',
|
||||||
'-g',
|
|
||||||
'--ga',
|
|
||||||
'-v',
|
|
||||||
'--gi',
|
|
||||||
'*.fake',
|
|
||||||
'--gI',
|
|
||||||
'real_file',
|
|
||||||
'--gx',
|
|
||||||
'gcov2',
|
|
||||||
'-i',
|
|
||||||
'src/',
|
|
||||||
'-k',
|
|
||||||
'build/',
|
|
||||||
'-B',
|
'-B',
|
||||||
'thomasrockhu/test',
|
'thomasrockhu/test',
|
||||||
'-b',
|
'-b',
|
||||||
@@ -114,111 +102,119 @@ test('all arguments', () => {
|
|||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'-P',
|
'-P',
|
||||||
'2',
|
'2',
|
||||||
'-T',
|
'--network-root-folder',
|
||||||
'v1.2',
|
|
||||||
'-R',
|
|
||||||
'root/',
|
'root/',
|
||||||
'-s',
|
'-s',
|
||||||
'coverage/',
|
'coverage/',
|
||||||
'-r',
|
'-r',
|
||||||
'fakeOwner/fakeRepo',
|
'fakeOwner/fakeRepo',
|
||||||
'--xs',
|
'--plugin',
|
||||||
'--xsp',
|
'xcode',
|
||||||
'MyApp',
|
'--exclude',
|
||||||
'-U',
|
'src',
|
||||||
'https://codecov.example.com',
|
];
|
||||||
'-u',
|
|
||||||
'https://codecov.enterprise.com',
|
|
||||||
'-v',
|
|
||||||
'--xc',
|
|
||||||
'--xp',
|
|
||||||
'/test.xcresult',
|
|
||||||
'--some --other --args',
|
|
||||||
]);
|
|
||||||
expect(failCi).toBeTruthy();
|
|
||||||
|
|
||||||
|
expect(uploadExecArgs).toEqual(expectedArgs);
|
||||||
|
expect(uploadCommand).toEqual('do-upload');
|
||||||
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()];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('trim arguments after splitting them', () => {
|
|
||||||
const baseExpectation = [
|
|
||||||
'-n',
|
|
||||||
expect.stringContaining(''),
|
|
||||||
'-Q',
|
|
||||||
expect.stringContaining('github-action'),
|
|
||||||
];
|
|
||||||
|
|
||||||
test('files', () => {
|
test('report args', () => {
|
||||||
const envs = {'files': './client-coverage.txt, ./lcov.info'};
|
const envs = {
|
||||||
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
slug: 'fakeOwner/fakeRepo',
|
||||||
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
};
|
||||||
|
for (const env of Object.keys(envs)) {
|
||||||
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
|
}
|
||||||
|
|
||||||
for (const [name, value] of Object.entries(envs)) {
|
const {reportExecArgs, reportCommand} = buildReportExec();
|
||||||
process.env['INPUT_' + name.toUpperCase()] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {execArgs} = buildExec();
|
expect(reportExecArgs).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
expect(execArgs).toEqual(
|
'-C',
|
||||||
expect.arrayContaining([
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
...baseExpectation,
|
'--slug',
|
||||||
'-f',
|
'fakeOwner/fakeRepo',
|
||||||
'./client-coverage.txt',
|
]));
|
||||||
'-f',
|
expect(reportCommand).toEqual('create-report');
|
||||||
'./lcov.info',
|
for (const env of Object.keys(envs)) {
|
||||||
]),
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
);
|
}
|
||||||
|
});
|
||||||
for (const env of Object.keys(envs)) {
|
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
|
||||||
}
|
test('report args using context', () => {
|
||||||
});
|
const envs = {
|
||||||
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
test('flags', () => {
|
};
|
||||||
const envs = {'flags': 'ios, mobile'};
|
for (const env of Object.keys(envs)) {
|
||||||
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
for (const [name, value] of Object.entries(envs)) {
|
}
|
||||||
process.env['INPUT_' + name.toUpperCase()] = value;
|
const expectedArgs : string[] = [];
|
||||||
}
|
if (context.eventName == 'pull_request') {
|
||||||
|
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
const {execArgs} = buildExec();
|
}
|
||||||
|
|
||||||
expect(execArgs).toEqual(
|
const {reportExecArgs, reportCommand} = buildReportExec();
|
||||||
expect.arrayContaining([
|
|
||||||
...baseExpectation,
|
expect(reportExecArgs).toEqual(expectedArgs);
|
||||||
'-F',
|
expect(reportCommand).toEqual('create-report');
|
||||||
'ios',
|
for (const env of Object.keys(envs)) {
|
||||||
'-F',
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
'mobile',
|
}
|
||||||
]),
|
});
|
||||||
);
|
|
||||||
|
|
||||||
for (const env of Object.keys(envs)) {
|
test('commit args', () => {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
const envs = {
|
||||||
}
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
});
|
slug: 'fakeOwner/fakeRepo',
|
||||||
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
test('functionalities', () => {
|
override_branch: 'thomasrockhu/test',
|
||||||
const envs = {'functionalities': 'network, gcov'};
|
override_pr: '2',
|
||||||
|
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
||||||
for (const [name, value] of Object.entries(envs)) {
|
};
|
||||||
process.env['INPUT_' + name.toUpperCase()] = value;
|
for (const env of Object.keys(envs)) {
|
||||||
}
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
|
}
|
||||||
const {execArgs} = buildExec();
|
|
||||||
|
const {commitExecArgs, commitCommand} = buildCommitExec();
|
||||||
expect(execArgs).toEqual(
|
|
||||||
expect.arrayContaining([
|
expect(commitExecArgs).toEqual(
|
||||||
...baseExpectation,
|
expect.arrayContaining([
|
||||||
'-X',
|
'-C',
|
||||||
'network',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'-X',
|
'--slug',
|
||||||
'gcov',
|
'fakeOwner/fakeRepo',
|
||||||
]),
|
'-B',
|
||||||
);
|
'thomasrockhu/test',
|
||||||
|
'--pr',
|
||||||
for (const env of Object.keys(envs)) {
|
'2',
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
'--parent-sha',
|
||||||
}
|
'83231650328f11695dfb754ca0f540516f188d27',
|
||||||
});
|
]));
|
||||||
|
expect(commitCommand).toEqual('create-commit');
|
||||||
|
for (const env of Object.keys(envs)) {
|
||||||
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('commit args using context', () => {
|
||||||
|
const expectedArgs :string[] = [];
|
||||||
|
|
||||||
|
const {commitExecArgs, commitCommand} = buildCommitExec();
|
||||||
|
if (context.eventName == 'pull_request') {
|
||||||
|
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
|
}
|
||||||
|
if (context.eventName == 'pull_request_target') {
|
||||||
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
|
expect(commitCommand).toEqual('create-commit');
|
||||||
});
|
});
|
||||||
|
|||||||
276
src/buildExec.ts
276
src/buildExec.ts
@@ -1,7 +1,8 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
|
||||||
import {version} from '../package.json';
|
|
||||||
|
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
|
||||||
@@ -16,56 +17,145 @@ const isTrue = (variable) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildExec = () => {
|
|
||||||
const clean = core.getInput('move_coverage_to_trash');
|
const buildCommitExec = () => {
|
||||||
const commitParent = core.getInput('commit_parent');
|
const commitParent = core.getInput('commit_parent');
|
||||||
const dryRun = isTrue(core.getInput('dry_run'));
|
const overrideBranch = core.getInput('override_branch');
|
||||||
|
const overrideCommit = core.getInput('override_commit');
|
||||||
|
const overridePr = core.getInput('override_pr');
|
||||||
|
const slug = core.getInput('slug');
|
||||||
|
const token = core.getInput('token');
|
||||||
|
|
||||||
|
|
||||||
|
const commitCommand = 'create-commit';
|
||||||
|
const commitExecArgs = [];
|
||||||
|
|
||||||
|
const commitOptions:any = {};
|
||||||
|
commitOptions.env = Object.assign(process.env, {
|
||||||
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
|
GITHUB_REF: process.env.GITHUB_REF,
|
||||||
|
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||||
|
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||||
|
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
commitOptions.env.CODECOV_TOKEN = token;
|
||||||
|
}
|
||||||
|
if (commitParent) {
|
||||||
|
commitExecArgs.push('--parent-sha', `${commitParent}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overrideBranch) {
|
||||||
|
commitExecArgs.push('-B', `${overrideBranch}`);
|
||||||
|
}
|
||||||
|
if (overrideCommit) {
|
||||||
|
commitExecArgs.push('-C', `${overrideCommit}`);
|
||||||
|
} else if (
|
||||||
|
`${context.eventName}` == 'pull_request' ||
|
||||||
|
`${context.eventName}` == 'pull_request_target'
|
||||||
|
) {
|
||||||
|
commitExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
|
}
|
||||||
|
if (overridePr) {
|
||||||
|
commitExecArgs.push('--pr', `${overridePr}`);
|
||||||
|
} else if (
|
||||||
|
`${context.eventName}` == 'pull_request_target'
|
||||||
|
) {
|
||||||
|
commitExecArgs.push('--pr', `${context.payload.number}`);
|
||||||
|
}
|
||||||
|
if (slug) {
|
||||||
|
commitExecArgs.push('--slug', `${slug}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return {commitExecArgs, commitOptions, commitCommand};
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildGeneralExec = () => {
|
||||||
|
const url = core.getInput('url');
|
||||||
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
|
const args = [];
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
args.push('--enterprise-url', `${url}`);
|
||||||
|
}
|
||||||
|
if (verbose) {
|
||||||
|
args.push('-v');
|
||||||
|
}
|
||||||
|
return {args, verbose};
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildReportExec = () => {
|
||||||
|
const overrideCommit = core.getInput('override_commit');
|
||||||
|
const slug = core.getInput('slug');
|
||||||
|
const token = core.getInput('token');
|
||||||
|
|
||||||
|
|
||||||
|
const reportCommand = 'create-report';
|
||||||
|
const reportExecArgs = [];
|
||||||
|
|
||||||
|
const reportOptions:any = {};
|
||||||
|
reportOptions.env = Object.assign(process.env, {
|
||||||
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
|
GITHUB_REF: process.env.GITHUB_REF,
|
||||||
|
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||||
|
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||||
|
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '',
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
reportOptions.env.CODECOV_TOKEN = token;
|
||||||
|
}
|
||||||
|
if (overrideCommit) {
|
||||||
|
reportExecArgs.push('-C', `${overrideCommit}`);
|
||||||
|
} else if (
|
||||||
|
`${context.eventName}` == 'pull_request' ||
|
||||||
|
`${context.eventName}` == 'pull_request_target'
|
||||||
|
) {
|
||||||
|
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
|
}
|
||||||
|
if (slug) {
|
||||||
|
reportExecArgs.push('--slug', `${slug}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {reportExecArgs, reportOptions, reportCommand};
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildUploadExec = () => {
|
||||||
const envVars = core.getInput('env_vars');
|
const envVars = core.getInput('env_vars');
|
||||||
|
const dryRun = isTrue(core.getInput('dry_run'));
|
||||||
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 fullReport = core.getInput('full_report');
|
|
||||||
const functionalities = core.getInput('functionalities');
|
|
||||||
const gcov = core.getInput('gcov');
|
|
||||||
const gcovArgs = core.getInput('gcov_args');
|
|
||||||
const gcovExecutable = core.getInput('gcov_executable');
|
|
||||||
const gcovIgnore = core.getInput('gcov_ignore');
|
|
||||||
const gcovInclude = core.getInput('gcov_include');
|
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
const networkFilter = core.getInput('network_filter');
|
|
||||||
const networkPrefix = core.getInput('network_prefix');
|
|
||||||
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 overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const overrideTag = core.getInput('override_tag');
|
|
||||||
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 swift = core.getInput('swift');
|
|
||||||
const swiftProject = core.getInput('swift_project');
|
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const upstream = core.getInput('upstream_proxy');
|
|
||||||
const url = core.getInput('url');
|
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
|
||||||
const workingDir = core.getInput('working-directory');
|
|
||||||
const xcode = core.getInput('xcode');
|
|
||||||
const xcodeArchivePath = core.getInput('xcode_archive_path');
|
|
||||||
const xtraArgs = core.getInput('xtra_args');
|
|
||||||
let uploaderVersion = core.getInput('version');
|
let uploaderVersion = core.getInput('version');
|
||||||
|
const workingDir = core.getInput('working-directory');
|
||||||
|
const plugin = core.getInput('plugin');
|
||||||
|
const exclude = core.getInput('exclude');
|
||||||
|
|
||||||
const execArgs = [];
|
const uploadExecArgs = [];
|
||||||
execArgs.push(
|
uploadExecArgs.push(
|
||||||
'-n',
|
'-n',
|
||||||
`${name}`,
|
`${name}`,
|
||||||
'-Q',
|
|
||||||
`github-action-${version}`,
|
|
||||||
);
|
);
|
||||||
|
const uploadCommand = 'do-upload';
|
||||||
const options:any = {};
|
const uploadOptions:any = {};
|
||||||
options.env = Object.assign(process.env, {
|
uploadOptions.env = Object.assign(process.env, {
|
||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
GITHUB_REF: process.env.GITHUB_REF,
|
GITHUB_REF: process.env.GITHUB_REF,
|
||||||
@@ -78,144 +168,94 @@ const buildExec = () => {
|
|||||||
for (const envVar of envVars.split(',')) {
|
for (const envVar of envVars.split(',')) {
|
||||||
const envVarClean = envVar.trim();
|
const envVarClean = envVar.trim();
|
||||||
if (envVarClean) {
|
if (envVarClean) {
|
||||||
options.env[envVarClean] = process.env[envVarClean];
|
uploadOptions.env[envVarClean] = process.env[envVarClean];
|
||||||
envVarsArg.push(envVarClean);
|
envVarsArg.push(envVarClean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
options.env.CODECOV_TOKEN = token;
|
uploadOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
|
||||||
if (clean) {
|
|
||||||
execArgs.push('-c');
|
|
||||||
}
|
|
||||||
if (commitParent) {
|
|
||||||
execArgs.push('-N', `${commitParent}`);
|
|
||||||
}
|
}
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
execArgs.push('-d');
|
uploadExecArgs.push('-d');
|
||||||
}
|
}
|
||||||
if (envVarsArg.length) {
|
if (envVarsArg.length) {
|
||||||
execArgs.push('-e', envVarsArg.join(','));
|
uploadExecArgs.push('-e', envVarsArg.join(','));
|
||||||
}
|
|
||||||
if (functionalities) {
|
|
||||||
functionalities.split(',').map((f) => f.trim()).forEach((f) => {
|
|
||||||
execArgs.push('-X', `${f}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (failCi) {
|
if (failCi) {
|
||||||
execArgs.push('-Z');
|
uploadExecArgs.push('-Z');
|
||||||
}
|
}
|
||||||
if (file) {
|
if (file) {
|
||||||
execArgs.push('-f', `${file}`);
|
uploadExecArgs.push('-f', `${file}`);
|
||||||
}
|
}
|
||||||
if (files) {
|
if (files) {
|
||||||
files.split(',').map((f) => f.trim()).forEach((f) => {
|
files.split(',').map((f) => f.trim()).forEach((f) => {
|
||||||
execArgs.push('-f', `${f}`);
|
uploadExecArgs.push('-f', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (fullReport) {
|
|
||||||
execArgs.push('--full', `${fullReport}`);
|
|
||||||
}
|
|
||||||
if (flags) {
|
if (flags) {
|
||||||
flags.split(',').map((f) => f.trim()).forEach((f) => {
|
flags.split(',').map((f) => f.trim()).forEach((f) => {
|
||||||
execArgs.push('-F', `${f}`);
|
uploadExecArgs.push('-F', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gcov) {
|
|
||||||
execArgs.push('-g');
|
|
||||||
}
|
|
||||||
if (gcovArgs) {
|
|
||||||
execArgs.push('--ga', `${gcovArgs}`);
|
|
||||||
}
|
|
||||||
if (gcovIgnore) {
|
|
||||||
execArgs.push('--gi', `${gcovIgnore}`);
|
|
||||||
}
|
|
||||||
if (gcovInclude) {
|
|
||||||
execArgs.push('--gI', `${gcovInclude}`);
|
|
||||||
}
|
|
||||||
if (gcovExecutable) {
|
|
||||||
execArgs.push('--gx', `${gcovExecutable}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (networkFilter) {
|
|
||||||
execArgs.push('-i', `${networkFilter}`);
|
|
||||||
}
|
|
||||||
if (networkPrefix) {
|
|
||||||
execArgs.push('-k', `${networkPrefix}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
execArgs.push('-B', `${overrideBranch}`);
|
uploadExecArgs.push('-B', `${overrideBranch}`);
|
||||||
}
|
}
|
||||||
if (overrideBuild) {
|
if (overrideBuild) {
|
||||||
execArgs.push('-b', `${overrideBuild}`);
|
uploadExecArgs.push('-b', `${overrideBuild}`);
|
||||||
}
|
}
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
execArgs.push('-C', `${overrideCommit}`);
|
uploadExecArgs.push('-C', `${overrideCommit}`);
|
||||||
} else if (
|
} else if (
|
||||||
`${context.eventName}` == 'pull_request' ||
|
`${context.eventName}` == 'pull_request' ||
|
||||||
`${context.eventName}` == 'pull_request_target'
|
`${context.eventName}` == 'pull_request_target'
|
||||||
) {
|
) {
|
||||||
execArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
uploadExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
}
|
}
|
||||||
if (overridePr) {
|
if (overridePr) {
|
||||||
execArgs.push('-P', `${overridePr}`);
|
uploadExecArgs.push('-P', `${overridePr}`);
|
||||||
} else if (
|
} else if (
|
||||||
`${context.eventName}` == 'pull_request_target'
|
`${context.eventName}` == 'pull_request_target'
|
||||||
) {
|
) {
|
||||||
execArgs.push('-P', `${context.payload.number}`);
|
uploadExecArgs.push('-P', `${context.payload.number}`);
|
||||||
}
|
|
||||||
if (overrideTag) {
|
|
||||||
execArgs.push('-T', `${overrideTag}`);
|
|
||||||
}
|
}
|
||||||
if (rootDir) {
|
if (rootDir) {
|
||||||
execArgs.push('-R', `${rootDir}`);
|
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
||||||
}
|
}
|
||||||
if (searchDir) {
|
if (searchDir) {
|
||||||
execArgs.push('-s', `${searchDir}`);
|
uploadExecArgs.push('-s', `${searchDir}`);
|
||||||
}
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
execArgs.push('-r', `${slug}`);
|
uploadExecArgs.push('-r', `${slug}`);
|
||||||
}
|
}
|
||||||
if (swift) {
|
if (workingDir) {
|
||||||
execArgs.push('--xs');
|
uploadOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
if (swift && swiftProject) {
|
if (plugin) {
|
||||||
execArgs.push('--xsp', `${swiftProject}`);
|
uploadExecArgs.push('--plugin', `${plugin}`);
|
||||||
}
|
}
|
||||||
if (upstream) {
|
if (exclude) {
|
||||||
execArgs.push('-U', `${upstream}`);
|
uploadExecArgs.push('--exclude', `${exclude}`);
|
||||||
}
|
|
||||||
if (url) {
|
|
||||||
execArgs.push('-u', `${url}`);
|
|
||||||
}
|
|
||||||
if (verbose) {
|
|
||||||
execArgs.push('-v');
|
|
||||||
}
|
|
||||||
if (xcode && xcodeArchivePath) {
|
|
||||||
execArgs.push('--xc');
|
|
||||||
execArgs.push('--xp', `${xcodeArchivePath}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uploaderVersion == '') {
|
if (uploaderVersion == '') {
|
||||||
uploaderVersion = 'latest';
|
uploaderVersion = 'latest';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) {
|
return {
|
||||||
console.debug({execArgs});
|
uploadExecArgs,
|
||||||
}
|
uploadOptions,
|
||||||
|
failCi,
|
||||||
if (workingDir) {
|
os,
|
||||||
options.cwd = workingDir;
|
uploaderVersion,
|
||||||
}
|
uploadCommand,
|
||||||
|
};
|
||||||
if (xtraArgs) {
|
|
||||||
execArgs.push(`${xtraArgs}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {execArgs, options, failCi, os, uploaderVersion, verbose};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildExec;
|
|
||||||
|
export {
|
||||||
|
buildCommitExec,
|
||||||
|
buildGeneralExec,
|
||||||
|
buildReportExec,
|
||||||
|
buildUploadExec,
|
||||||
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
isWindows,
|
isWindows,
|
||||||
PLATFORMS,
|
PLATFORMS,
|
||||||
|
getCommand,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
let OLDOS = process.env.RUNNER_OS;
|
let OLDOS = process.env.RUNNER_OS;
|
||||||
@@ -39,34 +40,35 @@ test('getBaseUrl', () => {
|
|||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return getBaseUrl(platform, 'latest');
|
return getBaseUrl(platform, 'latest');
|
||||||
})).toEqual([
|
})).toEqual([
|
||||||
'https://uploader.codecov.io/latest/aarch64/codecov',
|
'https://cli.codecov.io/latest/linux/codecov',
|
||||||
'https://uploader.codecov.io/latest/alpine/codecov',
|
'https://cli.codecov.io/latest/macos/codecov',
|
||||||
'https://uploader.codecov.io/latest/linux/codecov',
|
'https://cli.codecov.io/latest/windows/codecov.exe',
|
||||||
'https://uploader.codecov.io/latest/macos/codecov',
|
|
||||||
'https://uploader.codecov.io/latest/windows/codecov.exe',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return getBaseUrl(platform, 'v0.1.0_8880');
|
return getBaseUrl(platform, 'v0.1.0_8880');
|
||||||
})).toEqual([
|
})).toEqual([
|
||||||
'https://uploader.codecov.io/v0.1.0_8880/aarch64/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/linux/codecov',
|
||||||
'https://uploader.codecov.io/v0.1.0_8880/alpine/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/macos/codecov',
|
||||||
'https://uploader.codecov.io/v0.1.0_8880/linux/codecov',
|
'https://cli.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
||||||
'https://uploader.codecov.io/v0.1.0_8880/macos/codecov',
|
|
||||||
'https://uploader.codecov.io/v0.1.0_8880/windows/codecov.exe',
|
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isWindows', () => {
|
test('isWindows', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return isWindows(platform);
|
return isWindows(platform);
|
||||||
})).toEqual([false, false, false, false, true]);
|
})).toEqual([false, false, true]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('isValidPlatform', () => {
|
test('isValidPlatform', () => {
|
||||||
expect(PLATFORMS.map((platform) => {
|
expect(PLATFORMS.map((platform) => {
|
||||||
return isValidPlatform(platform);
|
return isValidPlatform(platform);
|
||||||
})).toEqual([true, true, true, true, true]);
|
})).toEqual([true, true, true]);
|
||||||
|
|
||||||
expect(isValidPlatform('fakeos')).toBeFalsy();
|
expect(isValidPlatform('fakeos')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getCommand', () => {
|
||||||
|
expect(getCommand('path', ['-v', '-x'], 'do-upload'))
|
||||||
|
.toEqual(['path', '-v', '-x', 'do-upload']);
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
const PLATFORMS = [
|
const PLATFORMS = [
|
||||||
'aarch64',
|
|
||||||
'alpine',
|
|
||||||
'linux',
|
'linux',
|
||||||
'macos',
|
'macos',
|
||||||
'windows',
|
'windows',
|
||||||
@@ -50,7 +48,17 @@ const getPlatform = (os?: string): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getBaseUrl = (platform: string, version: string): string => {
|
const getBaseUrl = (platform: string, version: string): string => {
|
||||||
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
return `https://cli.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCommand = (
|
||||||
|
filename: string,
|
||||||
|
generalArgs:string[],
|
||||||
|
command: string,
|
||||||
|
): string[] => {
|
||||||
|
const fullCommand = [filename, ...generalArgs, command];
|
||||||
|
core.info(`==> Running command '${fullCommand.join(' ')}'`);
|
||||||
|
return fullCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@@ -61,4 +69,5 @@ export {
|
|||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
isWindows,
|
isWindows,
|
||||||
setFailure,
|
setFailure,
|
||||||
|
getCommand,
|
||||||
};
|
};
|
||||||
|
|||||||
69
src/index.ts
69
src/index.ts
@@ -4,12 +4,18 @@ import * as path from 'path';
|
|||||||
|
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
import buildExec from './buildExec';
|
import {
|
||||||
|
buildCommitExec,
|
||||||
|
buildGeneralExec,
|
||||||
|
buildReportExec,
|
||||||
|
buildUploadExec,
|
||||||
|
} from './buildExec';
|
||||||
import {
|
import {
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
setFailure,
|
setFailure,
|
||||||
|
getCommand,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
import verify from './validate';
|
import verify from './validate';
|
||||||
@@ -18,7 +24,18 @@ import versionInfo from './version';
|
|||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {execArgs, options, failCi, os, uploaderVersion, verbose} = buildExec();
|
const {commitExecArgs, commitOptions, commitCommand} = buildCommitExec();
|
||||||
|
const {reportExecArgs, reportOptions, reportCommand} = buildReportExec();
|
||||||
|
const {
|
||||||
|
uploadExecArgs,
|
||||||
|
uploadOptions,
|
||||||
|
failCi,
|
||||||
|
os,
|
||||||
|
uploaderVersion,
|
||||||
|
uploadCommand,
|
||||||
|
} = buildUploadExec();
|
||||||
|
const {args, verbose} = buildGeneralExec();
|
||||||
|
|
||||||
const platform = getPlatform(os);
|
const platform = getPlatform(os);
|
||||||
|
|
||||||
const filename = path.join( __dirname, getUploaderName(platform));
|
const filename = path.join( __dirname, getUploaderName(platform));
|
||||||
@@ -49,14 +66,52 @@ try {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
await exec.exec(filename, execArgs, options)
|
const doUpload = async () => {
|
||||||
.catch((err) => {
|
await exec.exec(getCommand(filename, args, uploadCommand).join(' '),
|
||||||
|
uploadExecArgs,
|
||||||
|
uploadOptions)
|
||||||
|
.catch((err) => {
|
||||||
|
setFailure(
|
||||||
|
`Codecov:
|
||||||
|
Failed to properly upload report: ${err.message}`,
|
||||||
|
failCi,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const createReport = async () => {
|
||||||
|
await exec.exec(
|
||||||
|
getCommand(filename, args, reportCommand).join(' '),
|
||||||
|
reportExecArgs,
|
||||||
|
reportOptions)
|
||||||
|
.then(async (exitCode) => {
|
||||||
|
if (exitCode == 0) {
|
||||||
|
await doUpload();
|
||||||
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
setFailure(
|
||||||
|
`Codecov:
|
||||||
|
Failed to properly create report: ${err.message}`,
|
||||||
|
failCi,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
await exec.exec(
|
||||||
|
getCommand(
|
||||||
|
filename,
|
||||||
|
args,
|
||||||
|
commitCommand,
|
||||||
|
).join(' '),
|
||||||
|
commitExecArgs, commitOptions)
|
||||||
|
.then(async (exitCode) => {
|
||||||
|
if (exitCode == 0) {
|
||||||
|
await createReport();
|
||||||
|
}
|
||||||
|
unlink();
|
||||||
|
}).catch((err) => {
|
||||||
setFailure(
|
setFailure(
|
||||||
`Codecov: Failed to properly upload: ${err.message}`,
|
`Codecov: Failed to properly create commit: ${err.message}`,
|
||||||
failCi,
|
failCi,
|
||||||
);
|
);
|
||||||
}).then(() => {
|
|
||||||
unlink();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user