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 3, 2020
1 parent 738fb8c commit 439a9b7
Show file tree
Hide file tree
Showing 37 changed files with 1,343 additions and 16 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ 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.4] - 2020-10-03
### Added
- 💫 Coverage locations can now be Glob patterns - via [`#240`](https://github.com/paambaati/codeclimate-action/pull/240). This closes [`#234`](https://github.com/paambaati/codeclimate-action/issues/234). Thanks @Sumolari!

# [2.7.3] - 2020-10-01
### Fixed
- 🐛 Default coverage command now correctly defaults to `''` - via [`#238`](https://github.com/paambaati/codeclimate-action/pull/238). This closes [`#235`](https://github.com/paambaati/codeclimate-action/issues/235).
- 🐛 Default coverage command now correctly defaults to `''` - via [`#238`](https://github.com/paambaati/codeclimate-action/pull/238). This closes [`#235`](https://github.com/paambaati/codeclimate-action/issues/235). Thanks @bennypowers!

# [2.7.2] - 2020-10-01
### Fixed
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This action requires that you set the [`CC_TEST_REPORTER_ID`](https://docs.codec
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected].2
uses: paambaati/[email protected].4
env:
CC_TEST_REPORTER_ID: <code_climate_reporter_id>
with:
Expand All @@ -38,32 +38,33 @@ When you've already generated the coverage report in a previous step and wish to
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected].2
uses: paambaati/[email protected].4
env:
CC_TEST_REPORTER_ID: <code_climate_reporter_id>
```

#### Example with multiple coverage locations
#### Example with wildcard (glob) pattern

This action supports basic glob patterns to search for files matching given patterns. It uses [`@actions/glob`](https://github.com/actions/toolkit/tree/master/packages/glob#basic) to expand the glob patterns.

```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected].2
uses: paambaati/[email protected].4
env:
CC_TEST_REPORTER_ID: <code_climate_reporter_id>
with:
coverageCommand: yarn coverage
coverageCommand: yarn run coverage
coverageLocations: |
${{github.workspace}}/some-directory/coverage/lcov.info:lcov
${{github.workspace}}/some-other/coverage/lcov.info:lcov
${{github.workspace}}/*.lcov:lcov
```

#### Example with Jacoco

```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected].2
uses: paambaati/[email protected].4
env:
# Set CC_TEST_REPORTER_ID as secret of your repo
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
Expand Down Expand Up @@ -104,11 +105,11 @@ module.exports = {
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected].2
uses: paambaati/[email protected].4
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: yarn coverage
coverageCommand: yarn run coverage
coverageLocations: |
${{github.workspace}}/client/coverage/lcov.info:lcov
${{github.workspace}}/server/coverage/lcov.info:lcov
Expand Down
47 changes: 43 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand All @@ -20,6 +39,7 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
const core_1 = require("@actions/core");
const exec_1 = require("@actions/exec");
const github_1 = require("@actions/github");
const glob = __importStar(require("@actions/glob"));
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';
Expand Down Expand Up @@ -58,6 +78,28 @@ function prepareEnv() {
}
return env;
}
function getLocationLines(coverageLocationPatternsParam) {
return __awaiter(this, void 0, void 0, function* () {
const coverageLocationPatternsLines = coverageLocationPatternsParam
.split(/\r?\n/)
.filter((pat) => pat)
.map((pat) => pat.trim());
const patternsAndFormats = coverageLocationPatternsLines.map((line) => {
const lineParts = line.split(':');
const format = lineParts.slice(-1)[0];
const pattern = lineParts.slice(0, -1)[0];
return { format, pattern };
});
const pathsWithFormat = yield Promise.all(patternsAndFormats.map(({ format, pattern }) => __awaiter(this, void 0, void 0, function* () {
const globber = yield glob.create(pattern);
const paths = yield globber.glob();
const pathsWithFormat = paths.map((singlePath) => `${singlePath}:${format}`);
return pathsWithFormat;
})));
const coverageLocationLines = [].concat(...pathsWithFormat);
return coverageLocationLines;
});
}
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;
Expand Down Expand Up @@ -118,10 +160,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
else {
core_1.info(`ℹ️ 'coverageCommand' not set, so skipping building coverage report!`);
}
const coverageLocations = coverageLocationsParam
.split(/\r?\n/)
.filter((pat) => pat)
.map((pat) => pat.trim());
const coverageLocations = yield getLocationLines(coverageLocationsParam);
if (coverageLocations.length > 0) {
core_1.debug(`Parsing ${coverageLocations.length} coverage location(s) — ${coverageLocations} (${typeof coverageLocations})`);
// Run format-coverage on each location.
Expand Down
3 changes: 2 additions & 1 deletion node_modules/@actions/core/package.json

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

10 changes: 10 additions & 0 deletions node_modules/@actions/glob/lib/glob.d.ts

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

25 changes: 25 additions & 0 deletions node_modules/@actions/glob/lib/glob.js

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/@actions/glob/lib/glob.js.map

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

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

30 changes: 30 additions & 0 deletions node_modules/@actions/glob/lib/internal-glob-options-helper.js

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

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

29 changes: 29 additions & 0 deletions node_modules/@actions/glob/lib/internal-glob-options.d.ts

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

3 changes: 3 additions & 0 deletions node_modules/@actions/glob/lib/internal-glob-options.js

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

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

42 changes: 42 additions & 0 deletions node_modules/@actions/glob/lib/internal-globber.d.ts

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

Loading

0 comments on commit 439a9b7

Please sign in to comment.