Skip to content

Commit b7caf0c

Browse files
authored
Add codefresh (#29)
* Add tests * use test/ folder for all tests * fix errors * fix 404s * organizations empty index fix * fix all content errors * Ignore img.shields.io * Upgrade build-harness * fix aws s3 sync command * pin build-harness to release
1 parent f31c84a commit b7caf0c

38 files changed

+195
-101
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
deploy.toml
2+
test
3+
test.toml
14
node_modules
25
.build-harness
36
build-harness/

.htmltest.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Directory to scan for HTML files.
2-
DirectoryPath: "public/"
2+
DirectoryPath: "test/"
33

44
# The file to look for when linking to a directory.
55
DirectoryIndex: "index.html"
@@ -25,12 +25,26 @@ CheckScripts: true
2525
# Fails when encountering an http:// link. Useful to prevent mixed content errors when serving over HTTPS.
2626
EnforceHTTPS: false
2727

28+
HTTPHeaders:
29+
User-Agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"
30+
2831
# Turns off image alt attribute checking.
2932
IgnoreAltMissing: true
3033

34+
# Turns off errors for links to directories without a trailing slash.
35+
IgnoreDirectoryMissingTrailingSlash: true
36+
37+
# When true prevents raising an error for links with href="#".
38+
IgnoreInternalEmptyHash: true
39+
3140
# Array of regexs of URLs to ignore.
3241
IgnoreURLs:
42+
# LinkedIn blocks all crawlers and AWS
3343
- "linkedin.com"
44+
# Related to: https://github.com/wjdp/htmltest/issues/89
45+
- "marketplace.visualstudio.com"
46+
# Rate limiting precludes us from testing these
47+
- "img.shields.io"
3448

3549
# IgnoreDirs
3650
IgnoreDirs:

Makefile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ export HUGO ?= hugo
33
export HUGO_VERSION ?= 0.40.2
44
export HUGO_URL ?= http://localhost.cloudposse.com:1313/
55
export HUGO_ARGS ?= --watch --buildDrafts
6+
export HUGO_CONFIG ?= config.toml
7+
export HUGO_PUBLISH_DIR ?= public
68
export PACKAGES_VERSION ?= 0.1.7
9+
export HTMLTEST_LOG_LEVEL ?= 2
710

811
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
912

@@ -21,13 +24,36 @@ run:
2124

2225
## Generate all static content (outputs to public/)
2326
build:
24-
rm -rf public/
25-
$(HUGO)
27+
@[ "$(HUGO_PUBLISH_DIR)" != "/" ] || (echo "Invalid HUGO_PUBLISH_DIR=$(HUGO_PUBLISH_DIR)"; exit 1)
28+
rm -rf $(HUGO_PUBLISH_DIR)
29+
$(HUGO) --config $(HUGO_CONFIG)
2630

2731
## Lint check all hugo code
2832
lint:
2933
hugo --renderToMemory
3034

3135
## Validate all html is good
32-
validate: lint
33-
htmltest
36+
validate: lint test
37+
38+
.PHONY : test
39+
## Run tests
40+
test:
41+
htmltest --log-level $(HTMLTEST_LOG_LEVEL)
42+
43+
## Run smoketest
44+
smoketest:
45+
make release build test HUGO_URL=/ HUGO_CONFIG=test.toml HUGO_PUBLISH_DIR=test
46+
47+
## Generate a release config
48+
release:
49+
@[ "$(HUGO_CONFIG)" != "config.toml" ] || (echo "Cannot release with $(HUGO_CONFIG)"; exit 1)
50+
cat config.toml | \
51+
sed 's,^baseURL.*,baseURL = "$(HUGO_URL)",' | \
52+
sed 's,^publishDir.*,publishDir = "$(HUGO_PUBLISH_DIR)",' \
53+
> $(HUGO_CONFIG)
54+
@echo "Wrote $(HUGO_CONFIG) for $(HUGO_URL)..."
55+
56+
## Deploy static site to S3
57+
deploy:
58+
aws s3 sync --delete --acl public-read --exact-timestamps $(HUGO_PUBLISH_DIR)/ s3://$(S3_BUCKET_NAME)/
59+

codefresh.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build a service with environment variables
2+
version: '1.0'
3+
4+
steps:
5+
init_variables:
6+
title: Init variables
7+
image: alpine
8+
commands:
9+
- cf_export BUILD_HARNESS_VERSION=0.5.5
10+
- cf_export HUGO_URL=https://${{S3_BUCKET_NAME}}
11+
- cf_export HUGO_CONFIG=deploy.toml
12+
13+
build:
14+
title: Build Hugo static site
15+
image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}}
16+
working_directory: ./
17+
commands:
18+
- make deps
19+
- make release
20+
- make build
21+
22+
test:
23+
title: Run tests
24+
image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}}
25+
working_directory: ./
26+
commands:
27+
- make deps
28+
- make smoketest
29+
30+
deploy:
31+
title: Push all artifacts to S3 bucket
32+
image: cloudposse/build-harness:${{BUILD_HARNESS_VERSION}}
33+
working_directory: ./
34+
commands:
35+
- make deploy
36+
when:
37+
condition:
38+
all:
39+
executeForMasterBranch: "'${{CF_BRANCH}}' == 'master'"

config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defaultContentLanguage = "en"
99
defaultContentLanguageInSubdir= false
1010
enableMissingTranslationPlaceholders = false
1111

12+
publishDir = "public"
1213

1314
enableEmoji = true
1415
# [Languages]

content/_header.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

content/aws/organizations/_index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: AWS Organizations
33
excerpt: ''
4-
draft: true
54
tags:
65
- aws
76
- organizations

content/development/editor-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ indent_size = 4
7070
Find all plugins here: <http://editorconfig.org/#download>
7171

7272
- [Vim](https://github.com/editorconfig/editorconfig-vim#readme)
73-
- [Visual Studio](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
73+
- [Visual Studio](https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig)
7474

7575
# References
7676

content/devops-methodology/root-cause-analysis-postmortem/postmortem-example.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ The site experienced the classic cascading failure that affected all components
7474

7575
## Unexplained problems
7676

77-
- During the rollout, API keys for the `amazon-associates-link-builder` plugin got cleared ![](/assets/e82e21a-image_10.png)
78-
- During the rollout, TablePress options got cleared ![](/assets/4204bed-image_11.png)
77+
- During the rollout, API keys for the `amazon-associates-link-builder` plugin got cleared ![Amazon Associates Link Builder Credentials Lost](/assets/e82e21a-image_10.png)
78+
- During the rollout, TablePress options got cleared ![TablePress Options Reset](/assets/4204bed-image_11.png)
7979

8080
## Remediations
8181

@@ -92,7 +92,7 @@ List of actions performed to resolve the problem:
9292

9393
### Short term
9494

95-
- Varnish health probe should ping synthetic URI (e.g. /healthcheck) that only tests varnish, [not backends](https://github.com/gadgetreview/wordpress/blob/master/.ebextensions/80-monit.config#L174)
95+
- Varnish health probe should ping synthetic URI (e.g. /healthcheck) that only tests varnish, not backends
9696
- PHP-FPM should not use persistent mysqli connections
9797
- Ensure wp-plugins are all explicitly activated/deactivated as part of deployment
9898
- Investigate what happens if wordpress plugin activated before all servers upgraded
@@ -126,7 +126,7 @@ Prior to rollout, all 3 production instances indicated high memory pressure (90%
126126

127127
### Elastic Beanstalk
128128

129-
ElasticBeanstalk saw a massive increase in requests which manifested as a Denial of Service Attack. This was triggered probably by mod_pagespeed generating pages for webp assets which could not be served by upgraded servers. Varnish does not cache 404s.
129+
ElasticBeanstalk saw a massive increase in requests which manifested as a Denial of Service Attack. This was triggered probably by mod_pagespeed generating pages for webp assets which could not be served by upgraded servers. Varnish does not cache 404s.
130130

131131
{{< img src="/assets/af54926-image_15.png" title="ElasticBeanstalk Request Spike" >}}
132132

content/geodesic/module/usage/with-kops.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ terraform plan
4444
terraform apply
4545
```
4646

47-
![](/assets/b5e88dd-joany-staging-kops-state.png)
47+
![Staging Cluster State](/assets/b5e88dd-joany-staging-kops-state.png)
48+
4849
The public and private SSH keys are created and stored automatically in the encrypted S3 bucket.
4950

50-
![](/assets/9d5dc1c-joany-staging-kops-state-ssh-keys.png)
51+
![Staging Kops SSH Keys](/assets/9d5dc1c-joany-staging-kops-state-ssh-keys.png)
52+
5153
From the Terraform outputs, copy the `zone_name` and `bucket_name` into the ENV vars `CLUSTER_NAME` and `KOPS_STATE_STORE` in the `Dockerfile`.
5254

5355
# Build Manifest

0 commit comments

Comments
 (0)