Compare commits

...
Author SHA1 Message Date
Thomas Hu 66ddb8cd18 Test different on 2020-08-07 11:25:40 -04:00
Thomas Hu 07127fde53 Merge pull request #97 from codecov/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-22 09:57:50 -04:00
dependabot[bot] 9128542d5d Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>
2020-07-17 18:34:08 +00:00
Thomas Hu 6d208f5b52 Merge pull request #96 from codecov/1.0.12
Wrap request promise in try catch
2020-07-17 14:33:32 -04:00
Thomas Hu 8ddda09c14 Wrap request promise in try catch 2020-07-17 11:57:18 -04:00
Thomas Hu e16d515d3b Merge pull request #90 from codecov/directory-and-debug
Add directory and file save
2020-07-13 13:21:09 -04:00
Thomas Hu 6b30325ebb Merge branch 'master' into directory-and-debug 2020-07-13 13:00:02 -04:00
Thomas Hu 95f699a0a9 Merge pull request #94 from codecov/update-readme
Add files to README
2020-07-10 17:53:16 -04:00
Thomas Hu 273443b325 Add files to README 2020-07-10 15:32:51 -04:00
Thomas Hu a258ec8bb8 Merge pull request #93 from codecov/specify-files
Specify files and add testing
2020-07-10 15:31:03 -04:00
Thomas Hu 89692c91b7 Specify files and add testing 2020-07-09 23:07:34 -04:00
Thomas Hu 85ec2c8d83 Add directory and file save 2020-07-07 22:36:09 -04:00
Thomas Hu f3570723ef Merge pull request #89 from codecov/fix-ependency
Fix dependencies
2020-07-01 16:43:21 -04:00
Thomas Hu f40f110376 Try requestretry 2020-07-01 15:47:57 -04:00
Thomas Hu 4f81def87b Upgrade ncc 2020-07-01 15:35:39 -04:00
Thomas Hu ddc46b3107 Fix dependencies 2020-07-01 14:58:11 -04:00
Thomas Hu 1b088680d5 Fix dependencies 2020-07-01 14:48:26 -04:00
Thomas Hu 22f6ff10ac Merge pull request #88 from codecov/update-dist
Update dist
2020-07-01 11:57:59 -04:00
Thomas Hu 0ceca4b5d3 Install dependencies 2020-07-01 11:51:01 -04:00
Thomas Hu 3658bafacb Bump version 2020-07-01 11:45:18 -04:00
Thomas Hu ef3b48314f Update dist 2020-07-01 11:40:05 -04:00
Thomas Hu dbf1ddee08 Merge pull request #87 from codecov/retry-bash
Retry retrieval of bash script
2020-07-01 07:27:35 -04:00
Thomas Hu cc6b0c11d2 Retry retrieval of bash script 2020-06-30 23:33:46 -04:00
Thomas Hu f532c3a145 Merge pull request #64 from samuelcolvin/env-vars
Env vars
2020-05-06 17:35:02 -04:00
Thomas Hu 143333ba90 Merge pull request #67 from alex/patch-1
Fixes #66 -- include the current env when invoking the subprocess
2020-05-06 17:33:54 -04:00
Thomas Hu a50851cfd8 Merge pull request #72 from christophebedard/fix-typo-readme
Fix typo in README
2020-05-06 17:32:30 -04:00
Thomas Hu 6914527afb Update index.js 2020-05-06 17:28:51 -04:00
Christophe Bedard fff75f1901 Fix typo in README 2020-05-03 10:22:07 -04:00
Samuel Colvin 1804a456ff fix typos 2020-04-04 14:01:58 +01:00
Alex Gaynor d1b4c72fc5 Update index.js 2020-03-21 20:47:24 -04:00
Alex Gaynor 6fd09f835d Fixes #66 -- include the current env when invoking the subprocess 2020-03-21 20:47:04 -04:00
Samuel Colvin e866b3854d add docs 2020-03-20 16:05:53 +00:00
Samuel Colvin 608816e426 remove log statements 2020-03-20 11:27:29 +00:00
Samuel Colvin 2ce3b3807d rebuild dist 2020-03-20 11:21:50 +00:00
Samuel Colvin 0e6a911c9b add '-e' flag 2020-03-19 16:46:53 +00:00
Samuel Colvin d04135f7cf debug log 2020-03-19 16:39:42 +00:00
Samuel Colvin 7938e79f4c adding 'env_vars' input option 2020-03-19 16:31:53 +00:00
Ibrahim Ali a3a6becb2c Update README.md 2020-03-07 00:00:34 -08:00
Ibrahim Ali bf0e754c09 Update README.md 2020-03-07 00:00:14 -08:00
Ibrahim Ali daa5098552 update latest version line on readme 2020-03-06 23:59:58 -08:00
Ibrahim Ali 71d5dea6af Add example for how to specify multiple flags 2020-03-05 00:00:10 -08:00
ibrahim0814 e34ee48524 remove sample coverage file 2020-03-04 22:37:01 -08:00
Ibrahim Ali d7c91c57ee Merge pull request #53 from armano2/branch-support
Add support for pull requests and tokenless uploads
2020-03-04 22:24:12 -08:00
ibrahim0814 d9faadf52a more documentation updates 2020-03-04 22:22:38 -08:00
ibrahim0814 c70450d006 revert alt exec cmd 2020-03-04 22:02:07 -08:00
ibrahim0814 a6d365dd4c syntax error fix 2020-03-04 21:59:13 -08:00
ibrahim0814 94278ffe1b test alternate exec cmd 2020-03-04 21:57:29 -08:00
ibrahim0814 ebea5cacdf add more documentation notes 2020-03-04 19:59:17 -08:00
ibrahim0814 6a65fa4d50 add github run id env variable 2020-03-04 19:11:12 -08:00
ibrahim0814 4623a4dc3d add sample coverage files 2020-03-04 18:55:36 -08:00
ibrahim0814 c98408608b add functionality for tokenless 2020-03-04 18:30:14 -08:00
13 changed files with 59292 additions and 216 deletions
+18 -19
View File
@@ -1,23 +1,22 @@
name: Example workflow for Codecov
on: [push, pull_request]
name: Workflow for Codecov Action
on:
push:
branches: master
pull_request:
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# - name: Setup Python
# uses: actions/setup-python@master
# - name: Generate coverage report
# run: |
# pip install pytest
# pip install pytest-cov
# pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: ./
with:
token: ${{secrets.CODECOV_TOKEN}}
flags: unittest
name: codecov-1
- name: Checkout
uses: actions/checkout@master
- name: Install dependencies
run: npm install
- name: Run tests and collect coverage
run: yarn run test-all
- name: Upload coverage to Codecov
uses: ./
with:
files: ./coverage/calculator/coverage-final.json,./coverage/index/coverage-final.json
file: ./coverage/coverage-final.json
flags: unittest
name: codecov-1
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 Codecov
Copyright (c) 2019-2020 Codecov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+35 -19
View File
File diff suppressed because one or more lines are too long
+17 -6
View File
@@ -1,26 +1,37 @@
name: 'Codecov'
description: 'GitHub Action that uploads coverage reports for your repository to codecov.io'
author: 'Ibrahim Ali <@ibrahim0814> | Codecov'
inputs:
inputs:
name:
description: 'User defined upload name. Visible in Codecov UI'
required: false
required: false
token:
description: 'Repository upload token - get it from codecov.io'
required: true
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
required: false
file:
description: 'Path to coverage file to upload'
required: false
files:
description: 'Comma-separated list of files to upload'
required: false
directory:
description: 'Directory to search for coverage reports.'
required: false
flags:
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
required: false
path_to_write_report:
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
branding:
color: 'red'
color: 'red'
icon: 'umbrella'
runs:
using: 'node12'
main: 'dist/index.js'
+54127 -89
View File
File diff suppressed because one or more lines are too long
+124 -71
View File
@@ -1,7 +1,7 @@
const core = require("@actions/core");
const exec = require("@actions/exec");
const request = require("request");
const fs = require("fs");
const request = require('requestretry');
let fail_ci;
try {
@@ -9,6 +9,11 @@ try {
const token = core.getInput("token");
const flags = core.getInput("flags");
const file = core.getInput("file");
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");
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
if (
@@ -23,83 +28,131 @@ try {
fail_ci = false;
}
request("https://codecov.io/bash", (error, response, body) => {
if (error && fail_ci) {
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}`);
request({
url: "https://codecov.io/bash",
json: false
}, (error, response, body) => {
try {
if (error && fail_ci) {
throw error;
} else if (error) {
core.warning(`Codecov warning: ${error.message}`);
}
let output = "";
let execError = "";
const options = {};
options.listeners = {
stdout: data => {
output += data.toString();
},
stderr: data => {
execError += data.toString();
fs.writeFile("codecov.sh", body, err => {
if (err && fail_ci) {
throw err;
} else if (err) {
core.warning(`Codecov warning: ${err.message}`);
}
};
options.env = {
CODECOV_TOKEN: `${token}`,
GITHUB_ACTION: process.env.GITHUB_ACTION,
GITHUB_REF: process.env.GITHUB_REF,
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
GITHUB_SHA: process.env.GITHUB_SHA,
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || ''
};
const execArgs = ["codecov.sh"];
if (file) {
execArgs.push(
"-f", `${file}`
);
}
execArgs.push(
"-n", `${name}`,
"-F", `${flags}`
);
if (fail_ci) {
execArgs.push(
"-Z"
);
}
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}`);
let output = "";
let execError = "";
const options = {};
options.listeners = {
stdout: data => {
output += data.toString();
},
stderr: data => {
execError += data.toString();
}
})
.then(() => {
unlinkFile();
});;
};
const unlinkFile = () => {
fs.unlink("codecov.sh", err => {
if (err && fail_ci) {
throw err;
} else if (err) {
core.warning(`Codecov warning: ${err.message}`);
}
options.env = Object.assign(process.env, {
GITHUB_ACTION: process.env.GITHUB_ACTION,
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,
GITHUB_REF: process.env.GITHUB_REF,
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY,
GITHUB_SHA: process.env.GITHUB_SHA,
GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || ''
});
};
});
if(token){
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) {
if (fail_ci) {
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
}
+4895 -4
View File
File diff suppressed because it is too large Load Diff
+18 -7
View File
@@ -1,10 +1,13 @@
{
"name": "codecov-action",
"version": "1.0.5",
"version": "1.0.12",
"description": "Upload coverage reports to Codecov from GitHub Actions",
"main": "index.js",
"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": {
@@ -12,8 +15,8 @@
"url": "git+https://github.com/codecov/codecov-action.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"author": "Ibrahim Ali",
"license": "MIT",
"bugs": {
"url": "https://github.com/codecov/codecov-action/issues"
},
@@ -21,8 +24,16 @@
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/exec": "^1.0.1",
"@zeit/ncc": "^0.20.5",
"@types/jest": "^26.0.4",
"@zeit/ncc": "^0.22.3",
"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": {}
}
+11
View File
@@ -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);
});
+10
View File
@@ -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;
}
}
+11
View File
@@ -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);
});
+21
View File
@@ -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
}
}