Compare commits
91
Commits
node-action
...
v1.0.13
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6004246f47 | ||
|
|
5d3f01ccdc | ||
|
|
2d80980946 | ||
|
|
fadbb25281 | ||
|
|
ad774549da | ||
|
|
07127fde53 | ||
|
|
9128542d5d | ||
|
|
6d208f5b52 | ||
|
|
8ddda09c14 | ||
|
|
e16d515d3b | ||
|
|
6b30325ebb | ||
|
|
95f699a0a9 | ||
|
|
273443b325 | ||
|
|
a258ec8bb8 | ||
|
|
89692c91b7 | ||
|
|
85ec2c8d83 | ||
|
|
f3570723ef | ||
|
|
f40f110376 | ||
|
|
4f81def87b | ||
|
|
ddc46b3107 | ||
|
|
1b088680d5 | ||
|
|
22f6ff10ac | ||
|
|
0ceca4b5d3 | ||
|
|
3658bafacb | ||
|
|
ef3b48314f | ||
|
|
dbf1ddee08 | ||
|
|
cc6b0c11d2 | ||
|
|
f532c3a145 | ||
|
|
143333ba90 | ||
|
|
a50851cfd8 | ||
|
|
6914527afb | ||
|
|
fff75f1901 | ||
|
|
1804a456ff | ||
|
|
d1b4c72fc5 | ||
|
|
6fd09f835d | ||
|
|
e866b3854d | ||
|
|
608816e426 | ||
|
|
2ce3b3807d | ||
|
|
0e6a911c9b | ||
|
|
d04135f7cf | ||
|
|
7938e79f4c | ||
|
|
a3a6becb2c | ||
|
|
bf0e754c09 | ||
|
|
daa5098552 | ||
|
|
71d5dea6af | ||
|
|
e34ee48524 | ||
|
|
d7c91c57ee | ||
|
|
d9faadf52a | ||
|
|
c70450d006 | ||
|
|
a6d365dd4c | ||
|
|
94278ffe1b | ||
|
|
ebea5cacdf | ||
|
|
6a65fa4d50 | ||
|
|
4623a4dc3d | ||
|
|
c98408608b | ||
|
|
49c86d6a5f | ||
|
|
6ec347819d | ||
|
|
44ca3d2c84 | ||
|
|
66879ff350 | ||
|
|
797e92895e | ||
|
|
a6337803aa | ||
|
|
2613f978c9 | ||
|
|
4c6a7296af | ||
|
|
4fec3dfa96 | ||
|
|
355d574b25 | ||
|
|
a497b16d77 | ||
|
|
ab46201142 | ||
|
|
ecf5f576a0 | ||
|
|
8c950ae5c5 | ||
|
|
3d303911df | ||
|
|
eb1ea256cb | ||
|
|
5f55456d46 | ||
|
|
ade1ebf812 | ||
|
|
31d7d88849 | ||
|
|
d608de8763 | ||
|
|
08a0ecb0f3 | ||
|
|
3dfea70b3f | ||
|
|
f291e7ca9d | ||
|
|
78d806df69 | ||
|
|
dd4242c61d | ||
|
|
fc0e9fde50 | ||
|
|
cf0e744e2c | ||
|
|
fd07c5fc0c | ||
|
|
3d11715b9e | ||
|
|
cec654a0a7 | ||
|
|
41a31f1ccf | ||
|
|
d073b23c28 | ||
|
|
11d69070bf | ||
|
|
dd2a59ac10 | ||
|
|
3ec2345d08 | ||
|
|
aea83764c6 |
+15
-19
@@ -1,23 +1,19 @@
|
|||||||
name: Example workflow for Codecov
|
name: Workflow for Codecov Action
|
||||||
on: [push]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
# - name: Setup Python
|
- name: Install dependencies
|
||||||
# uses: actions/setup-python@master
|
run: npm install
|
||||||
|
- name: Run tests and collect coverage
|
||||||
# - name: Generate coverage report
|
run: yarn run test-all
|
||||||
# run: |
|
- name: Upload coverage to Codecov
|
||||||
# pip install pytest
|
uses: ./
|
||||||
# pip install pytest-cov
|
with:
|
||||||
# pytest --cov=./ --cov-report=xml
|
files: ./coverage/calculator/coverage-final.json,./coverage/index/coverage-final.json
|
||||||
|
file: ./coverage/coverage-final.json
|
||||||
- name: Upload coverage to Codecov
|
flags: unittest
|
||||||
uses: ./
|
name: codecov-1
|
||||||
with:
|
|
||||||
token: ${{secrets.CODECOV_TOKEN}}
|
|
||||||
flags: unittest
|
|
||||||
name: codecov-1
|
|
||||||
|
|||||||
+5
-2
@@ -76,7 +76,7 @@ typings/
|
|||||||
# nuxt.js build output
|
# nuxt.js build output
|
||||||
.nuxt
|
.nuxt
|
||||||
|
|
||||||
# react / gatsby
|
# react / gatsby
|
||||||
public/
|
public/
|
||||||
|
|
||||||
# vuepress build output
|
# vuepress build output
|
||||||
@@ -89,4 +89,7 @@ public/
|
|||||||
.fusebox/
|
.fusebox/
|
||||||
|
|
||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|
||||||
|
# macOS Finder metadata
|
||||||
|
.DS_Store
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2019 Codecov
|
Copyright (c) 2019-2020 Codecov
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
+20
-9
@@ -1,26 +1,37 @@
|
|||||||
name: 'Codecov'
|
name: 'Codecov'
|
||||||
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
|
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
|
||||||
author: 'Ibrahim Ali <@ibrahim0814> | Codecov'
|
author: 'Ibrahim Ali <@ibrahim0814> & Thomas Hu <@thomasrockhu> | Codecov'
|
||||||
inputs:
|
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
|
||||||
token:
|
token:
|
||||||
description: 'Repository upload token - get it from codecov.io'
|
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
||||||
required: true
|
required: false
|
||||||
file:
|
file:
|
||||||
description: 'Path to coverage file to upload'
|
description: 'Path to coverage file to upload'
|
||||||
required: false
|
required: false
|
||||||
|
files:
|
||||||
|
description: 'Comma-separated list of files to upload'
|
||||||
|
required: false
|
||||||
|
directory:
|
||||||
|
description: 'Directory to search for coverage reports.'
|
||||||
|
required: false
|
||||||
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
|
||||||
yml:
|
path_to_write_report:
|
||||||
description: 'Specify the location of the .codecov.yml config file'
|
description: 'Write upload file to path before uploading'
|
||||||
|
required: false
|
||||||
|
env_vars:
|
||||||
|
description: 'Environment variables to tag the upload with (e.g. PYTHON | OS,PYTHON)'
|
||||||
|
required: false
|
||||||
|
fail_ci_if_error:
|
||||||
|
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||||
required: false
|
required: false
|
||||||
branding:
|
branding:
|
||||||
color: 'red'
|
color: 'red'
|
||||||
icon: 'umbrella'
|
icon: 'umbrella'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
||||||
|
|||||||
Vendored
+46804
-26217
File diff suppressed because one or more lines are too long
@@ -1,72 +1,165 @@
|
|||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const exec = require("@actions/exec");
|
const exec = require("@actions/exec");
|
||||||
const request = require("request");
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
const request = require('requestretry');
|
||||||
|
|
||||||
|
let fail_ci;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const name = core.getInput("name");
|
const name = core.getInput("name");
|
||||||
const token = core.getInput("token");
|
const token = core.getInput("token");
|
||||||
const flags = core.getInput("flags");
|
const flags = core.getInput("flags");
|
||||||
const file = core.getInput("file");
|
const file = core.getInput("file");
|
||||||
const yml = core.getInput("yml");
|
const files = core.getInput("files");
|
||||||
|
const env_vars = core.getInput("env_vars");
|
||||||
|
const dir = core.getInput("directory");
|
||||||
|
const write_path = core.getInput("path_to_write_report");
|
||||||
|
|
||||||
request("https://codecov.io/bash", (error, response, body) => {
|
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||||
if (error) throw error;
|
|
||||||
|
|
||||||
fs.writeFile("codecov.sh", body, err => {
|
if (
|
||||||
if (err) throw err;
|
fail_ci === "yes" ||
|
||||||
|
fail_ci === "y" ||
|
||||||
|
fail_ci === "true" ||
|
||||||
|
fail_ci === "t" ||
|
||||||
|
fail_ci === "1"
|
||||||
|
) {
|
||||||
|
fail_ci = true;
|
||||||
|
} else {
|
||||||
|
fail_ci = false;
|
||||||
|
}
|
||||||
|
|
||||||
let output = "";
|
request({
|
||||||
let execError = "";
|
json: false,
|
||||||
const options = {};
|
maxAttempts: 10,
|
||||||
options.listeners = {
|
timeout: 3000,
|
||||||
stdout: data => {
|
url: "https://codecov.io/bash"
|
||||||
output += data.toString();
|
}, (error, response, body) => {
|
||||||
},
|
try {
|
||||||
stderr: data => {
|
if (error && fail_ci) {
|
||||||
execError += data.toString();
|
throw error;
|
||||||
|
} else if (error) {
|
||||||
|
core.warning(`Codecov warning: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFile("codecov.sh", body, err => {
|
||||||
|
if (err && fail_ci) {
|
||||||
|
throw err;
|
||||||
|
} else if (err) {
|
||||||
|
core.warning(`Codecov warning: ${err.message}`);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
options.env = {
|
let output = "";
|
||||||
CODECOV_TOKEN: `${token}`,
|
let execError = "";
|
||||||
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
const options = {};
|
||||||
GITHUB_REF: process.env.GITHUB_REF,
|
options.listeners = {
|
||||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
stdout: data => {
|
||||||
GITHUB_SHA: process.env.GITHUB_SHA
|
output += data.toString();
|
||||||
};
|
},
|
||||||
|
stderr: data => {
|
||||||
|
execError += data.toString();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (file) {
|
options.env = Object.assign(process.env, {
|
||||||
exec
|
GITHUB_ACTION: process.env.GITHUB_ACTION,
|
||||||
.exec(
|
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
|
||||||
"bash",
|
GITHUB_REF: process.env.GITHUB_REF,
|
||||||
["codecov.sh", "-f", `${file}`, "-n", `${name}`, "-F", `${flags}`, '-y', `${yml}`],
|
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
|
||||||
options
|
GITHUB_SHA: process.env.GITHUB_SHA,
|
||||||
)
|
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || ''
|
||||||
.then(() => {
|
|
||||||
unlinkFile()
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
exec
|
|
||||||
.exec(
|
|
||||||
"bash",
|
|
||||||
["codecov.sh", "-n", `${name}`, "-F", `${flags}`, '-y', `${yml}`],
|
|
||||||
options
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
unlinkFile()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const unlinkFile = () => {
|
|
||||||
fs.unlink("codecov.sh", err => {
|
|
||||||
if (err) throw err;
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
});
|
if(token){
|
||||||
|
options.env.CODECOV_TOKEN = token
|
||||||
|
}
|
||||||
|
|
||||||
|
const env_vars_arg = []
|
||||||
|
for (let env_var of env_vars.split(",")) {
|
||||||
|
let env_var_clean = env_var.trim();
|
||||||
|
if (env_var_clean) {
|
||||||
|
options.env[env_var_clean] = process.env[env_var_clean];
|
||||||
|
env_vars_arg.push(env_var_clean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const execArgs = ["codecov.sh"];
|
||||||
|
if (file) {
|
||||||
|
execArgs.push(
|
||||||
|
"-f", `${file}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (files) {
|
||||||
|
files.split(',').forEach(f => {
|
||||||
|
execArgs.push(
|
||||||
|
"-f", `${f}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dir) {
|
||||||
|
execArgs.push(
|
||||||
|
"-s", `${dir}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
execArgs.push(
|
||||||
|
"-n", `${name}`,
|
||||||
|
"-F", `${flags}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fail_ci) {
|
||||||
|
execArgs.push(
|
||||||
|
"-Z"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env_vars_arg.length) {
|
||||||
|
execArgs.push(
|
||||||
|
"-e", env_vars_arg.join(",")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (write_path) {
|
||||||
|
execArgs.push(
|
||||||
|
"-q", `${write_path}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
exec.exec("bash", execArgs, options)
|
||||||
|
.catch(err => {
|
||||||
|
if (fail_ci) {
|
||||||
|
core.setFailed(
|
||||||
|
`Codecov failed with the following error: ${err.message}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.warning(`Codecov warning: ${err.message}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
unlinkFile();
|
||||||
|
});
|
||||||
|
|
||||||
|
const unlinkFile = () => {
|
||||||
|
fs.unlink("codecov.sh", err => {
|
||||||
|
if (err && fail_ci) {
|
||||||
|
throw err;
|
||||||
|
} else if (err) {
|
||||||
|
core.warning(`Codecov warning: ${err.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(
|
||||||
|
`Codecov failed with the following error: ${error.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
if (fail_ci) {
|
||||||
|
core.setFailed(`Codecov failed with the following error: ${error.message}`);
|
||||||
|
} else {
|
||||||
|
core.warning(`Codecov warning: ${error.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
preset: 'ts-jest',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
}
|
||||||
Generated
+4624
-196
File diff suppressed because it is too large
Load Diff
+21
-8
@@ -1,18 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "test2",
|
"name": "codecov-action",
|
||||||
"version": "1.0.0",
|
"version": "1.0.13",
|
||||||
"description": "[](https://github.com/marketplace/actions/codecov) ### Easily 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": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "jest --coverage",
|
||||||
|
"test-calculator": "jest --testPathPattern=src/calculator/ --coverage --coverageDirectory=coverage/calculator",
|
||||||
|
"test-index": "jest --testPathPattern=src/index --coverage --coverageDirectory=coverage/index",
|
||||||
|
"test-all": "yarn run test && yarn run test-calculator && yarn run test-index",
|
||||||
|
"build": "ncc build index.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/codecov/codecov-action.git"
|
"url": "git+https://github.com/codecov/codecov-action.git"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "Ibrahim Ali",
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/codecov/codecov-action/issues"
|
"url": "https://github.com/codecov/codecov-action/issues"
|
||||||
},
|
},
|
||||||
@@ -20,7 +24,16 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
|
"@types/jest": "^26.0.4",
|
||||||
|
"@zeit/ncc": "^0.22.3",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
"request": "^2.88.0"
|
"jest": "^26.1.0",
|
||||||
}
|
"jest-junit": "^10.0.0",
|
||||||
|
"request": "^2.88.0",
|
||||||
|
"requestretry": "^4.1.1",
|
||||||
|
"ts-jest": "^26.1.1",
|
||||||
|
"typescript": "^3.9.6",
|
||||||
|
"yarn": "^1.22.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import Calculator from './calculator'
|
||||||
|
|
||||||
|
test('adds 2 + 3 to equal 5', () => {
|
||||||
|
const calc = new Calculator()
|
||||||
|
expect(calc.add(2, 3)).toBe(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subtracts 2 - 3 to equal -1', () => {
|
||||||
|
const calc = new Calculator()
|
||||||
|
expect(calc.subtract(2, 3)).toBe(-1);
|
||||||
|
});
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export default class Calculator {
|
||||||
|
|
||||||
|
add(x : number, y : number) : number {
|
||||||
|
return x + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
subtract(x: number, y: number) : number {
|
||||||
|
return x - y;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import Index from "./index";
|
||||||
|
|
||||||
|
test('test uncovered if', () => {
|
||||||
|
const indexObj = new Index();
|
||||||
|
expect(indexObj.uncovered_if()).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fully covered', () => {
|
||||||
|
const indexObj = new Index();
|
||||||
|
expect(indexObj.fully_covered()).toEqual(true);
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export default class Index {
|
||||||
|
|
||||||
|
//This function is tested and part of it is uncovered
|
||||||
|
uncovered_if = (a = true) => {
|
||||||
|
if (a == true) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//This function will be fully covered
|
||||||
|
fully_covered = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
//This function will not be tested by unit tests
|
||||||
|
uncovered = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user