Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
paambaati committed Sep 22, 2020
1 parent 60d1b18 commit 0d5a078
Show file tree
Hide file tree
Showing 2,833 changed files with 290,821 additions and 153,388 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [2.7.0] - 2020-09-22
### Added
- Customizable working directory with the new `workingDirectory` option - via [`#220`](https://github.com/paambaati/codeclimate-action/pull/220). Thanks @arareko!

### Fixed
- Errors in the `before-build` and `after-build` steps, if any, are now surfaced correctly - via [`#214`](https://github.com/paambaati/codeclimate-action/pull/214). Thanks @olly!

### Changed
- Dependencies upgraded to latest, including tape v5.

# [2.6.0] - 2020-04-24
### Fixed
- Fixed regressions introduced in [`#154`](https://github.com/paambaati/codeclimate-action/pull/154). Thanks @MartinNuc!
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This action requires that you set the [`CC_TEST_REPORTER_ID`](https://docs.codec
| Input | Default | Description |
| ------------------- | --------------- | ---------------------------------------------------------------------------------- |
| `coverageCommand` | `yarn coverage` | The actual command that should be executed to run your tests and capture coverage. |
| `workingDirectory` | | Specify a custom working directory where the coverage command should be executed. |
| `debug` | `false` | Enable Code Coverage debug output when set to `true`. |
| `coverageLocations` | | Locations to find code coverage as a multiline string.<br>Each line should be of the form `<location>:<type>`. See examples below.
| `prefix` | `undefined` | See [`--prefix`](https://docs.codeclimate.com/docs/configuring-test-coverage) |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
required: false
description: 'Coverage command to execute'
default: 'yarn coverage'
workingDirectory:
required: false
description: 'Custom working directory for executing the coverage command'
default: ''
debug:
required: false
description: 'Enable debugging logs for the Code Climate test reporter'
Expand Down
42 changes: 33 additions & 9 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.downloadToFile = void 0;
const os_1 = require("os");
const fs_1 = require("fs");
const process_1 = require("process");
const node_fetch_1 = __importDefault(require("node-fetch"));
const core_1 = require("@actions/core");
const exec_1 = require("@actions/exec");
Expand All @@ -22,6 +25,7 @@ const utils_1 = require("./utils");
const DOWNLOAD_URL = `https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${os_1.platform()}-amd64`;
const EXECUTABLE = './cc-reporter';
const DEFAULT_COVERAGE_COMMAND = 'yarn coverage';
const DEFAULT_WORKING_DIRECTORY = '';
const DEFAULT_CODECLIMATE_DEBUG = 'false';
const DEFAULT_COVERAGE_LOCATIONS = '';
function downloadToFile(url, file, mode = 0o755) {
Expand Down Expand Up @@ -55,9 +59,22 @@ function prepareEnv() {
}
return env;
}
function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageCommand = DEFAULT_COVERAGE_COMMAND, codeClimateDebug = DEFAULT_CODECLIMATE_DEBUG, coverageLocationsParam = DEFAULT_COVERAGE_LOCATIONS, coveragePrefix) {
function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageCommand = DEFAULT_COVERAGE_COMMAND, workingDirectory = DEFAULT_WORKING_DIRECTORY, codeClimateDebug = DEFAULT_CODECLIMATE_DEBUG, coverageLocationsParam = DEFAULT_COVERAGE_LOCATIONS, coveragePrefix) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
let lastExitCode = 1;
if (workingDirectory) {
core_1.debug(`Changing working directory to ${workingDirectory}`);
try {
process_1.chdir(workingDirectory);
lastExitCode = 0;
core_1.debug('✅ Changing working directory completed...');
}
catch (err) {
core_1.error(err.message);
core_1.setFailed('🚨 Changing working directory failed!');
return reject(err);
}
}
try {
core_1.debug(`ℹ️ Downloading CC Reporter from ${downloadUrl} ...`);
yield downloadToFile(downloadUrl, executable);
Expand All @@ -75,10 +92,13 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
};
try {
lastExitCode = yield exec_1.exec(executable, ['before-build'], execOpts);
if (lastExitCode !== 0) {
throw new Error(`Coverage after-build exited with code ${lastExitCode}`);
}
core_1.debug('✅ CC Reporter before-build checkin completed...');
}
catch (err) {
core_1.error(err);
core_1.error(err.message);
core_1.setFailed('🚨 CC Reporter before-build checkin failed!');
return reject(err);
}
Expand Down Expand Up @@ -132,7 +152,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
}
}
catch (err) {
core_1.error(err);
core_1.error(err.message);
core_1.setFailed('🚨 CC Reporter coverage formatting failed!');
return reject(err);
}
Expand All @@ -155,7 +175,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
}
}
catch (err) {
core_1.error(err);
core_1.error(err.message);
core_1.setFailed('🚨 CC Reporter coverage sum failed!');
return reject(err);
}
Expand All @@ -172,7 +192,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
return resolve();
}
catch (err) {
core_1.error(err);
core_1.error(err.message);
core_1.setFailed('🚨 CC Reporter coverage upload failed!');
return reject(err);
}
Expand All @@ -181,22 +201,26 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
const commands = ['after-build', '--exit-code', lastExitCode.toString()];
if (codeClimateDebug === 'true')
commands.push('--debug');
yield exec_1.exec(executable, commands, execOpts);
lastExitCode = yield exec_1.exec(executable, commands, execOpts);
if (lastExitCode !== 0) {
throw new Error(`Coverage after-build exited with code ${lastExitCode}`);
}
core_1.debug('✅ CC Reporter after-build checkin completed!');
return resolve();
}
catch (err) {
core_1.error(err);
core_1.error(err.message);
core_1.setFailed('🚨 CC Reporter after-build checkin failed!');
return reject(err);
}
}));
}
exports.run = run;
if (!module.parent) {
if (((_b = (_a = require.main) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) < 1) {
const coverageCommand = utils_1.getOptionalString('coverageCommand', DEFAULT_COVERAGE_COMMAND);
const workingDirectory = utils_1.getOptionalString('workingDirectory', DEFAULT_WORKING_DIRECTORY);
const codeClimateDebug = utils_1.getOptionalString('debug', DEFAULT_CODECLIMATE_DEBUG);
const coverageLocations = utils_1.getOptionalString('coverageLocations', DEFAULT_COVERAGE_LOCATIONS);
const coveragePrefix = utils_1.getOptionalString('prefix');
run(DOWNLOAD_URL, EXECUTABLE, coverageCommand, codeClimateDebug, coverageLocations, coveragePrefix);
run(DOWNLOAD_URL, EXECUTABLE, coverageCommand, workingDirectory, codeClimateDebug, coverageLocations, coveragePrefix);
}
3 changes: 2 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.areObjectsEqual = exports.getOptionalString = void 0;
const core_1 = require("@actions/core");
exports.getOptionalString = (name, def = '') => core_1.getInput(name, { required: false }) || def;
exports.getOptionalString = (name, defaultValue = '') => core_1.getInput(name, { required: false }) || defaultValue;
exports.areObjectsEqual = (obj1, obj2) => JSON.stringify(obj1) === JSON.stringify(obj2);
1 change: 1 addition & 0 deletions node_modules/.bin/esparse

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esvalidate

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/js-yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jsesc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/node-which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/nyc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/parser

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/rimraf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion node_modules/.bin/which

This file was deleted.

9 changes: 9 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0d5a078

Please sign in to comment.