Skip to content

Commit 7aa9f72

Browse files
committed
Use htmltest for faster validation
1 parent 10bfa33 commit 7aa9f72

File tree

12 files changed

+1433
-163
lines changed

12 files changed

+1433
-163
lines changed

.circleci/config.yml

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -77,56 +77,34 @@ jobs:
7777
message: "Build job failed for branch ${CIRCLE_BRANCH}"
7878

7979
validate:
80-
executor: ruby_executor
80+
executor: go_executor
8181
steps:
8282
- checkout
8383
- attach_workspace:
8484
at: .
85-
- run:
86-
name: Dependencies
87-
command: bundle install
88-
- run:
89-
name: html-proofer
90-
command: |
91-
# Handle path prefix and ignore search template placeholders
92-
htmlproofer ./build \
93-
--ignore-empty-alt \
94-
--checks 'Links,Images' \
95-
--disable-external \
96-
--swap-urls '^/docs/:/' \
97-
--ignore-files './build/api/v1/index.html,./build/api/v2/index.html' \
98-
--ignore-urls '[url],[path]'
85+
- go/with-cache:
86+
golangci-lint: true
87+
steps:
88+
- run: task mod-download
89+
- run: task ci:diff
90+
- run: task ci:lint
91+
- run: task validate-html
9992
- notify_error:
10093
message: "Validation job failed for branch ${CIRCLE_BRANCH}"
10194

10295
deploy-production:
10396
executor: go_executor
104-
parameters:
105-
bucket_name:
106-
description: The name of the s3 bucket where static assets are stored.
107-
type: string
10897
steps:
10998
- checkout
11099
- attach_workspace:
111100
at: .
112101
- aws-setup
113102
- go/with-cache:
114103
steps:
115-
- go/mod-download
116-
- run:
117-
name: Deploy Production Site to S3
118-
command: |
119-
echo "[INFO] Deploying production site..."
120-
dir=$(mktemp -d)
121-
mv build "${dir}/docs"
122-
aws s3 sync "${dir}" "s3://<< parameters.bucket_name >>/" \
123-
--delete
124-
- run:
125-
name: Deploy Redirects to S3
126-
command: go run ./cmd/create-redirects "<< parameters.bucket_name >>"
127-
- run:
128-
name: Validate Redirects
129-
command: go run ./cmd/validate-redirects https://circleci.com
104+
- run: task mod-download
105+
- run: task deploy
106+
- run: task deploy-redirects
107+
- run: task validate-redirects
130108
- notify_error:
131109
message: "Production deployment job failed for branch ${CIRCLE_BRANCH}"
132110

@@ -144,10 +122,12 @@ workflows:
144122
context: circleci-docs-static
145123

146124
- validate:
147-
requires: [build]
125+
requires:
126+
- build
148127

149128
- deploy-production:
150-
requires: [validate]
129+
requires:
130+
- validate
151131
filters:
152132
branches:
153133
only: main
@@ -156,4 +136,3 @@ workflows:
156136
- docs-platform-assets
157137
- web-ui-npm
158138
- web-ui-datadog
159-
bucket_name: "circleci-docs-platform-assets"

.gitignore

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
node_modules/
2-
build/
1+
/node_modules/
2+
/build/
33
**/.DS_Store
4-
ui-bundle.zip
5-
ui/build/
6-
ui/node_modules/
7-
ui/public/
8-
ui/**/.DS_Store
9-
extensions/.temp
10-
.env
11-
.vscode/
4+
/ui-bundle.zip
5+
/ui/build/
6+
/ui/node_modules/
7+
/ui/public/
8+
/ui/**/.DS_Store
9+
/extensions/.temp
10+
/.env
11+
/.vscode/
12+
/.htmltest
13+
/test-reports

.htmltest.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
DirectoryPath: "build"
2+
CheckExternal: false
3+
EnforceHTTPS: true
4+
CheckSelfReferencesAsInternal: true
5+
BaseURL: https://circleci.com/docs
6+
IgnoreAltEmpty: true
7+
IgnoreInternalEmptyHash: true
8+
IgnoreURLs:
9+
- "[url]"
10+
- "[path]"
11+
- "/docs/"
12+
- "/docs/_/img/x-icon.svg"
13+
IgnoreDirs:
14+
- "api"
15+
OutputDir: ".htmltest"

Gemfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 97 deletions
This file was deleted.

