Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
chore: improve erro log (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
adikari authored Nov 23, 2022
1 parent b21e787 commit c1ecdb9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ coverage:
status:
project:
default:
target: "78%"
target: "80.5%"
patch:
enabled: false
10 changes: 6 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Build

on: [push, pull_request]
on: pull_request

jobs:
build:

concurrency:
group: monorepo-plugin-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '^1.17.2'

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.1]

### Changed
- Improve error logging by @adikari in https://github.com/monebag/monorepo-diff-buildkite-plugin/pull/118

## [2.5.0]

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If the version number is not provided then the most recent version of the plugin
steps:
- label: "Triggering pipelines"
plugins:
- monebag/monorepo-diff#v2.5.0:
- monebag/monorepo-diff#v2.5.1:
diff: "git diff --name-only HEAD~1"
watch:
- path: "bar-service/"
Expand All @@ -35,7 +35,7 @@ steps:
steps:
- label: "Triggering pipelines"
plugins:
- monebag/monorepo-diff#v2.5.0:
- monebag/monorepo-diff#v2.5.1:
diff: "git diff --name-only $(head -n 1 last_successful_build)"
interpolation: false
env:
Expand Down Expand Up @@ -131,7 +131,7 @@ Add `log_level` property to set the log level. Supported log levels are `debug`
steps:
- label: "Triggering pipelines"
plugins:
- monebag/monorepo-diff#v2.5.0:
- monebag/monorepo-diff#v2.5.1:
diff: "git diff --name-only HEAD~1"
log_level: "debug" # defaults to "info"
watch:
Expand Down Expand Up @@ -207,7 +207,7 @@ hooks:
steps:
- label: "Triggering pipelines"
plugins:
- monebag/monorepo-diff#v2.5.0:
- monebag/monorepo-diff#v2.5.1:
diff: "git diff --name-only HEAD~1"
watch:
- path: app/cms/
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ func setupLogger(logLevel string) {
var Version string

func main() {
log.Infof("--- :one: monorepo-diff %s", Version)
log.Infof("--- running monorepo-diff %s", Version)

plugin, err := initializePlugin(env("BUILDKITE_PLUGINS", ""))

if err != nil {
log.Debug(err)
log.Fatal(err)
}

Expand Down
2 changes: 2 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func (s Step) MarshalYAML() (interface{}, error) {
}

func initializePlugin(data string) (Plugin, error) {
log.Debugf("parsing plugin config: %v", data)

var pluginConfigs []map[string]json.RawMessage

if err := json.Unmarshal([]byte(data), &pluginConfigs); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ func TestPluginShouldHaveDefaultValues(t *testing.T) {

func TestPluginWithValidParameter(t *testing.T) {
param := ""
got, _ := initializePlugin(param)
got, err := initializePlugin(param)
expected := Plugin{}

assert.EqualError(t, err, "failed to parse plugin configuration")
assert.Equal(t, expected, got)
}

Expand Down
6 changes: 3 additions & 3 deletions tests/command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ EOM

assert_success

assert_output --partial "--- :one: monorepo-diff"
assert_output --partial "Running diff command: echo foo-service/"
assert_output --partial "Output from diff: \nfoo-service/"
assert_output --partial "--- running monorepo-diff"
assert_output --partial "Running diff command: echo foo-service/ \nbat-service/"
assert_output --partial "Output from diff: \nfoo-service/ \nbat-service/"

assert_output --partial << EOM
steps:
Expand Down

0 comments on commit c1ecdb9

Please sign in to comment.