forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Missing title in engine/tutorials/index.md - add framework for CI che…
…cking (docker#763) * added title in engine/tutorials/index.md Signed-off-by: Adrien Duermael <adrien@duermael.com> * added pre_build script for Docker Cloud CI It includes one first test that should run when PRs are submitted. For now it only checks if there’s always a title in fronmatters. We should add more tests as we fix issues. Signed-off-by: Adrien Duermael <adrien@duermael.com> * Jenkinsfile + pre_build script update Signed-off-by: Adrien Duermael <adrien@duermael.com> * fix in Jenkinsfile Signed-off-by: Adrien Duermael <adrien@duermael.com> * chmod +x hooks/pre_build Signed-off-by: Adrien Duermael <adrien@duermael.com> * removed hooks folder since we’re not using Docker Cloud CI Signed-off-by: Adrien Duermael <adrien@duermael.com>
- Loading branch information
1 parent
8d4eab5
commit 99ab738
Showing
29 changed files
with
11,351 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
wrappedNode(label: 'linux && x86_64') { | ||
deleteDir() | ||
stage "checkout" | ||
checkout scm | ||
stage "test" | ||
sh "docker build -t tests `pwd`/tests" | ||
sh "docker run --rm -v `pwd`:/docs tests" | ||
sh "docker rmi tests" | ||
} |
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,12 @@ | ||
FROM golang:1.7.3-alpine | ||
MAINTAINER Gaetan de Villele <gaetan@docker.com> | ||
|
||
RUN apk update | ||
RUN apk add git | ||
|
||
COPY src /go/src | ||
WORKDIR /go/src/validator | ||
|
||
# when running the container, MOUNT docs repo in /docs | ||
|
||
CMD ["go", "test"] |
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 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
// TestMain is used to add extra setup or | ||
// teardown before or after testing | ||
func TestMain(m *testing.M) { | ||
os.Exit(m.Run()) | ||
} |
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,61 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/gdevillele/frontparser" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
// TestFrontmatterTitle tests if there's a title present in all | ||
// markdown frontmatters. | ||
func TestFrontmatterTitle(t *testing.T) { | ||
filepath.Walk("/docs", func(path string, info os.FileInfo, err error) error { | ||
err = testFrontmatterTitle(path) | ||
if err != nil { | ||
fmt.Println(err.Error(), "-", path) | ||
t.Fail() | ||
} | ||
return nil | ||
}) | ||
} | ||
|
||
// testFrontmatterTitle tests if there's a title present in | ||
// markdown file at given path | ||
func testFrontmatterTitle(path string) error { | ||
if strings.HasSuffix(path, ".md") { | ||
fileBytes, err := ioutil.ReadFile(path) | ||
if err != nil { | ||
return err | ||
} | ||
// if file has frontmatter | ||
if frontparser.HasFrontmatterHeader(fileBytes) { | ||
fm, _, err := frontparser.ParseFrontmatterAndContent(fileBytes) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// skip markdowns that are not published | ||
if published, exists := fm["published"]; exists { | ||
if publishedBool, ok := published.(bool); ok { | ||
if publishedBool == false { | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
if _, exists := fm["title"]; exists == false { | ||
return errors.New("can't find title in frontmatter") | ||
} | ||
} else { | ||
// no frontmatter is not an error | ||
// markdown files without frontmatter won't be considered | ||
return nil | ||
} | ||
} | ||
return nil | ||
} |
201 changes: 201 additions & 0 deletions
201
tests/src/vendor/github.com/gdevillele/frontparser/LICENSE
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.