Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

V3 Upgrades Part 1 #186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out/
dist/
build/*tgz

# dep
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ go:
- 1.15
- tip

matrix:
allow_failures:
- go: tip
fast_finish: true

install: true

before_install:
Expand Down
38 changes: 19 additions & 19 deletions cmd/fmt_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ func ExampleFormatVerboseFlag() {
runFmt("../fixtures/format/unformatted/", unformattedDir)

// Output:
//-> ../fixtures/format/unformatted/config.json
// -> ../fixtures/format/unformatted/config.json
//
//@@ -11 +11,2 @@
//@@ -16 +16,2 @@
//-{
//+ {
//+ "slug": "one",
//@@ -13 +13,0 @@
//@@ -18 +18,0 @@
//- "slug": "one",
//@@ -14,0 +15 @@
//@@ -19,0 +20 @@
//+ "auto_approve": true,
//@@ -17 +17,0 @@
//@@ -22 +22,0 @@
//- "auto_approve": true,
//@@ -19,4 +19,4 @@
//@@ -24,4 +24,4 @@
//- "Control-flow (conditionals)",
//- "Logic",
//- "Booleans",
Expand All @@ -51,11 +51,11 @@ func ExampleFormatVerboseFlag() {
//+ "control_flow_conditionals",
//+ "integers",
//+ "logic"
//@@ -25,0 +26 @@
//@@ -30,0 +31 @@
//+ "slug": "two",
//@@ -27 +27,0 @@
//@@ -32 +32,0 @@
//- "slug": "two",
//@@ -32,5 +32,8 @@
//@@ -37,5 +37,8 @@
//- "Time",
//- "Mathematics",
//- "Text formatting",
Expand All @@ -79,7 +79,7 @@ func ExampleFormatVerboseFlag() {
//+ "maintainers": []
//
//-> changes made to:
// ../fixtures/format/unformatted/config.json
/* ../fixtures/format/unformatted/config.json*/
//../fixtures/format/unformatted/config/maintainers.json
}

Expand Down Expand Up @@ -107,17 +107,17 @@ func ExampleFormatTestFlag() {
// Output:
//-> ../fixtures/format/unformatted/config.json
//
//@@ -11 +11,2 @@
//@@ -16 +16,2 @@
//-{
//+ {
//+ "slug": "one",
//@@ -13 +13,0 @@
//@@ -18 +18,0 @@
//- "slug": "one",
//@@ -14,0 +15 @@
//@@ -19,0 +20 @@
//+ "auto_approve": true,
//@@ -17 +17,0 @@
//@@ -22 +22,0 @@
//- "auto_approve": true,
//@@ -19,4 +19,4 @@
//@@ -24,4 +24,4 @@
//- "Control-flow (conditionals)",
//- "Logic",
//- "Booleans",
Expand All @@ -126,11 +126,11 @@ func ExampleFormatTestFlag() {
//+ "control_flow_conditionals",
//+ "integers",
//+ "logic"
//@@ -25,0 +26 @@
//@@ -30,0 +31 @@
//+ "slug": "two",
//@@ -27 +27,0 @@
//@@ -32 +32,0 @@
//- "slug": "two",
//@@ -32,5 +32,8 @@
//@@ -37,5 +37,8 @@
//- "Time",
//- "Mathematics",
//- "Text formatting",
Expand All @@ -154,6 +154,6 @@ func ExampleFormatTestFlag() {
//+ "maintainers": []
//
//-> no changes were made to:
// ../fixtures/format/unformatted/config.json
/* ../fixtures/format/unformatted/config.json*/
//../fixtures/format/unformatted/config/maintainers.json
}
21 changes: 20 additions & 1 deletion cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ func lintTrack(path string) bool {
return true
}

if t.Config.Version < 3 {
ui.PrintError("config.json has a missing or invalid version: ",
t.Config.Version)
return true
}

switch t.Config.OnlineEditor.IndentStyle {
case "space", "tabs":
break
default:
ui.PrintError("config.json - missing or invalid indent_style: ",
t.Config.OnlineEditor.IndentStyle)
return true
}
ind := t.Config.OnlineEditor.IndentSize
if ind < 1 || ind > 16 {
ui.PrintError("config.json - missing or invalid indent_size: ", ind)
return true
}

if trackID != "" {
t.ID = trackID
}
Expand Down Expand Up @@ -139,7 +159,6 @@ func lintTrack(path string) bool {
hasErrors = true
for _, item := range failedItems {
ui.Print(fmt.Sprintf(configError.msg, item))

}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ func TestLintTrack(t *testing.T) {
expected bool
}{
{
desc: "should fail when given a track containing one or more lint failures.",
desc: "should fail when a track contains one or more lint failures.",
path: "../fixtures/numbers",
expected: true,
},
{
desc: "should fail when given a track containing malformed configuration data.",
desc: "should fail when a track contains malformed configuration data.",
path: "../fixtures/broken-maintainers",
expected: true,
},
{
desc: "should fail when given a track missing READMEs.",
desc: "should fail when a track is missing a README.",
path: "../fixtures/missing-readme",
expected: true,
},
Expand Down
5 changes: 5 additions & 0 deletions fixtures/format/formatted/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"version": 3,
"online_editor": {
"indent_style": "space",
"indent_size": 4
},
"language": "Numbers",
"active": true,
"blurb": "",
Expand Down
3 changes: 2 additions & 1 deletion fixtures/format/malformed/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"blurb": "", "active": true,
"blurb": "", "active": true, "version": 3,
"online_editor": { "indent_style": "space", "indent_size": 4 },
"exercises": [ {
"core": false,
"auto_approve": true,
Expand Down
5 changes: 5 additions & 0 deletions fixtures/format/semantics/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"version": 3,
"online_editor": {
"indent_style": "space",
"indent_size": 4
},
"language": "Nope",
"active": false,
"blurb": "",
Expand Down
5 changes: 5 additions & 0 deletions fixtures/format/unformatted/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"version": 3,
"online_editor": {
"indent_style": "tab",
"indent_size": 2
},
"language": "Numbers",
"active": true,
"blurb": "",
Expand Down
5 changes: 5 additions & 0 deletions fixtures/lint/valid-track/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"slug": "valid-track",
"version": 3,
"online_editor": {
"indent_style": "space",
"indent_size": 4
},
"language": "Valid Track",
"repository": "https://github.com/exercism/valid-track",
"active": true,
Expand Down
5 changes: 5 additions & 0 deletions fixtures/numbers/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"slug": "numbers",
"version": 3,
"online_editor": {
"indent_style": "space",
"indent_size": 4
},
"language": "Numbers",
"repository": "https://github.com/exercism/numbers",
"active": true,
Expand Down
7 changes: 6 additions & 1 deletion track/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ type ExerciseMetadata struct {

// Config is an Exercism track configuration.
type Config struct {
TrackID string `json:"track_id,omitempty"`
TrackID string `json:"track_id,omitempty"`
Version int `json:"version"`
OnlineEditor struct {
IndentStyle string `json:"indent_style"`
IndentSize int `json:"indent_size"`
} `json:"online_editor"`
Language string `json:"language"`
Active bool `json:"active"`
Blurb string `json:"blurb"`
Expand Down