Compare commits

..

43 Commits

Author SHA1 Message Date
Tom Hu
f32b3a3741 Merge pull request #515 from codecov/specify-version
Allow specifying version of Codecov uploader
2021-09-13 08:58:22 -04:00
Tom Hu
72dfd4782e Allow specifying version of Codecov uploader 2021-09-09 14:53:12 -04:00
Tom Hu
46edaeda0c Merge pull request #499 from codecov/dependabot/npm_and_yarn/vercel/ncc-0.30.0
build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
2021-09-09 13:21:21 -04:00
Tom Hu
b6fd8cc98b Merge pull request #508 from codecov/dependabot/npm_and_yarn/openpgp-5.0.0
build(deps): bump openpgp from 5.0.0-5 to 5.0.0
2021-09-09 13:20:49 -04:00
dependabot[bot]
07a4e975bb build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.29.0 to 0.30.0.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.29.0...0.30.0)

---
updated-dependencies:
- dependency-name: "@vercel/ncc"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 17:17:40 +00:00
dependabot[bot]
c071c7087f build(deps): bump openpgp from 5.0.0-5 to 5.0.0
Bumps [openpgp](https://github.com/openpgpjs/openpgpjs) from 5.0.0-5 to 5.0.0.
- [Release notes](https://github.com/openpgpjs/openpgpjs/releases)
- [Commits](https://github.com/openpgpjs/openpgpjs/compare/v5.0.0-5...v5.0.0)

---
updated-dependencies:
- dependency-name: openpgp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 17:17:14 +00:00
Tom Hu
f6d4366a4c Merge pull request #514 from codecov/dependabot/npm_and_yarn/types/node-16.9.0
build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
2021-09-09 13:16:10 -04:00
dependabot[bot]
2bbefc9105 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.6.0 to 16.9.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-09 04:03:24 +00:00
Tom Hu
5a8bb4701e Merge pull request #485 from codecov/alternate-os
fix: Add override OS and linux default to platform
2021-08-24 12:06:13 -04:00
Tom Hu
3e9a2814f2 Merge pull request #481 from codecov/dependabot/npm_and_yarn/types/node-16.6.2
build(deps-dev): bump @types/node from 16.6.0 to 16.6.2
2021-08-20 14:58:37 -04:00
Tom Hu
6feb914f25 chore: Update CHANGELOG 2021-08-20 11:58:22 -07:00
dependabot[bot]
9f40d310dd build(deps-dev): bump @types/node from 16.6.0 to 16.6.2
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.6.0 to 16.6.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-20 18:56:34 +00:00
Tom Hu
c4e74feb72 Merge pull request #483 from codecov/dependabot/npm_and_yarn/vercel/ncc-0.29.2
build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.29.2
2021-08-20 14:55:08 -04:00
Tom Hu
6ba3fb33c7 Merge pull request #479 from codecov/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-4.29.2
build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.29.1 to 4.29.2
2021-08-20 14:54:33 -04:00
dependabot[bot]
7efb9be09a 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 4.29.1 to 4.29.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.29.2/packages/eslint-plugin)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-20 18:31:30 +00:00
dependabot[bot]
514990d4ef build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.29.2
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.29.0 to 0.29.2.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.29.0...0.29.2)

---
updated-dependencies:
- dependency-name: "@vercel/ncc"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-20 18:31:14 +00:00
Tom Hu
cd6db5e313 Merge pull request #484 from codecov/dependabot/npm_and_yarn/actions/core-1.5.0
build(deps): bump @actions/core from 1.4.0 to 1.5.0
2021-08-20 14:30:21 -04:00
Tom Hu
678cc77a4f Merge pull request #478 from codecov/dependabot/npm_and_yarn/typescript-eslint/parser-4.29.2
build(deps-dev): bump @typescript-eslint/parser from 4.29.1 to 4.29.2
2021-08-20 14:29:05 -04:00
Tom Hu
4d99e58921 Merge pull request #473 from codecov/dependabot/npm_and_yarn/types/jest-27.0.1
build(deps-dev): bump @types/jest from 27.0.0 to 27.0.1
2021-08-20 14:28:46 -04:00
Tom Hu
92dc6d4776 Merge pull request #472 from codecov/dependabot/npm_and_yarn/path-parse-1.0.7
build(deps): bump path-parse from 1.0.6 to 1.0.7
2021-08-20 14:28:22 -04:00
Tom Hu
b92422542f fix: Add override OS and linux default 2021-08-20 11:23:29 -07:00
dependabot[bot]
5a85075c68 build(deps): bump @actions/core from 1.4.0 to 1.5.0
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.4.0 to 1.5.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-20 04:03:10 +00:00
Tom Hu
53cd6a7259 Add platform 2021-08-19 14:19:35 -07:00
Tom Hu
be75906042 Add khadas-vim3 2021-08-19 14:17:29 -07:00
dependabot[bot]
4af3634337 build(deps-dev): bump @typescript-eslint/parser from 4.29.1 to 4.29.2
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.29.1 to 4.29.2.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.29.2/packages/parser)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-17 04:02:30 +00:00
dependabot[bot]
476c0d12c6 build(deps-dev): bump @types/jest from 27.0.0 to 27.0.1
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 27.0.0 to 27.0.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: "@types/jest"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-13 04:02:56 +00:00
dependabot[bot]
d37df59abd build(deps): bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 20:17:15 +00:00
Tom Hu
17debce911 Merge pull request #470 from codecov/dependabot/npm_and_yarn/types/node-16.6.0
build(deps-dev): bump @types/node from 16.4.0 to 16.6.0
2021-08-12 16:15:51 -04:00
Tom Hu
ef233394d5 Merge pull request #458 from codecov/dependabot/npm_and_yarn/eslint-7.32.0
build(deps-dev): bump eslint from 7.31.0 to 7.32.0
2021-08-12 16:15:45 -04:00
dependabot[bot]
ef1306695a build(deps-dev): bump eslint from 7.31.0 to 7.32.0
Bumps [eslint](https://github.com/eslint/eslint) from 7.31.0 to 7.32.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.31.0...v7.32.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 20:07:59 +00:00
dependabot[bot]
617d8c2876 build(deps-dev): bump @types/node from 16.4.0 to 16.6.0
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.4.0 to 16.6.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 20:07:43 +00:00
Tom Hu
d5d9accd2c Merge pull request #465 from codecov/dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-4.29.1
build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.28.4 to 4.29.1
2021-08-12 16:06:46 -04:00
Tom Hu
0764691a81 Merge pull request #447 from codecov/dependabot/npm_and_yarn/openpgp-5.0.0-5
build(deps): bump openpgp from 5.0.0-4 to 5.0.0-5
2021-08-12 16:06:37 -04:00
Tom Hu
b5f04a063c Merge pull request #464 from mheob/fix-href
Fix wrong link in the readme
2021-08-12 16:02:40 -04:00
dependabot[bot]
f059fc5a7a 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 4.28.4 to 4.29.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.29.1/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>
2021-08-12 20:00:28 +00:00
dependabot[bot]
8f4c6c001f build(deps): bump openpgp from 5.0.0-4 to 5.0.0-5
Bumps [openpgp](https://github.com/openpgpjs/openpgpjs) from 5.0.0-4 to 5.0.0-5.
- [Release notes](https://github.com/openpgpjs/openpgpjs/releases)
- [Commits](https://github.com/openpgpjs/openpgpjs/compare/v5.0.0-4...v5.0.0-5)

---
updated-dependencies:
- dependency-name: openpgp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 20:00:24 +00:00
Tom Hu
dc1883c9ed Merge pull request #466 from codecov/dependabot/npm_and_yarn/typescript-eslint/parser-4.29.1
build(deps-dev): bump @typescript-eslint/parser from 4.28.4 to 4.29.1
2021-08-12 15:59:19 -04:00
Tom Hu
1266be0b5c Merge pull request #468 from codecov/dependabot/npm_and_yarn/types/jest-27.0.0
build(deps-dev): bump @types/jest from 26.0.24 to 27.0.0
2021-08-12 15:59:07 -04:00
dependabot[bot]
71a740cb5b build(deps-dev): bump @types/jest from 26.0.24 to 27.0.0
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.24 to 27.0.0.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

---
updated-dependencies:
- dependency-name: "@types/jest"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-11 04:02:54 +00:00
dependabot[bot]
93f0e12d86 build(deps-dev): bump @typescript-eslint/parser from 4.28.4 to 4.29.1
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.28.4 to 4.29.1.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.29.1/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>
2021-08-10 04:04:45 +00:00
Alexander Böhm
c31909abf8 Fix wrong link in the readme 2021-08-09 08:58:02 +02:00
Tom Hu
71ef541ceb Merge pull request #444 from codecov/fix-readme-marketplace-v2 2021-07-23 10:29:31 -07:00
Tom Hu
c452b99268 Update README with v2 marketplace badge 2021-07-23 09:50:56 -07:00
14 changed files with 8074 additions and 259 deletions

View File

@@ -22,6 +22,14 @@ jobs:
file: ./coverage/coverage-final.json
flags: demo,${{ matrix.os }}
name: codecov-demo
- 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.1.0_8880
run:
runs-on: ${{ matrix.os }}
strategy:
@@ -49,3 +57,11 @@ jobs:
file: ./coverage/coverage-final.json
flags: demo,${{ matrix.os }}
name: codecov-demo
- 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.1.0_8880

View File

@@ -1,3 +1,32 @@
## 2.1.0
### Features
- #515 Allow specifying version of Codecov uploader
### Dependencies
- #499 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.30.0
- #508 build(deps): bump openpgp from 5.0.0-5 to 5.0.0
- #514 build(deps-dev): bump @types/node from 16.6.0 to 16.9.0
## 2.0.3
### Fixes
- #464 Fix wrong link in the readme
- #485 fix: Add override OS and linux default to platform
### Dependencies
- #447 build(deps): bump openpgp from 5.0.0-4 to 5.0.0-5
- #458 build(deps-dev): bump eslint from 7.31.0 to 7.32.0
- #465 build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.28.4 to 4.29.1
- #466 build(deps-dev): bump @typescript-eslint/parser from 4.28.4 to 4.29.1
- #468 build(deps-dev): bump @types/jest from 26.0.24 to 27.0.0
- #470 build(deps-dev): bump @types/node from 16.4.0 to 16.6.0
- #472 build(deps): bump path-parse from 1.0.6 to 1.0.7
- #473 build(deps-dev): bump @types/jest from 27.0.0 to 27.0.1
- #478 build(deps-dev): bump @typescript-eslint/parser from 4.29.1 to 4.29.2
- #479 build(deps-dev): bump @typescript-eslint/eslint-plugin from 4.29.1 to 4.29.2
- #481 build(deps-dev): bump @types/node from 16.6.0 to 16.6.2
- #483 build(deps-dev): bump @vercel/ncc from 0.29.0 to 0.29.2
- #484 build(deps): bump @actions/core from 1.4.0 to 1.5.0
## 2.0.2
### Fixes
- Underlying uploader fixes issues with tokens not being sent properly for users seeing

View File

@@ -10,7 +10,7 @@
## ⚠️ Deprecration of v1
**On February 1, 2022, this version will be fully sunset and no longer function**
Due to the [deprecation](https://about.codecov.io/blog/introducting-codecovs-new-uploader/) of the underlying bash uploader,
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` 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/).
@@ -73,6 +73,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
| `slug` | Specify the slug manually (Enterprise use) | Optional
| `url` | Change the upload host (Enterprise use) | Optional
| `verbose` | Specify whether the Codecov output should be verbose | Optional
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
### Example `workflow.yml` with Codecov Action

View File

@@ -53,6 +53,9 @@ inputs:
override_tag:
description: 'Specify the git tag'
required: false
os:
description: 'Override the assumed OS. Options are alpine | linux | macos | windows.'
required: false
root_dir:
description: 'Used when not in git/hg project to identify project root directory'
required: false
@@ -65,6 +68,9 @@ inputs:
verbose:
description: 'Specify whether the Codecov output should be verbose'
required: false
version:
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
required: false
working-directory:
description: 'Directory in which to execute codecov.sh'
required: false

149
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

7937
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "codecov-action",
"version": "2.0.2",
"version": "2.1.0",
"description": "Upload coverage reports to Codecov from GitHub Actions",
"main": "index.js",
"scripts": {
@@ -23,19 +23,19 @@
},
"homepage": "https://github.com/codecov/codecov-action#readme",
"dependencies": {
"@actions/core": "^1.4.0",
"@actions/core": "^1.5.0",
"@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0",
"node-fetch": "^2.6.1",
"openpgp": "^5.0.0-4"
"openpgp": "^5.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.24",
"@types/node": "^16.4.0",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"@vercel/ncc": "^0.29.0",
"eslint": "^7.31.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.9.0",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"@vercel/ncc": "^0.30.0",
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0",
"jest": "^26.6.3",
"jest-junit": "^12.2.0",

View File

@@ -27,6 +27,7 @@ const buildExec = () => {
const flags = core.getInput('flags');
const functionalities = core.getInput('functionalities');
const name = core.getInput('name');
const os = core.getInput('os');
const overrideBranch = core.getInput('override_branch');
const overrideBuild = core.getInput('override_build');
const overrideCommit = core.getInput('override_commit');
@@ -36,8 +37,9 @@ const buildExec = () => {
const searchDir = core.getInput('directory');
const slug = core.getInput('slug');
const token = core.getInput('token');
const verbose = isTrue(core.getInput('verbose'));
let uploaderVersion = core.getInput('version');
const url = core.getInput('url');
const verbose = isTrue(core.getInput('verbose'));
const workingDir = core.getInput('working-directory');
const execArgs = [];
@@ -146,7 +148,11 @@ const buildExec = () => {
options.cwd = workingDir;
}
return {execArgs, options, failCi};
if (uploaderVersion == '') {
uploaderVersion = 'latest';
}
return {execArgs, options, failCi, os, uploaderVersion};
};
export default buildExec;

70
src/helpers.test.ts Normal file
View File

@@ -0,0 +1,70 @@
import {
getBaseUrl,
getPlatform,
isValidPlatform,
isWindows,
PLATFORMS,
} from './helpers';
let OLDOS = process.env.RUNNER_OS;
beforeEach(() => {
jest.resetModules();
OLDOS = process.env.RUNNER_OS;
});
afterAll(() => {
process.env.RUNNER_OS = OLDOS;
});
test('getPlatform', () => {
expect(getPlatform('linux')).toBe('linux');
expect(getPlatform('windows')).toBe('windows');
const defaultPlatform =
process.env.RUNNER_OS ? process.env.RUNNER_OS.toLowerCase() : 'linux';
expect(getPlatform('fakeos')).toBe(defaultPlatform);
expect(getPlatform()).toBe(defaultPlatform);
process.env.RUNNER_OS = 'macos';
expect(getPlatform('fakeos')).toBe('macos');
expect(getPlatform()).toBe('macos');
process.env.RUNNER_OS = 'alsofakeos';
expect(getPlatform()).toBe('linux');
expect(getPlatform('fakeos')).toBe('linux');
});
test('getBaseUrl', () => {
expect(PLATFORMS.map((platform) => {
return getBaseUrl(platform, 'latest');
})).toEqual([
'https://uploader.codecov.io/latest/alpine/codecov',
'https://uploader.codecov.io/latest/linux/codecov',
'https://uploader.codecov.io/latest/macos/codecov',
'https://uploader.codecov.io/latest/windows/codecov.exe',
]);
expect(PLATFORMS.map((platform) => {
return getBaseUrl(platform, 'v0.1.0_8880');
})).toEqual([
'https://uploader.codecov.io/v0.1.0_8880/alpine/codecov',
'https://uploader.codecov.io/v0.1.0_8880/linux/codecov',
'https://uploader.codecov.io/v0.1.0_8880/macos/codecov',
'https://uploader.codecov.io/v0.1.0_8880/windows/codecov.exe',
]);
});
test('isWindows', () => {
expect(PLATFORMS.map((platform) => {
return isWindows(platform);
})).toEqual([false, false, false, true]);
});
test('isValidPlatform', () => {
expect(PLATFORMS.map((platform) => {
return isValidPlatform(platform);
})).toEqual([true, true, true, true]);
expect(isValidPlatform('fakeos')).toBeFalsy();
});

View File

@@ -9,30 +9,47 @@ const setFailure = (message: string, failCi: boolean): void => {
}
};
const getUploaderName = (): string => {
if (isWindows()) {
const getUploaderName = (platform: string): string => {
if (isWindows(platform)) {
return 'codecov.exe';
} else {
return 'codecov';
}
};
const isValidPlatform = (): boolean => {
return PLATFORMS.includes(getPlatform());
const isValidPlatform = (platform: string): boolean => {
return PLATFORMS.includes(platform);
};
const isWindows = (): boolean => {
return getPlatform() === 'windows';
const isWindows = (platform: string): boolean => {
return platform === 'windows';
};
const getPlatform = (): string => {
return process.env.RUNNER_OS.toLowerCase();
const getPlatform = (os?: string): string => {
if (isValidPlatform(os)) {
core.info(`==> ${os} OS provided`);
return os;
}
const platform = process.env.RUNNER_OS?.toLowerCase();
if (isValidPlatform(platform)) {
core.info(`==> ${platform} OS detected`);
return platform;
}
core.info(
'==> Could not detect OS or provided OS is invalid. Defaulting to linux',
);
return 'linux';
};
const BASEURL = `https://uploader.codecov.io/latest/${getPlatform()}/${getUploaderName()}`;
const getBaseUrl = (platform: string, version: string): string => {
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
};
export {
BASEURL,
PLATFORMS,
getBaseUrl,
getPlatform,
getUploaderName,
isValidPlatform,

View File

@@ -6,28 +6,23 @@ import * as exec from '@actions/exec';
import buildExec from './buildExec';
import {
BASEURL,
getBaseUrl,
getPlatform,
getUploaderName,
isValidPlatform,
setFailure,
} from './helpers';
import verify from './validate';
import versionInfo from './version';
let failCi;
try {
const {execArgs, options, failCi} = buildExec();
const platform = getPlatform();
if (!isValidPlatform()) {
setFailure(
`Codecov: Encountered an unexpected platform: ${platform}`,
failCi,
);
}
const filename = path.join( __dirname, getUploaderName());
https.get(BASEURL, (res) => {
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
const platform = getPlatform(os);
const filename = path.join( __dirname, getUploaderName(platform));
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
// Image will be stored at this path
const filePath = fs.createWriteStream(filename);
res.pipe(filePath);
@@ -40,7 +35,8 @@ try {
}).on('finish', async () => {
filePath.close();
await verify(filename);
await verify(filename, platform, uploaderVersion);
await versionInfo(platform, uploaderVersion);
await fs.chmodSync(filename, '777');
const unlink = () => {

View File

@@ -7,14 +7,14 @@ import * as openpgp from 'openpgp';
import * as fetch from 'node-fetch';
import {
BASEURL,
getBaseUrl,
getUploaderName,
setFailure,
} from './helpers';
const verify = async (filename: string) => {
const verify = async (filename: string, platform: string, version: string) => {
try {
const uploaderName = getUploaderName();
const uploaderName = getUploaderName(platform);
// Read in public key
const publicKeyArmored = await fs.readFileSync(
@@ -23,10 +23,15 @@ const verify = async (filename: string) => {
);
// Get SHASUM and SHASUM signature files
const shasumRes = await fetch( `${BASEURL}.SHA256SUM`);
console.log(`${getBaseUrl(platform, version)}.SHA256SUM`);
const shasumRes = await fetch(
`${getBaseUrl(platform, version)}.SHA256SUM`,
);
const shasum = await shasumRes.text();
const shaSigRes = await fetch( `${BASEURL}.SHA256SUM.sig`);
const shaSigRes = await fetch(
`${getBaseUrl(platform, version)}.SHA256SUM.sig`,
);
const shaSig = await shaSigRes.text();
// Verify shasum

19
src/version.ts Normal file
View File

@@ -0,0 +1,19 @@
import * as core from '@actions/core';
import * as fetch from 'node-fetch';
const versionInfo = async (platform: string, version?: string) => {
if (version) {
core.info(`==> Running version ${version}`);
}
try {
const metadataRes = await fetch( `https://uploader.codecov.io/${platform}/latest`, {
headers: {'Accept': 'application/json'},
});
const metadata = await metadataRes.json();
core.info(`==> Running version ${metadata['version']}`);
} catch (err) {
core.info(`Could not pull latest version information: ${err}`);
}
};
export default versionInfo;