Skip to content

Commit

Permalink
Missing title in engine/tutorials/index.md - add framework for CI che…
Browse files Browse the repository at this point in the history
…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
Adrien Duermael authored and johndmulhausen committed Dec 5, 2016
1 parent 8d4eab5 commit 99ab738
Show file tree
Hide file tree
Showing 29 changed files with 11,351 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Jenkinsfile
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"
}
1 change: 1 addition & 0 deletions engine/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ description: Explains how to work with containers
keywords: docker, introduction, documentation, about, technology, docker.io, user, guide, user's, manual, platform, framework, home, intro
redirect_from:
- /engine/userguide/containers/
title: Engine tutorials
---

# Learn by example
Expand Down
12 changes: 12 additions & 0 deletions tests/Dockerfile
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"]
12 changes: 12 additions & 0 deletions tests/src/validator/main_test.go
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())
}
61 changes: 61 additions & 0 deletions tests/src/validator/markdown_test.go
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 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.

2 changes: 2 additions & 0 deletions tests/src/vendor/github.com/gdevillele/frontparser/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 99ab738

Please sign in to comment.