Skip to content

Commit 605afff

Browse files
author
Sam Giffney
authored
Add pipeline for testing (#18)
* Add pipeline for testing * fix shellcheck files hash * fix indentation * specify agent queue * correct linter id * remove default specifier for add_prefix as arg isn't included if not specified * covert docker-compose docs
1 parent 3845a0a commit 605afff

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

.buildkite/pipeline.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
steps:
2+
- label: ":shell: shellcheck"
3+
plugins:
4+
- shellcheck#v1.3.0:
5+
files:
6+
- hooks/*
7+
agents:
8+
queue: docker-light
9+
10+
- label: ":sparkles: lint"
11+
plugins:
12+
- plugin-linter#v3.0.0:
13+
id: jobready/codeclimate-test-reporter
14+
agents:
15+
queue: docker-light
16+
17+
- label: ":docker: :hammer:"
18+
plugins:
19+
docker-compose#v4.9.0:
20+
run: tests
21+
agents:
22+
queue: docker-light

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# codeclimate-test-reporter-buildkite-plugin
22

3+
[![Build status](https://badge.buildkite.com/f02ebd0ee8076077620275a2d77190da07c192522aaaeeb940.svg)](https://buildkite.com/jobready/codeclimate-test-reporter-buildkite-plugin)
4+
35
A BuildKite plugin
46

57
https://buildkite.com/docs/agent/plugins
@@ -203,7 +205,7 @@ Example: `false`
203205
204206
Controls the name outputs files formatted by the codeclimate test reporter. Required to stop artifact names clashing when processing multiple test suites.
205207
206-
### `add_prefix` (optional, default `<empty_string>`)
208+
### `add_prefix` (optional)
207209
208210
Controls the prefix to add to file paths in coverage payloads, to make them match the project's directory structure.
209211
@@ -218,20 +220,28 @@ The `CC_TEST_REPORTER_ID` environment variable must be configured.
218220
219221
## Development
220222
223+
### shellcheck
224+
225+
To run the [shellcheck](https://github.com/koalaman/shellcheck), run
226+
227+
```sh
228+
docker compose run --rm shellcheck hooks/*
229+
```
230+
221231
### Linting
222232

223233
To run the [Buildkite Plugin Linter](https://github.com/buildkite-plugins/buildkite-plugin-linter), run
224234

225235
```sh
226-
docker-compose run --rm lint --name jobready/codeclimate-test-reporter
236+
docker compose run --rm lint
227237
```
228238

229239
### Testing
230240

231-
To run the [Buildkite Plugin Linter](https://github.com/buildkite-plugins/buildkite-plugin-linter), run
241+
To run the [Buildkite Plugin Tester](https://github.com/buildkite-plugins/buildkite-plugin-tester), run
232242

233243
```sh
234-
docker run -it --rm -v "$PWD:/plugin:ro" buildkite/plugin-tester
244+
docker compose run --rm tests
235245
```
236246

237247
## Contributing

docker-compose.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
version: '2'
1+
version: '3.7'
22
services:
33
tests:
4-
image: buildkite/plugin-tester
4+
image: buildkite/plugin-tester:v4.0.0
55
volumes:
66
- ".:/plugin:ro"
7+
78
lint:
89
image: buildkite/plugin-linter
9-
command: ['--id', 'jobready/codeclimate-test-reporter-buildkite-plugin']
10+
command: ['--id', 'jobready/codeclimate-test-reporter']
1011
volumes:
1112
- ".:/plugin:ro"
13+
14+
shellcheck:
15+
image: koalaman/shellcheck:v0.9.0
16+
volumes:
17+
- ".:/mnt:ro"

hooks/command

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ install_reporter() {
1313
"https://codeclimate.com/downloads/test-reporter/test-reporter-${version}-linux-amd64" && \
1414
chmod +x ./cc-test-reporter
1515
# add current working directory to path so cc-test-reporter is accessible
16-
export PATH=${PATH}:$(pwd)
17-
printf -- "cc-test-reporter --version\\n$(cc-test-reporter -v)\\n"
16+
PATH=${PATH}:$(pwd)
17+
export PATH
18+
printf -- "cc-test-reporter --version\\n%s\\n" "$(cc-test-reporter -v)"
1819
}
1920

2021
download_artifacts() {
@@ -28,7 +29,8 @@ download_artifacts() {
2829
}
2930

3031
format_file() {
31-
output_file="coverage/$formatted_file_prefix.$(basename $1)"
32+
existing_file=$(basename "$1")
33+
output_file="coverage/$formatted_file_prefix.$existing_file"
3234
[[ $output_file == *.json ]] || output_file+=.json
3335

3436
args=()
@@ -59,7 +61,6 @@ format_files() {
5961

6062
printf -- "--- :codeclimate: Formatting coverage\\n"
6163

62-
count=1
6364
for f in ${BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_ARTIFACT}; do
6465
format_file "$f" &
6566
done
@@ -81,6 +82,7 @@ report_coverage() {
8182
args+=( "--parts" )
8283
args+=( "${BUILDKITE_PLUGIN_CODECLIMATE_TEST_REPORTER_PARTS}" )
8384
fi
85+
# shellcheck disable=SC2206
8486
args+=( coverage/${formatted_file_prefix}.*.json )
8587
echo cc-test-reporter "${args[@]}"
8688
cc-test-reporter "${args[@]}"

0 commit comments

Comments
 (0)