Taskfile.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
version: '3'
2+
3+
vars:
4+
BUCKET: "circleci-docs-platform-assets"
5+
RESULTS_DIR: test-reports
6+
TEST_REPORT: test-reports/tests.xml
7+
LINT_REPORT: test-reports/lint.xml
8+
9+
tasks:
10+
lint:
11+
desc: Run `golangci-lint run` to lint the code
12+
summary: Lint the project with golangci-lint
13+
vars:
14+
ARGS: '{{default "./..." .CLI_ARGS}}'
15+
cmds:
16+
- go tool golangci-lint run {{.ARGS}}
17+
18+
lint-migrate:
19+
desc: Migrate the `golangci-lint` config
20+
cmds:
21+
- go tool golangci-lint migrate
22+
23+
fmt:
24+
desc: Format the code
25+
vars:
26+
ARGS: '{{default "." .CLI_ARGS}}'
27+
cmds:
28+
- go tool gosimports -local "$(go list -m)" -w {{.ARGS}}
29+
30+
test:
31+
desc: Run the tests
32+
vars:
33+
ARGS: '{{default "./..." .CLI_ARGS}}'
34+
cmds:
35+
- mkdir -p {{.RESULTS_DIR}}
36+
- go tool gotestsum -- -race {{.ARGS}}
37+
38+
generate:
39+
desc: Run generation of any generated code
40+
vars:
41+
ARGS: '{{default "./..." .CLI_ARGS}}'
42+
cmds:
43+
- go generate -x {{.ARGS}}
44+
45+
mod-tidy:
46+
desc: Run 'go mod tidy' to clean up module files.
47+
cmds:
48+
- go mod tidy -v
49+
50+
mod-download:
51+
desc: Run 'go mod download' to retrieve module files.
52+
cmds:
53+
- go mod download -x
54+
55+
deploy:
56+
desc: Deploy to S3 bucket
57+
vars:
58+
TEMPDIR: $(mktemp -d)
59+
cmds:
60+
- defer: rm -rf "{{.TEMPDIR}}"
61+
- cp -r "./build" "{{.TEMPDIR}}/docs"
62+
- aws s3 sync "{{.TEMPDIR}}" "s3://{{.BUCKET}}/" --delete
63+
64+
deploy-redirects:
65+
desc: Build main
66+
cmds:
67+
- go run ./cmd/create-redirects {{.BUCKET}}
68+
69+
validate-redirects:
70+
desc: Build main
71+
cmds:
72+
- go run ./cmd/validate-redirects https://circleci.com
73+
74+
build:
75+
desc: Build docs
76+
cmds:
77+
- npm run build:docs
78+
79+
validate-html:
80+
desc: Validate HTML, links, etc
81+
cmds:
82+
- go tool htmltest
83+
84+
# Tasks for running the service locally
85+
86+
run-publicapi:
87+
desc: Run the public API
88+
cmds:
89+
- go run ./cmd/publicapi
90+
91+
run-internalapi:
92+
desc: Run the internal API
93+
cmds:
94+
- go run ./cmd/internalapi
95+
96+
# Tasks below here are intended mainly to be run as part of CI
97+
98+
ci:lint:
99+
desc: Run `golangci-lint run` to lint the code, outputting a report.
100+
cmds:
101+
- mkdir -p "{{.RESULTS_DIR}}"
102+
- task: lint
103+
vars:
104+
CLI_ARGS: |
105+
./... \
106+
--output.junit-xml.path "{{.LINT_REPORT}}" --output.junit-xml.extended \
107+
--output.text.path=stdout --output.text.colors=true
108+
109+
ci:test:
110+
desc: Run the tests and output the test results
111+
vars:
112+
ARGS: '{{default "./..." .CLI_ARGS}}'
113+
cmds:
114+
- mkdir -p {{.RESULTS_DIR}}
115+
- go tool gotestsum --junitfile="{{.TEST_REPORT}}" -- -race -count=1 {{.ARGS}}
116+
117+
ci:diff:
118+
desc: Check no diffs
119+
cmds:
120+
- task: generate
121+
- task: fmt
122+
- task: mod-tidy
123+
- git diff --exit-code

custom-template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<body>
7575
<!-- Clickable logo that routes to docs homepage -->
7676
<div class="custom-logo">
77-
<a href="../../reference/api-homepage" title="Back to CircleCI Documentation">
77+
<a href="../../reference/api-homepage/" title="Back to CircleCI Documentation">
7878
<img src="logo.svg" alt="CircleCI" />
7979
</a>
8080
</div>

docs/orbs/modules/author/pages/orb-author.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ steps:
318318
[#why-include-scripts]
319319
===== Why include scripts?
320320

321-
CircleCI configuration is written in `YAML`. Logical code such as `bash` can be encapsulated and executed on CircleCI through `YAML`, but, for developers, it is not convenient to write and test programmatic code within a non-executable format. Also, parameters can become cumbersome in more complex scripts as the `<<parameter>>` syntax is a CircleCI native YAML enhancement, and not something that can be interpreted and executed locally.
321+
CircleCI configuration is written in `YAML`. Logical code such as `bash` can be encapsulated and executed on CircleCI through `YAML`, but, for developers, it is not convenient to write and test programmatic code within a non-executable format. Also, parameters can become cumbersome in more complex scripts as the `\<<parameter>>` syntax is a CircleCI native YAML enhancement, and not something that can be interpreted and executed locally.
322322

323-
Using the orb development kit and the `<<include(file)>>` syntax, you can:
323+
Using the orb development kit and the `\<<include(file)>>` syntax, you can:
324324

325325
* Import existing scripts into your orb.
326326
* Locally execute and test your orb scripts.
@@ -329,7 +329,7 @@ Using the orb development kit and the `<<include(file)>>` syntax, you can:
329329
[#using-parameters-with-scripts]
330330
===== Using parameters with scripts
331331

332-
To keep your scripts portable and locally executable, it is best practice to expect a set of environment variables within your scripts and set them at the config level. The `greet.sh` file, which was included with the special `<<include(file)>>` syntax above in our `greet.yml` command file, looks like this:
332+
To keep your scripts portable and locally executable, it is best practice to expect a set of environment variables within your scripts and set them at the config level. The `greet.sh` file, which was included with the special `\<<include(file)>>` syntax above in our `greet.yml` command file, looks like this:
333333

334334
[,shell]
335335
----

0 commit comments

Comments
 (0)