mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-09 12:26:24 +00:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f32b3a3741 | ||
|
|
72dfd4782e | ||
|
|
46edaeda0c | ||
|
|
b6fd8cc98b | ||
|
|
07a4e975bb | ||
|
|
c071c7087f | ||
|
|
f6d4366a4c | ||
|
|
2bbefc9105 | ||
|
|
5a8bb4701e | ||
|
|
3e9a2814f2 | ||
|
|
6feb914f25 | ||
|
|
9f40d310dd | ||
|
|
c4e74feb72 | ||
|
|
6ba3fb33c7 | ||
|
|
7efb9be09a | ||
|
|
514990d4ef | ||
|
|
cd6db5e313 | ||
|
|
678cc77a4f | ||
|
|
4d99e58921 | ||
|
|
92dc6d4776 | ||
|
|
b92422542f | ||
|
|
5a85075c68 | ||
|
|
53cd6a7259 | ||
|
|
be75906042 | ||
|
|
4af3634337 | ||
|
|
476c0d12c6 | ||
|
|
d37df59abd | ||
|
|
17debce911 | ||
|
|
ef233394d5 | ||
|
|
ef1306695a | ||
|
|
617d8c2876 | ||
|
|
d5d9accd2c | ||
|
|
0764691a81 | ||
|
|
b5f04a063c | ||
|
|
f059fc5a7a | ||
|
|
8f4c6c001f | ||
|
|
dc1883c9ed | ||
|
|
1266be0b5c | ||
|
|
71a740cb5b | ||
|
|
93f0e12d86 | ||
|
|
c31909abf8 | ||
|
|
71ef541ceb | ||
|
|
c452b99268 | ||
|
|
51d810878b | ||
|
|
88c796db18 | ||
|
|
0bbb08247a | ||
|
|
53f686aaf8 | ||
|
|
6ab08a75e2 | ||
|
|
f2242e1815 | ||
|
|
fc2878a530 | ||
|
|
e00e953908 | ||
|
|
8dcb1d2117 | ||
|
|
c5857ba40c | ||
|
|
d680b4c7af | ||
|
|
da21aa9fb6 | ||
|
|
0c50b7bcf4 | ||
|
|
3375d62f3d | ||
|
|
b0b3438bb4 | ||
|
|
9426b0fd6a | ||
|
|
7474287922 | ||
|
|
51773137e8 | ||
|
|
16bc085eaf | ||
|
|
37cfa1ca0a | ||
|
|
4322a1979b | ||
|
|
a558bcf782 | ||
|
|
a96e9cbd13 | ||
|
|
c4b374fc52 | ||
|
|
48b5a1f06e | ||
|
|
66926ef901 | ||
|
|
eac41f1afd | ||
|
|
4c95c92d70 | ||
|
|
c585afe366 | ||
|
|
852cffb352 | ||
|
|
d910efb490 | ||
|
|
439c1e508e | ||
|
|
fc5d663f82 | ||
|
|
5c832aefb8 | ||
|
|
71fa76a9e4 | ||
|
|
672fbdc6af | ||
|
|
1691a31d13 | ||
|
|
ad2b0032e0 | ||
|
|
51db270fe4 | ||
|
|
e2a75c9ff3 |
7
.github/dependabot.yml
vendored
7
.github/dependabot.yml
vendored
@@ -1,7 +1,12 @@
|
|||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: npm
|
- package-ecosystem: npm
|
||||||
directory: "/"
|
directory: /
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
open-pull-requests-limit: 10
|
open-pull-requests-limit: 10
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
|||||||
37
.github/workflows/main.yml
vendored
37
.github/workflows/main.yml
vendored
@@ -1,6 +1,35 @@
|
|||||||
name: Workflow for Codecov Action
|
name: Workflow for Codecov Action
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
|
no-deps:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Upload coverage to Codecov (script)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: ./coverage/script/coverage-final.json
|
||||||
|
flags: script,${{ matrix.os }}
|
||||||
|
name: codecov-script
|
||||||
|
- name: Upload coverage to Codecov (demo)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
|
flags: demo,${{ matrix.os }}
|
||||||
|
name: codecov-demo
|
||||||
|
- 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:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
@@ -28,3 +57,11 @@ jobs:
|
|||||||
file: ./coverage/coverage-final.json
|
file: ./coverage/coverage-final.json
|
||||||
flags: demo,${{ matrix.os }}
|
flags: demo,${{ matrix.os }}
|
||||||
name: codecov-demo
|
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
|
||||||
|
|||||||
39
CHANGELOG.md
39
CHANGELOG.md
@@ -1,3 +1,42 @@
|
|||||||
|
## 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
|
||||||
|
`Error!: Error: Error uploading to https://codecov.io: Error: Error uploading to Codecov: Error: Not Found`
|
||||||
|
- #440 fix: Validation ordering
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
### Fixes
|
||||||
|
- #424 fix: Issue in building all deep dependencies
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
On February 1, 2022, the `v1` uploader will be full sunset and no longer function. This is due
|
On February 1, 2022, the `v1` uploader will be full sunset and no longer function. This is due
|
||||||
to the deprecation of the underlying bash uploader. This version uses the new [uploader](https://github.com/codecov/uploader).
|
to the deprecation of the underlying bash uploader. This version uses the new [uploader](https://github.com/codecov/uploader).
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -1,7 +1,7 @@
|
|||||||
deploy:
|
deploy:
|
||||||
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
$(eval VERSION := $(shell cat package.json | grep '"version": ' | cut -d\" -f4))
|
||||||
git tag -d v1
|
git tag -d v2
|
||||||
git push origin :v1
|
git push origin :v2
|
||||||
git tag v1
|
git tag v2
|
||||||
git tag v$(VERSION) -m ""
|
git tag v$(VERSION) -m ""
|
||||||
git push origin --tags
|
git push origin --tags
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Codecov GitHub Action
|
# Codecov GitHub Action
|
||||||
|
|
||||||
[](https://github.com/marketplace/actions/codecov)
|
[](https://github.com/marketplace/actions/codecov)
|
||||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-action?ref=badge_shield)
|
||||||
[](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
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
## ⚠️ Deprecration of v1
|
## ⚠️ Deprecration of v1
|
||||||
**On February 1, 2022, this version will be fully sunset and no longer function**
|
**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
|
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/).
|
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
|
| `slug` | Specify the slug manually (Enterprise use) | Optional
|
||||||
| `url` | Change the upload host (Enterprise use) | Optional
|
| `url` | Change the upload host (Enterprise use) | Optional
|
||||||
| `verbose` | Specify whether the Codecov output should be verbose | 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
|
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
|
||||||
|
|
||||||
### Example `workflow.yml` with Codecov Action
|
### Example `workflow.yml` with Codecov Action
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ inputs:
|
|||||||
override_tag:
|
override_tag:
|
||||||
description: 'Specify the git tag'
|
description: 'Specify the git tag'
|
||||||
required: false
|
required: false
|
||||||
|
os:
|
||||||
|
description: 'Override the assumed OS. Options are alpine | linux | macos | windows.'
|
||||||
|
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
|
||||||
@@ -65,6 +68,9 @@ inputs:
|
|||||||
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:
|
||||||
|
description: 'Specify which version of the Codecov Uploader should be used. Defaults to `latest`'
|
||||||
|
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
|
||||||
|
|||||||
47256
dist/index.js
vendored
47256
dist/index.js
vendored
File diff suppressed because one or more lines are too long
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/sourcemap-register.js
vendored
Normal file
1
dist/sourcemap-register.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7980
package-lock.json
generated
7980
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "2.0.0",
|
"version": "2.1.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": {
|
||||||
"build": "ncc build src/index.ts",
|
"build": "ncc build src/index.ts --source-map",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
"test": "npm run test-script && npm run test-calculator && npm run test-coverage",
|
"test": "npm run test-script && npm run test-calculator && npm run test-coverage",
|
||||||
"test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator",
|
"test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator",
|
||||||
@@ -23,19 +23,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/codecov/codecov-action#readme",
|
"homepage": "https://github.com/codecov/codecov-action#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.4.0",
|
"@actions/core": "^1.5.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/github": "^5.0.0",
|
"@actions/github": "^5.0.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"openpgp": "^4.10.10"
|
"openpgp": "^5.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.24",
|
"@types/jest": "^27.0.1",
|
||||||
"@types/node": "^16.0.1",
|
"@types/node": "^16.9.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
"@typescript-eslint/eslint-plugin": "^4.29.2",
|
||||||
"@typescript-eslint/parser": "^4.28.3",
|
"@typescript-eslint/parser": "^4.29.2",
|
||||||
"@vercel/ncc": "^0.28.6",
|
"@vercel/ncc": "^0.30.0",
|
||||||
"eslint": "^7.30.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-google": "^0.14.0",
|
"eslint-config-google": "^0.14.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"jest-junit": "^12.2.0",
|
"jest-junit": "^12.2.0",
|
||||||
|
|||||||
@@ -1,8 +1,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';
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
import {version} from '../package.json';
|
||||||
const {version} = require('../package.json');
|
|
||||||
|
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
|
||||||
@@ -28,6 +27,7 @@ const buildExec = () => {
|
|||||||
const flags = core.getInput('flags');
|
const flags = core.getInput('flags');
|
||||||
const functionalities = core.getInput('functionalities');
|
const functionalities = core.getInput('functionalities');
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
|
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');
|
||||||
@@ -37,8 +37,9 @@ const buildExec = () => {
|
|||||||
const searchDir = core.getInput('directory');
|
const searchDir = core.getInput('directory');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
let uploaderVersion = core.getInput('version');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
|
|
||||||
const execArgs = [];
|
const execArgs = [];
|
||||||
@@ -147,7 +148,11 @@ const buildExec = () => {
|
|||||||
options.cwd = workingDir;
|
options.cwd = workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {execArgs, options, failCi};
|
if (uploaderVersion == '') {
|
||||||
|
uploaderVersion = 'latest';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {execArgs, options, failCi, os, uploaderVersion};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default buildExec;
|
export default buildExec;
|
||||||
|
|||||||
70
src/helpers.test.ts
Normal file
70
src/helpers.test.ts
Normal 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();
|
||||||
|
});
|
||||||
@@ -9,30 +9,47 @@ const setFailure = (message: string, failCi: boolean): void => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUploaderName = (): string => {
|
const getUploaderName = (platform: string): string => {
|
||||||
if (isWindows()) {
|
if (isWindows(platform)) {
|
||||||
return 'codecov.exe';
|
return 'codecov.exe';
|
||||||
} else {
|
} else {
|
||||||
return 'codecov';
|
return 'codecov';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isValidPlatform = (): boolean => {
|
const isValidPlatform = (platform: string): boolean => {
|
||||||
return PLATFORMS.includes(getPlatform());
|
return PLATFORMS.includes(platform);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isWindows = (): boolean => {
|
const isWindows = (platform: string): boolean => {
|
||||||
return getPlatform() === 'windows';
|
return platform === 'windows';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPlatform = (): string => {
|
const getPlatform = (os?: string): string => {
|
||||||
return process.env.RUNNER_OS.toLowerCase();
|
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 {
|
export {
|
||||||
BASEURL,
|
PLATFORMS,
|
||||||
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
isValidPlatform,
|
isValidPlatform,
|
||||||
|
|||||||
22
src/index.ts
22
src/index.ts
@@ -6,28 +6,23 @@ import * as exec from '@actions/exec';
|
|||||||
|
|
||||||
import buildExec from './buildExec';
|
import buildExec from './buildExec';
|
||||||
import {
|
import {
|
||||||
BASEURL,
|
getBaseUrl,
|
||||||
getPlatform,
|
getPlatform,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
isValidPlatform,
|
|
||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
import verify from './validate';
|
import verify from './validate';
|
||||||
|
import versionInfo from './version';
|
||||||
|
|
||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {execArgs, options, failCi} = buildExec();
|
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
|
||||||
const platform = getPlatform();
|
const platform = getPlatform(os);
|
||||||
if (!isValidPlatform()) {
|
|
||||||
setFailure(
|
const filename = path.join( __dirname, getUploaderName(platform));
|
||||||
`Codecov: Encountered an unexpected platform: ${platform}`,
|
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||||
failCi,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const filename = path.join( __dirname, getUploaderName());
|
|
||||||
https.get(BASEURL, (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);
|
||||||
@@ -40,7 +35,8 @@ try {
|
|||||||
}).on('finish', async () => {
|
}).on('finish', async () => {
|
||||||
filePath.close();
|
filePath.close();
|
||||||
|
|
||||||
await verify(filename);
|
await verify(filename, platform, uploaderVersion);
|
||||||
|
await versionInfo(platform, uploaderVersion);
|
||||||
await fs.chmodSync(filename, '777');
|
await fs.chmodSync(filename, '777');
|
||||||
|
|
||||||
const unlink = () => {
|
const unlink = () => {
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import * as openpgp from 'openpgp';
|
|||||||
import * as fetch from 'node-fetch';
|
import * as fetch from 'node-fetch';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BASEURL,
|
getBaseUrl,
|
||||||
getUploaderName,
|
getUploaderName,
|
||||||
setFailure,
|
setFailure,
|
||||||
} from './helpers';
|
} from './helpers';
|
||||||
|
|
||||||
const verify = async (filename: string) => {
|
const verify = async (filename: string, platform: string, version: string) => {
|
||||||
try {
|
try {
|
||||||
const uploaderName = getUploaderName();
|
const uploaderName = getUploaderName(platform);
|
||||||
|
|
||||||
// Read in public key
|
// Read in public key
|
||||||
const publicKeyArmored = await fs.readFileSync(
|
const publicKeyArmored = await fs.readFileSync(
|
||||||
@@ -23,45 +23,55 @@ const verify = async (filename: string) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Get SHASUM and SHASUM signature files
|
// 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 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();
|
const shaSig = await shaSigRes.text();
|
||||||
|
|
||||||
// Verify shasum
|
// Verify shasum
|
||||||
const verified = await openpgp.verify({
|
const verified = await openpgp.verify({
|
||||||
message: await openpgp.cleartext.fromText(shasum),
|
message: await openpgp.createMessage({text: shasum}),
|
||||||
signature: await openpgp.signature.readArmored(shaSig),
|
signature: await openpgp.readSignature({armoredSignature: shaSig}),
|
||||||
publicKeys: (await openpgp.key.readArmored(publicKeyArmored)).keys,
|
verificationKeys: await openpgp.readKeys({armoredKeys: publicKeyArmored}),
|
||||||
});
|
});
|
||||||
const {valid} = verified.signatures[0];
|
const valid = await verified.signatures[0].verified;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
core.info('==> SHASUM file signed by key id ' +
|
core.info('==> SHASUM file signed by key id ' +
|
||||||
verified.signatures[0].keyid.toHex(),
|
verified.signatures[0].keyID.toHex(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setFailure('Codecov: Error validating SHASUM signature', true);
|
setFailure('Codecov: Error validating SHASUM signature', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify uploader
|
const calculateHash = async (filename: string) => {
|
||||||
const uploaderSha = crypto.createHash(`sha256`);
|
const stream = fs.createReadStream(filename);
|
||||||
const stream = fs.createReadStream(filename);
|
const uploaderSha = crypto.createHash(`sha256`);
|
||||||
await stream
|
stream.pipe(uploaderSha);
|
||||||
.on('data', (data) => {
|
|
||||||
uploaderSha.update(data);
|
return new Promise((resolve, reject) => {
|
||||||
}).on('end', async () => {
|
stream.on('end', () => resolve(
|
||||||
const hash = `${uploaderSha.digest('hex')} ${uploaderName}`;
|
`${uploaderSha.digest('hex')} ${uploaderName}`,
|
||||||
if (hash !== shasum) {
|
));
|
||||||
setFailure(
|
stream.on('error', reject);
|
||||||
'Codecov: Uploader shasum does not match ' +
|
});
|
||||||
`uploader hash: ${hash}, public hash: ${shasum}`,
|
};
|
||||||
true,
|
|
||||||
);
|
const hash = await calculateHash(filename);
|
||||||
} else {
|
if (hash === shasum) {
|
||||||
core.info('==> Uploader SHASUM verified');
|
core.info(`==> Uploader SHASUM verified (${hash})`);
|
||||||
}
|
} else {
|
||||||
});
|
setFailure(
|
||||||
|
'Codecov: Uploader shasum does not match -- ' +
|
||||||
|
`uploader hash: ${hash}, public hash: ${shasum}`,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setFailure(`Codecov: Error validating uploader: ${err.message}`, true);
|
setFailure(`Codecov: Error validating uploader: ${err.message}`, true);
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/version.ts
Normal file
19
src/version.ts
Normal 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;
|
||||||
@@ -2,9 +2,11 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"outDir": "./dist",
|
"outDir": "dist/",
|
||||||
"rootDir": "./src",
|
"resolveJsonModule": true,
|
||||||
"sourceMap": true
|
"rootDir": ".",
|
||||||
|
"sourceMap": true,
|
||||||
|
"target": "es2015"
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts"
|
"src/**/*.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user