-
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.
- Loading branch information
Showing
6 changed files
with
117 additions
and
12 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,31 @@ | ||
name: CI | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
name: Test URLs | ||
runs-on: ubuntu-18.04 | ||
|
||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13.x | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
|
||
- name: Test URLs on production | ||
run: go run scripts/test-urls.go https://fromcodetoprod.com/ | ||
|
||
- name: Setup Hugo | ||
run: make hugo | ||
|
||
- name: Serve local version | ||
run: make serve & | ||
|
||
- name: Wait | ||
run: sleep 1 | ||
|
||
- name: Test local URLs | ||
run: go run scripts/test-urls.go http://localhost:1313/ |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
/hugo | ||
|
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,14 @@ | ||
FROM busybox | ||
|
||
RUN wget https://github.com/gohugoio/hugo/releases/download/v0.60.1/hugo_0.60.1_Linux-64bit.tar.gz | ||
RUN echo '54efec73f8aca18a3fa90e539dbe3b3b53e5d0c802ee724b2cbc63dae2fc17d3 hugo_0.60.1_Linux-64bit.tar.gz' | sha256sum -cw | ||
RUN tar xzvf hugo_0.60.1_Linux-64bit.tar.gz hugo | ||
RUN ./hugo version | ||
RUN rm hugo_0.60.1_Linux-64bit.tar.gz | ||
|
||
VOLUME /site | ||
WORKDIR /site | ||
|
||
EXPOSE 1313 | ||
|
||
ENTRYPOINT ["/hugo"] |
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,2 @@ | ||
all: | ||
docker build --pull --squash --tag fromcodetoprod/hugo:dev . |
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,66 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"flag" | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
"net/url" | ||
"os" | ||
"regexp" | ||
) | ||
|
||
func main() { | ||
flag.Usage = func() { | ||
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [base URL]\n", os.Args[0]) | ||
flag.PrintDefaults() | ||
} | ||
flag.Parse() | ||
|
||
baseURL := flag.Arg(0) | ||
if baseURL == "" { | ||
fmt.Fprintf(flag.CommandLine.Output(), "base URL argument is required.\n\n") | ||
flag.Usage() | ||
os.Exit(2) | ||
} | ||
|
||
testURLs(baseURL) | ||
} | ||
|
||
func testURLs(baseURL string) { | ||
u, err := url.Parse(baseURL) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
for path, re := range map[string]*regexp.Regexp{ | ||
"/episodes/index.rss": regexp.MustCompile(`^<rss`), | ||
} { | ||
url := u.ResolveReference(&url.URL{ | ||
Path: path, | ||
}) | ||
if err = testURL(url.String(), re); err != nil { | ||
log.Printf("%s: %s", url, err) | ||
} | ||
} | ||
} | ||
|
||
func testURL(url string, re *regexp.Regexp) error { | ||
resp, err := http.Get(url) | ||
if err != nil { | ||
return err | ||
} | ||
defer resp.Body.Close() | ||
|
||
b, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !re.Match(b) { | ||
return errors.New("unexpected content") | ||
} | ||
return nil | ||
} |