Compare commits

...

11 Commits

Author SHA1 Message Date
Tom Hu
84508663e9 chore(release): v4.3.0 (#1366) 2024-04-09 10:58:54 -07:00
dependabot[bot]
e8419092e9 build(deps): bump undici from 5.28.3 to 5.28.4 (#1361)
Bumps [undici](https://github.com/nodejs/undici) from 5.28.3 to 5.28.4.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v5.28.3...v5.28.4)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-09 10:54:18 -07:00
Tom Hu
363a65ad48 feat: add network params (#1365) 2024-04-09 10:53:53 -07:00
dependabot[bot]
640b86a455 build(deps-dev): bump @typescript-eslint/parser from 7.5.0 to 7.6.0 (#1363)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 7.5.0 to 7.6.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.6.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-09 08:20:43 -07:00
dependabot[bot]
375c033fbe build(deps-dev): bump @typescript-eslint/eslint-plugin from 7.5.0 to 7.6.0 (#1364)
build(deps-dev): bump @typescript-eslint/eslint-plugin

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 7.5.0 to 7.6.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v7.6.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-09 08:10:20 -07:00
dependabot[bot]
d701256d7a build(deps): bump github/codeql-action from 3.24.9 to 3.24.10 (#1360)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.9 to 3.24.10.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v3.24.9...v3.24.10)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-08 08:14:19 -07:00
dependabot[bot]
0bb547ab49 build(deps-dev): bump typescript from 5.4.3 to 5.4.4 (#1355)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 5.4.3 to 5.4.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v5.4.3...v5.4.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-05 11:52:31 -07:00
Tom Hu
55e8381a3e fix: automatically detect if using GitHub enterprise (#1356) 2024-04-05 11:12:44 -07:00
Tom Hu
7afa10ed9b fix: use_oidc shoudl be required false (#1353) 2024-04-03 15:47:35 -07:00
Tom Hu
d820d60619 feat: allow for authentication via OIDC token (#1330)
* fix: allow for oidc token

* chore(docs): update docs with use_oidc argument

* Update action.yml

Co-authored-by: Cristian Le <github@lecris.me>

* chore(release): 4.2.0

---------

Co-authored-by: Cristian Le <github@lecris.me>
2024-04-03 15:41:48 -07:00
Tom Hu
3a20752bdd chore(deps): update deps (#1351) 2024-04-02 09:06:24 -07:00
12 changed files with 2459 additions and 2474 deletions

View File

@@ -17,6 +17,7 @@
"@typescript-eslint" "@typescript-eslint"
], ],
"rules": { "rules": {
"max-len": ["error", { "code": 120 }],
"linebreak-style": 0 "linebreak-style": 0
} }
} }

View File

@@ -41,7 +41,7 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3.24.9 uses: github/codeql-action/init@v3.24.10
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@v3.24.9 uses: github/codeql-action/autobuild@v3.24.10
# 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@v3.24.9 uses: github/codeql-action/analyze@v3.24.10

View File

@@ -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@v3.24.9 # v1.0.26 uses: github/codeql-action/upload-sarif@v3.24.10 # v1.0.26
with: with:
sarif_file: results.sarif sarif_file: results.sarif

View File

@@ -64,44 +64,56 @@ steps:
> [!NOTE] > [!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. > 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.
### Using OIDC
For users with [OpenID Connect(OIDC) enabled](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect), the Codecov token is not necessary. You can use OIDC with the `use_oidc` argument as following.
```yaml
- uses: codecov/codecov-action@v4
with:
use_oidc: true
```
Any token supplied will be ignored, as Codecov will default to the OIDC token for verification.
## Arguments ## Arguments
Codecov's Action supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below: Codecov's Action supports inputs from the user. These inputs, along with their descriptions and usage contexts, are listed in the table below:
| Input | Description | Required | | Input | Description | Required |
| :--- | :--- | :---: | | :--- | :--- | :---: |
| `token` | Repository Codecov token. Used to authorize report uploads | *Required | `token` | Repository Codecov token. Used to authorize report uploads | *Required
| `codecov_yml_path` | Specify the path to the Codecov YML | Optional | `codecov_yml_path` | Specify the path to the Codecov YML | Optional
| `commit_parent` | Override to specify the parent commit SHA | Optional | `commit_parent` | Override to specify the parent commit SHA | Optional
| `directory` | Directory to search for coverage reports. | Optional | `directory` | Directory to search for coverage reports. | Optional
| `disable_search` | Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option. | Optional | `disable_search` | Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option. | Optional
| `disable_file_fixes` | Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets) | Optional | `disable_file_fixes` | Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets) | Optional
| `dry_run` | Don't upload files to Codecov | Optional | `dry_run` | Don't upload files to Codecov | Optional
| `env_vars` | Environment variables to tag the upload with (e.g. PYTHON \| OS,PYTHON) | Optional | `env_vars` | Environment variables to tag the upload with (e.g. PYTHON \| OS,PYTHON) | Optional
| `exclude` | Folders to exclude from search | Optional | `exclude` | Folders to exclude from search | Optional
| `fail_ci_if_error` | Specify whether or not CI build should fail if Codecov runs into an error during upload | Optional | `fail_ci_if_error` | Specify whether or not CI build should fail if Codecov runs into an error during upload | Optional
| `file` | Path to coverage file to upload | Optional | `file` | Path to coverage file to upload | Optional
| `files` | Comma-separated list of files to upload | Optional | `files` | Comma-separated list of files to upload | Optional
| `flags` | Flag upload to group coverage metrics (e.g. unittests \| integration \| ui,chrome) | Optional | `flags` | Flag upload to group coverage metrics (e.g. unittests \| integration \| ui,chrome) | Optional
| `handle_no_reports_found` | Raise no exceptions when no coverage reports found | Optional | `handle_no_reports_found` | Raise no exceptions when no coverage reports found | Optional
| `job_code` | The job code | Optional | `job_code` | The job code | Optional
| `name` | User defined upload name. Visible in Codecov UI | Optional | `name` | User defined upload name. Visible in Codecov UI | Optional
| `os` | Override the assumed OS. Options are linux \| macos \| windows \| . | Optional | `os` | Override the assumed OS. Options are linux \| macos \| windows \| . | Optional
| `override_branch` | Specify the branch name | Optional | `override_branch` | Specify the branch name | Optional
| `override_build` | Specify the build number | Optional | `override_build` | Specify the build number | Optional
| `override_build_url` | The URL of the build where this is running | Optional | `override_build_url` | The URL of the build where this is running | Optional
| `override_commit` | Specify the commit SHA | Optional | `override_commit` | Specify the commit SHA | Optional
| `override_pr` | Specify the pull request number | Optional | `override_pr` | Specify the pull request number | Optional
| `plugin` | plugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all. | Optional | `plugin` | plugins to run. Options: xcode, gcov, pycoverage. The default behavior runs them all. | Optional
| `plugins` | Comma-separated list of plugins for use during upload. | Optional | `plugins` | Comma-separated list of plugins for use during upload. | Optional
| `report_code` | The code of the report. If unsure, do not include | Optional | `report_code` | The code of the report. If unsure, do not include | Optional
| `root_dir` | Used to specify the location of your .git root to identify project root directory | Optional | `root_dir` | Used to specify the location of your .git root to identify project root directory | Optional
| `slug` | Specify the slug manually (Enterprise use) | Optional | `slug` | Specify the slug manually (Enterprise use) | Optional
| `url` | Specify the base url to upload (Enterprise use) | Optional | `url` | Specify the base url to upload (Enterprise use) | Optional
| `use_legacy_upload_endpoint` | Use the legacy upload endpoint | Optional | `use_legacy_upload_endpoint` | Use the legacy upload endpoint | Optional
| `verbose` | Specify whether the Codecov output should be verbose | Optional | `use_oidc` | Use OpenID Connect for verification instead of token. This will ignore any token supplied. Please see [GitHub documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect) for details.
| `version` | Specify which version of the Codecov CLI should be used. Defaults to `latest` | Optional | `verbose` | Specify whether the Codecov output should be verbose | Optional
| `working-directory` | Directory in which to execute codecov.sh | Optional | `version` | Specify which version of the Codecov CLI should be used. Defaults to `latest` | Optional
| `working-directory` | Directory in which to execute codecov.sh | Optional
### Example `workflow.yml` with Codecov Action ### Example `workflow.yml` with Codecov Action

View File

@@ -56,6 +56,12 @@ inputs:
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. This will only add files whose path begin with the specified filter. 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 linux | macos | windows.' description: 'Override the assumed OS. Options are linux | macos | windows.'
required: false required: false
@@ -95,6 +101,9 @@ inputs:
use_legacy_upload_endpoint: use_legacy_upload_endpoint:
description: 'Use the legacy upload endpoint' description: 'Use the legacy upload endpoint'
required: false required: false
use_oidc:
description: 'Use OIDC instead of token. This will ignore any token supplied'
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

3785
dist/index.js vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

740
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "codecov-action", "name": "codecov-action",
"version": "4.1.1", "version": "4.3.0",
"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": {
@@ -27,18 +27,18 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"gpg": "^0.6.0", "gpg": "^0.6.0",
"undici": "5.28.3" "undici": "5.28.4"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^6.21.0", "@typescript-eslint/parser": "^7.6.0",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.38.1",
"eslint": "^8.57.0", "eslint": "^8.57.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.2", "ts-jest": "^29.1.2",
"typescript": "^5.4.3" "typescript": "^5.4.4"
} }
} }

View File

@@ -7,10 +7,20 @@ import {
buildUploadExec, buildUploadExec,
} from './buildExec'; } from './buildExec';
const context = github.context; const context = github.context;
test('general args', () => { let OLDOS = process.env.RUNNER_OS;
beforeEach(() => {
jest.resetModules();
OLDOS = process.env.RUNNER_OS;
});
afterAll(() => {
process.env.RUNNER_OS = OLDOS;
});
test('general args', async () => {
const envs = { const envs = {
codecov_yml_path: 'dev/codecov.yml', codecov_yml_path: 'dev/codecov.yml',
url: 'https://codecov.enterprise.com', url: 'https://codecov.enterprise.com',
@@ -20,7 +30,7 @@ test('general args', () => {
process.env['INPUT_' + env.toUpperCase()] = envs[env]; process.env['INPUT_' + env.toUpperCase()] = envs[env];
} }
const {args, verbose} = buildGeneralExec(); const {args, verbose} = await buildGeneralExec();
expect(args).toEqual( expect(args).toEqual(
expect.arrayContaining([ expect.arrayContaining([
@@ -36,13 +46,12 @@ test('general args', () => {
} }
}); });
test('upload args using context', async () => {
test('upload args using context', () => {
const expectedArgs = [ const expectedArgs = [
'--git-service', '--git-service',
'github', 'github',
]; ];
const {uploadExecArgs, uploadCommand} = buildUploadExec(); const {uploadExecArgs, uploadCommand} = await buildUploadExec();
if (context.eventName == 'pull_request') { if (context.eventName == 'pull_request') {
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`); expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
} }
@@ -54,7 +63,7 @@ test('upload args using context', () => {
expect(uploadCommand).toEqual('do-upload'); expect(uploadCommand).toEqual('do-upload');
}); });
test('upload args', () => { test('upload args', async () => {
const envs = { const envs = {
'codecov_yml_path': 'dev/codecov.yml', 'codecov_yml_path': 'dev/codecov.yml',
'commit_parent': 'fakeparentcommit', 'commit_parent': 'fakeparentcommit',
@@ -78,6 +87,8 @@ test('upload args', () => {
'override_build_url': 'https://example.com/build/2', 'override_build_url': 'https://example.com/build/2',
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244', 'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
'override_pr': '2', 'override_pr': '2',
'network_filter': 'subA/',
'network_prefix': 'forA/',
'plugin': 'xcode', 'plugin': 'xcode',
'plugins': 'pycoverage,compress-pycoverage', 'plugins': 'pycoverage,compress-pycoverage',
'report_code': 'testCode', 'report_code': 'testCode',
@@ -94,7 +105,7 @@ test('upload args', () => {
process.env['INPUT_' + env.toUpperCase()] = envs[env]; process.env['INPUT_' + env.toUpperCase()] = envs[env];
} }
const {uploadExecArgs, uploadCommand} = buildUploadExec(); const {uploadExecArgs, uploadCommand} = await buildUploadExec();
const expectedArgs = [ const expectedArgs = [
'--disable-file-fixes', '--disable-file-fixes',
'--disable-search', '--disable-search',
@@ -121,6 +132,10 @@ test('upload args', () => {
'32', '32',
'-n', '-n',
'codecov', 'codecov',
'--network-filter',
'subA/',
'--network-prefix',
'forA/',
'-B', '-B',
'thomasrockhu/test', 'thomasrockhu/test',
'-b', '-b',
@@ -156,7 +171,7 @@ test('upload args', () => {
}); });
test('report args', () => { test('report args', async () => {
const envs = { const envs = {
git_service: 'github_enterprise', git_service: 'github_enterprise',
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244', override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
@@ -169,7 +184,7 @@ test('report args', () => {
process.env['INPUT_' + env.toUpperCase()] = envs[env]; process.env['INPUT_' + env.toUpperCase()] = envs[env];
} }
const {reportExecArgs, reportCommand} = buildReportExec(); const {reportExecArgs, reportCommand} = await buildReportExec();
const expectedArgs = [ const expectedArgs = [
'--git-service', '--git-service',
@@ -191,7 +206,7 @@ test('report args', () => {
}); });
test('report args using context', () => { test('report args using context', async () => {
const envs = { const envs = {
token: 'd3859757-ab80-4664-924d-aef22fa7557b', token: 'd3859757-ab80-4664-924d-aef22fa7557b',
}; };
@@ -206,7 +221,7 @@ test('report args using context', () => {
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`); expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
} }
const {reportExecArgs, reportCommand} = buildReportExec(); const {reportExecArgs, reportCommand} = await buildReportExec();
expect(reportExecArgs).toEqual(expectedArgs); expect(reportExecArgs).toEqual(expectedArgs);
expect(reportCommand).toEqual('create-report'); expect(reportCommand).toEqual('create-report');
@@ -216,7 +231,7 @@ test('report args using context', () => {
}); });
test('commit args', () => { test('commit args', async () => {
const envs = { const envs = {
git_service: 'github_enterprise', git_service: 'github_enterprise',
commit_parent: '83231650328f11695dfb754ca0f540516f188d27', commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
@@ -231,7 +246,7 @@ test('commit args', () => {
process.env['INPUT_' + env.toUpperCase()] = envs[env]; process.env['INPUT_' + env.toUpperCase()] = envs[env];
} }
const {commitExecArgs, commitCommand} = buildCommitExec(); const {commitExecArgs, commitCommand} = await buildCommitExec();
const expectedArgs = [ const expectedArgs = [
'--parent-sha', '--parent-sha',
'83231650328f11695dfb754ca0f540516f188d27', '83231650328f11695dfb754ca0f540516f188d27',
@@ -255,13 +270,33 @@ test('commit args', () => {
} }
}); });
test('commit args using context', () => { test('commit args using context', async () => {
const expectedArgs :string[] = [ const expectedArgs :string[] = [
'--git-service', '--git-service',
'github', 'github',
]; ];
const {commitExecArgs, commitCommand} = buildCommitExec(); const {commitExecArgs, commitCommand} = await 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');
});
test('commit args using github server url', async () => {
const expectedArgs :string[] = [
'--git-service',
'github_enterprise',
];
process.env.GITHUB_SERVER_URL = 'https://example.com';
const {commitExecArgs, commitCommand} = await buildCommitExec();
if (context.eventName == 'pull_request') { if (context.eventName == 'pull_request') {
expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`); expectedArgs.push('-C', `${context.payload.pull_request.head.sha}`);
} }

View File

@@ -3,6 +3,7 @@
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 {setFailure} from './helpers';
const context = github.context; const context = github.context;
@@ -17,15 +18,47 @@ const isTrue = (variable) => {
); );
}; };
const getGitService = () => {
const overrideGitService = core.getInput('git_service');
const serverUrl = process.env.GITHUB_SERVER_URL;
if (overrideGitService) {
return overrideGitService;
} else if (serverUrl !== undefined && serverUrl !== 'https://github.com') {
return 'github_enterprise';
}
return 'github';
};
const buildCommitExec = () => { const getToken = async () => {
let token = core.getInput('token');
let url = core.getInput('url');
const useOIDC = isTrue(core.getInput('use_oidc'));
if (useOIDC) {
if (!url) {
url = 'https://codecov.io';
}
try {
token = await core.getIDToken(url);
return token;
} catch (err) {
setFailure(
`Codecov: Failed to get OIDC token with url: ${url}. ${err.message}`,
true,
);
}
}
return token;
};
const buildCommitExec = async () => {
const commitParent = core.getInput('commit_parent'); const commitParent = core.getInput('commit_parent');
const gitService = core.getInput('git_service'); const gitService = getGitService();
const overrideBranch = core.getInput('override_branch'); const overrideBranch = core.getInput('override_branch');
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 slug = core.getInput('slug'); const slug = core.getInput('slug');
const token = core.getInput('token'); const token = await getToken();
const failCi = isTrue(core.getInput('fail_ci_if_error')); const failCi = isTrue(core.getInput('fail_ci_if_error'));
const workingDir = core.getInput('working-directory'); const workingDir = core.getInput('working-directory');
@@ -49,7 +82,7 @@ const buildCommitExec = () => {
if (commitParent) { if (commitParent) {
commitExecArgs.push('--parent-sha', `${commitParent}`); commitExecArgs.push('--parent-sha', `${commitParent}`);
} }
commitExecArgs.push('--git-service', `${gitService ? gitService : 'github'}`); commitExecArgs.push('--git-service', `${gitService}`);
if (overrideBranch) { if (overrideBranch) {
commitExecArgs.push('-B', `${overrideBranch}`); commitExecArgs.push('-B', `${overrideBranch}`);
@@ -101,12 +134,12 @@ const buildGeneralExec = () => {
return {args, verbose}; return {args, verbose};
}; };
const buildReportExec = () => { const buildReportExec = async () => {
const gitService = core.getInput('git_service'); const gitService = getGitService();
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 slug = core.getInput('slug'); const slug = core.getInput('slug');
const token = core.getInput('token'); const token = await getToken();
const failCi = isTrue(core.getInput('fail_ci_if_error')); const failCi = isTrue(core.getInput('fail_ci_if_error'));
const workingDir = core.getInput('working-directory'); const workingDir = core.getInput('working-directory');
@@ -128,7 +161,7 @@ const buildReportExec = () => {
if (token) { if (token) {
reportOptions.env.CODECOV_TOKEN = token; reportOptions.env.CODECOV_TOKEN = token;
} }
reportExecArgs.push('--git-service', `${gitService ? gitService : 'github'}`); reportExecArgs.push('--git-service', `${gitService}`);
if (overrideCommit) { if (overrideCommit) {
reportExecArgs.push('-C', `${overrideCommit}`); reportExecArgs.push('-C', `${overrideCommit}`);
@@ -158,7 +191,7 @@ const buildReportExec = () => {
return {reportExecArgs, reportOptions, reportCommand}; return {reportExecArgs, reportOptions, reportCommand};
}; };
const buildUploadExec = () => { const buildUploadExec = async () => {
const disableFileFixes = isTrue(core.getInput('disable_file_fixes')); const disableFileFixes = isTrue(core.getInput('disable_file_fixes'));
const disableSafeDirectory = isTrue(core.getInput('disable_safe_directory')); const disableSafeDirectory = isTrue(core.getInput('disable_safe_directory'));
const disableSearch = isTrue(core.getInput('disable_search')); const disableSearch = isTrue(core.getInput('disable_search'));
@@ -169,10 +202,12 @@ const buildUploadExec = () => {
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 gitService = core.getInput('git_service'); const gitService = getGitService();
const handleNoReportsFound = isTrue(core.getInput('handle_no_reports_found')); const handleNoReportsFound = isTrue(core.getInput('handle_no_reports_found'));
const jobCode = core.getInput('job_code'); const jobCode = core.getInput('job_code');
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');
@@ -185,7 +220,7 @@ const buildUploadExec = () => {
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 = await getToken();
let uploaderVersion = core.getInput('version'); let uploaderVersion = core.getInput('version');
const useLegacyUploadEndpoint = isTrue( const useLegacyUploadEndpoint = isTrue(
core.getInput('use_legacy_upload_endpoint'), core.getInput('use_legacy_upload_endpoint'),
@@ -246,7 +281,7 @@ const buildUploadExec = () => {
uploadExecArgs.push('-F', `${f}`); uploadExecArgs.push('-F', `${f}`);
}); });
} }
uploadExecArgs.push('--git-service', `${gitService ? gitService : 'github'}`); uploadExecArgs.push('--git-service', `${gitService}`);
if (handleNoReportsFound) { if (handleNoReportsFound) {
uploadExecArgs.push('--handle-no-reports-found'); uploadExecArgs.push('--handle-no-reports-found');
} }
@@ -256,6 +291,12 @@ const buildUploadExec = () => {
if (name) { if (name) {
uploadExecArgs.push('-n', `${name}`); uploadExecArgs.push('-n', `${name}`);
} }
if (networkFilter) {
uploadExecArgs.push('--network-filter', `${networkFilter}`);
}
if (networkPrefix) {
uploadExecArgs.push('--network-prefix', `${networkPrefix}`);
}
if (overrideBranch) { if (overrideBranch) {
uploadExecArgs.push('-B', `${overrideBranch}`); uploadExecArgs.push('-B', `${overrideBranch}`);
} }

View File

@@ -24,102 +24,106 @@ import versionInfo from './version';
let failCi; let failCi;
try { const run = async () => {
const {commitExecArgs, commitOptions, commitCommand} = buildCommitExec(); try {
const {reportExecArgs, reportOptions, reportCommand} = buildReportExec(); const {commitExecArgs, commitOptions, commitCommand} = await buildCommitExec();
const { const {reportExecArgs, reportOptions, reportCommand} = await buildReportExec();
uploadExecArgs, const {
uploadOptions, uploadExecArgs,
disableSafeDirectory, uploadOptions,
failCi, disableSafeDirectory,
os, failCi,
uploaderVersion, os,
uploadCommand, uploaderVersion,
} = buildUploadExec(); uploadCommand,
const {args, verbose} = buildGeneralExec(); } = await 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));
https.get(getBaseUrl(platform, uploaderVersion), (res) => { https.get(getBaseUrl(platform, uploaderVersion), (res) => {
// Image will be stored at this path // Image will be stored at this path
const filePath = fs.createWriteStream(filename); const filePath = fs.createWriteStream(filename);
res.pipe(filePath); res.pipe(filePath);
filePath filePath
.on('error', (err) => { .on('error', (err) => {
setFailure( setFailure(
`Codecov: Failed to write uploader binary: ${err.message}`, `Codecov: Failed to write uploader binary: ${err.message}`,
true, true,
); );
}).on('finish', async () => { }).on('finish', async () => {
filePath.close(); filePath.close();
await verify(filename, platform, uploaderVersion, verbose, failCi); await verify(filename, platform, uploaderVersion, verbose, failCi);
await versionInfo(platform, uploaderVersion); await versionInfo(platform, uploaderVersion);
await fs.chmodSync(filename, '777'); await fs.chmodSync(filename, '777');
if (!disableSafeDirectory) { if (!disableSafeDirectory) {
await setSafeDirectory(); await setSafeDirectory();
} }
const unlink = () => { const unlink = () => {
fs.unlink(filename, (err) => { fs.unlink(filename, (err) => {
if (err) { if (err) {
setFailure(
`Codecov: Could not unlink uploader: ${err.message}`,
failCi,
);
}
});
};
const doUpload = async () => {
await exec.exec(getCommand(filename, args, uploadCommand).join(' '),
uploadExecArgs,
uploadOptions)
.catch((err) => {
setFailure( setFailure(
`Codecov: `Codecov: Could not unlink uploader: ${err.message}`,
Failed to properly upload report: ${err.message}`,
failCi, failCi,
); );
}); }
}; });
const createReport = async () => { };
const doUpload = async () => {
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( await exec.exec(
getCommand(filename, args, reportCommand).join(' '), getCommand(
reportExecArgs, filename,
reportOptions) args,
commitCommand,
).join(' '),
commitExecArgs, commitOptions)
.then(async (exitCode) => { .then(async (exitCode) => {
if (exitCode == 0) { if (exitCode == 0) {
await doUpload(); await createReport();
} }
unlink();
}).catch((err) => { }).catch((err) => {
setFailure( setFailure(
`Codecov: `Codecov: Failed to properly create commit: ${err.message}`,
Failed to properly create report: ${err.message}`,
failCi, failCi,
); );
}); });
}; });
await exec.exec( });
getCommand( } catch (err) {
filename, setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi);
args, }
commitCommand, };
).join(' '),
commitExecArgs, commitOptions) run();
.then(async (exitCode) => {
if (exitCode == 0) {
await createReport();
}
unlink();
}).catch((err) => {
setFailure(
`Codecov: Failed to properly create commit: ${err.message}`,
failCi,
);
});
});
});
} catch (err) {
setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi);
}