This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from kytrinyx/lint-maintainers
Lint maintainers
- Loading branch information
Showing
7 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"maintainers": [ | ||
{ | ||
"github_username": "alice", | ||
"show_on_website": false, | ||
} | ||
], | ||
"docs_url": "http://example.com/docs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"maintainers": [ | ||
{ | ||
"github_username": "alice", | ||
"show_on_website": false, | ||
"alumnus": false, | ||
"name": "Alice Jones", | ||
"bio": null | ||
} | ||
], | ||
"docs_url": "http://example.com/docs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package track | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
// MaintainerConfig contains the list of current and previous maintainers. | ||
// The files is used both to manage the GitHub maintainer team, as well | ||
// as to configure the display values for each maintainer on the Exercism | ||
// website. | ||
type MaintainerConfig struct { | ||
Maintainers []Maintainer `json:"maintainers"` | ||
DocsURL string `json:"docs_url"` | ||
} | ||
|
||
// Maintainer contains data about a track maintainer. | ||
type Maintainer struct { | ||
Username string `json:"github_username"` | ||
ShowOnWebsite bool `json:"show_on_website"` | ||
Alumnus bool `json:"alumnus"` | ||
Name string `json:"name"` | ||
Bio string `json:"bio"` | ||
LinkText string `json:"link_text"` | ||
LinkURL string `json:"link_url"` | ||
AvatarURL string `json:"avatar_url"` | ||
} | ||
|
||
// NewMaintainerConfig reads the maintainer config file, if present. | ||
func NewMaintainerConfig(path string) (MaintainerConfig, error) { | ||
mc := MaintainerConfig{} | ||
if _, err := os.Stat(path); os.IsNotExist(err) { | ||
return mc, nil | ||
} | ||
|
||
bytes, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return mc, err | ||
} | ||
err = json.Unmarshal(bytes, &mc) | ||
if err != nil { | ||
return mc, fmt.Errorf("invalid config %s -- %s", path, err.Error()) | ||
} | ||
return mc, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package track | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBrokenMaintainerConfig(t *testing.T) { | ||
if _, err := NewMaintainerConfig("../fixtures/broken-maintainers/config/maintainers.json"); err == nil { | ||
t.Errorf("Expected broken JSON") | ||
} | ||
} | ||
|
||
func TestValidMaintainerConfig(t *testing.T) { | ||
mc, err := NewMaintainerConfig("../fixtures/numbers/config/maintainers.json") | ||
if err != nil { | ||
t.Errorf("Expected valid JSON: %s", err) | ||
} | ||
assert.Equal(t, "alice", mc.Maintainers[0].Username) | ||
} | ||
|
||
func TestIgnoreMissingMaintainerConfig(t *testing.T) { | ||
_, err := NewMaintainerConfig("../fixtures/no-such-file.json") | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters