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 Feb 25, 2020
1 parent 777dbe8 commit ca9eb20
Show file tree
Hide file tree
Showing 23 changed files with 819 additions and 70 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.5.0] - 2020-02-25
### Added
- Custom `--prefix` support - via [`#111`](https://github.com/paambaati/codeclimate-action/pull/111).

# [2.4.0] - 2020-01-07
### Added
- Multiple coverage locations support - via [`#77`](https://github.com/paambaati/codeclimate-action/pull/77). Thanks @mattvv!
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This action requires that you set the [`CC_TEST_REPORTER_ID`](https://docs.codec
| `debug` | `false` | Enable Code Coverage debug output when set to `true`. |
| `coverageLocations` | `[]` | Locations to find code coverage (Used for builds from multiple locations) |
| | | Format is (location:type, e.g. ./coverage/lcov.info:lcov) |
| `prefix` | `undefined` | See [`--prefix`](https://docs.codeclimate.com/docs/configuring-test-coverage) |

#### Example

Expand All @@ -30,4 +31,21 @@ steps:
debug: true
```
#### Example with Jacoco
```yaml
steps:
- name: Test & publish code coverage
uses: paambaati/[email protected]
env:
# Set CC_TEST_REPORTER_ID as secret of your repo
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
JACOCO_SOURCE_PATH: "${{github.workspace}}/src/main/java"
with:
# The report file must be there, otherwise Code Climate won't find it
coverageCommand: mvn test
coverageLocations:
"${{github.workspace}}/target/site/jacoco/jacoco.xml:jacoco"
```
Example project — [paambaati/websight](https://github.com/paambaati/websight/blob/663bd4245b3c2dbd768aff9bfc197103ee77973e/.github/workflows/ci.yml#L33-L49)
13 changes: 8 additions & 5 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function prepareEnv() {
env.GIT_BRANCH = env.GIT_BRANCH.replace(/^refs\/heads\//, ''); // Remove 'refs/heads/' prefix (See https://github.com/paambaati/codeclimate-action/issues/42)
return env;
}
function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageCommand = DEFAULT_COVERAGE_COMMAND, codeClimateDebug = DEFAULT_CODECLIMATE_DEBUG, coverageLocations = DEFAULT_COVERAGE_LOCATIONS) {
function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageCommand = DEFAULT_COVERAGE_COMMAND, codeClimateDebug = DEFAULT_CODECLIMATE_DEBUG, coverageLocations = DEFAULT_COVERAGE_LOCATIONS, coveragePrefix = undefined) {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
let lastExitCode = 1;
try {
Expand Down Expand Up @@ -86,7 +86,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
return reject(err);
}
if (coverageLocations.length > 0) {
//Run format-coverage on each location.
// Run format-coverage on each location.
const parts = [];
for (const i in coverageLocations) {
const [location, type] = coverageLocations[i].split(':');
Expand All @@ -110,7 +110,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
return reject(err);
}
}
//run sum coverage
// Run sum coverage.
const sumCommands = [
'sum-coverage',
...parts,
Expand All @@ -129,7 +129,7 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
core_1.setFailed('🚨 CC Reporter after-build checkin failed!');
return reject(err);
}
//upload to code climate:
// Upload to Code Climate.
const uploadCommands = ['upload-coverage', '-i', `coverage.total.json`];
if (codeClimateDebug === 'true')
uploadCommands.push('--debug');
Expand All @@ -148,6 +148,8 @@ function run(downloadUrl = DOWNLOAD_URL, executable = EXECUTABLE, coverageComman
const commands = ['after-build', '--exit-code', lastExitCode.toString()];
if (codeClimateDebug === 'true')
commands.push('--debug');
if (typeof coveragePrefix === 'string')
commands.push('--prefix', coveragePrefix);
yield exec_1.exec(executable, commands, execOpts);
core_1.debug('✅ CC Reporter after-build checkin completed!');
return resolve();
Expand All @@ -173,5 +175,6 @@ if (!module.parent) {
const coverageLocations = coverageLocationsText.length
? coverageLocationsText.split(' ')
: DEFAULT_COVERAGE_LOCATIONS;
run(DOWNLOAD_URL, EXECUTABLE, coverageCommand, codeClimateDebug, coverageLocations);
const coveragePrefix = core_1.getInput('prefix', { required: false });
run(DOWNLOAD_URL, EXECUTABLE, coverageCommand, codeClimateDebug, coverageLocations, coveragePrefix);
}
6 changes: 3 additions & 3 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.

46 changes: 29 additions & 17 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.

11 changes: 9 additions & 2 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.

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

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

22 changes: 12 additions & 10 deletions node_modules/@actions/core/package.json

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

Loading

0 comments on commit ca9eb20

Please sign in to comment.