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 Oct 1, 2020
1 parent e1dd6c8 commit 8f034b1
Show file tree
Hide file tree
Showing 21 changed files with 629 additions and 69 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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.2] - 2020-10-01
### Fixed
- 🐛 The entrypoint logic was fixed so the script will _actually_ run now - via [`#236`](https://github.com/paambaati/codeclimate-action/pull/236). This closes [`#235`](https://github.com/paambaati/codeclimate-action/issues/235).

# [2.7.1] - 2020-09-22
### Added
- `coverageCommand` argument is now optional - via [`#220`](https://github.com/paambaati/codeclimate-action/pull/220). This closes [`#182`](https://github.com/paambaati/codeclimate-action/issues/182).
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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. |
| `coverageCommand` | | 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.
Expand All @@ -23,20 +23,32 @@ This action requires that you set the [`CC_TEST_REPORTER_ID`](https://docs.codec
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v2.6.0
uses: paambaati/codeclimate-action@v2.7.2
env:
CC_TEST_REPORTER_ID: <code_climate_reporter_id>
with:
coverageCommand: npm run coverage
debug: true
```
#### Example with only upload
When you've already generated the coverage report in a previous step and wish to just upload the coverage data to Code Climate, you can leave out the `coverageCommand` option.

```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: <code_climate_reporter_id>
```

#### Example with multiple coverage locations

```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v2.6.0
uses: paambaati/codeclimate-action@v2.7.2
env:
CC_TEST_REPORTER_ID: <code_climate_reporter_id>
with:
Expand All @@ -51,7 +63,7 @@ steps:
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v2.6.0
uses: paambaati/codeclimate-action@v2.7.2
env:
# Set CC_TEST_REPORTER_ID as secret of your repo
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
Expand Down Expand Up @@ -92,7 +104,7 @@ module.exports = {
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v2.6.0
uses: paambaati/codeclimate-action@v2.7.2
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
Expand Down
28 changes: 16 additions & 12 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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");
Expand All @@ -24,7 +23,7 @@ const github_1 = require("@actions/github");
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_COVERAGE_COMMAND = '';
const DEFAULT_WORKING_DIRECTORY = '';
const DEFAULT_CODECLIMATE_DEBUG = 'false';
const DEFAULT_COVERAGE_LOCATIONS = '';
Expand Down Expand Up @@ -102,17 +101,22 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
core_1.setFailed('🚨 CC Reporter before-build checkin failed!');
return reject(err);
}
try {
lastExitCode = yield exec_1.exec(coverageCommand, undefined, execOpts);
if (lastExitCode !== 0) {
throw new Error(`Coverage run exited with code ${lastExitCode}`);
if (coverageCommand) {
try {
lastExitCode = yield exec_1.exec(coverageCommand, undefined, execOpts);
if (lastExitCode !== 0) {
throw new Error(`Coverage run exited with code ${lastExitCode}`);
}
core_1.debug('✅ Coverage run completed...');
}
catch (err) {
core_1.error(err.message);
core_1.setFailed('🚨 Coverage run failed!');
return reject(err);
}
core_1.debug('✅ Coverage run completed...');
}
catch (err) {
core_1.error(err.message);
core_1.setFailed('🚨 Coverage run failed!');
return reject(err);
else {
core_1.info(`ℹ️ 'coverageCommand' not set, so skipping building coverage report!`);
}
const coverageLocations = coverageLocationsParam
.split(/\r?\n/)
Expand Down Expand Up @@ -216,7 +220,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
}));
}
exports.run = run;
if (((_b = (_a = require.main) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) < 1) {
if (require.main === module) {
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);
Expand Down
5 changes: 0 additions & 5 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.

19 changes: 3 additions & 16 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.

22 changes: 19 additions & 3 deletions node_modules/@actions/core/lib/core.js

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

Loading

0 comments on commit 8f034b1

Please sign in to comment.