Skip to content

Commit 900ffed

Browse files
authored
Merge pull request #3 from spaceapi-community/ci
Set up CI, enforce gofmt
2 parents 6715402 + 5917d51 commit 900ffed

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
# src: https://github.com/marketplace/actions/build-and-push-docker-images#keep-up-to-date-with-github-dependabot
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
7+
name: CI
8+
9+
jobs:
10+
test:
11+
name: run tests
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
16+
with:
17+
go-version: '^1.13.0'
18+
- name: Run tests
19+
run: go test
20+
21+
fmt:
22+
name: check code formatting with gofmt
23+
runs-on: ubuntu-22.04
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-go@v5
27+
with:
28+
go-version: '^1.13.0'
29+
- name: run gofmt
30+
run: diff -u <(echo -n) <(gofmt -d ./)

spaceapi_validator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ type ResultError struct {
2626

2727
// VersionValidationResult validation result per version
2828
type VersionValidationResult struct {
29-
Version string `json:"version"`
30-
Valid bool `json:"valid"`
31-
Errors []ResultError `json:"errors"`
29+
Version string `json:"version"`
30+
Valid bool `json:"valid"`
31+
Errors []ResultError `json:"errors"`
3232
}
3333

3434
// ValidationResult tells you if the provided string is a valid SpaceApi schema
3535
// and if not tells you what needs to be fixed
3636
type ValidationResult struct {
37-
Valid bool `json:"valid"`
38-
Schemas []VersionValidationResult `json:"version_validation"`
39-
Errors []ResultError `json:"errors"`
37+
Valid bool `json:"valid"`
38+
Schemas []VersionValidationResult `json:"version_validation"`
39+
Errors []ResultError `json:"errors"`
4040
}
4141

4242
// Validate a string to match jsonschema of SpaceApi
4343
func Validate(document string) (ValidationResult, error) {
44-
myResult := ValidationResult{ Valid: true }
44+
myResult := ValidationResult{Valid: true}
4545
if document == "" {
4646
return myResult, errors.New("document is empty")
4747
}

0 commit comments

Comments
 (0)