Skip to content

Commit 53bf907

Browse files
authored
ci: render with dhall, add more checks (#2)
1 parent 642e4d9 commit 53bf907

23 files changed

+485
-48
lines changed

.editorconfig

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
root = true
2+
3+
[*]
4+
insert_final_newline = true
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[*.go]
12+
indent_style = tab
13+
14+
[{*.js,*.json,*.yml,*.md,.babelrc,.stylelintrc}]
15+
indent_size = 2
16+
17+
[*.md]
18+
trim_trailing_whitespace = false
19+
20+
[{*.sh, *.bash}]
21+
indent_style = space
22+
indent_size = 2
23+
switch_case_indent = true
24+
25+
[**/node_modules/**]
26+
ignore = true

.github/workflows/ci.yaml

+119-41
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,126 @@
1-
name: CI
2-
3-
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
8-
1+
# Code generated by dhall-to-yaml. DO NOT EDIT.
92
jobs:
3+
checkDocs:
4+
name: "Rendered 'docs/' is up to date"
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: checkout
8+
uses: "actions/checkout@master"
9+
with:
10+
submodules: recursive
11+
- name: Install asdf
12+
uses: "asdf-vm/actions/[email protected]"
13+
- name: Install asdf plugins
14+
uses: scripts/ci/asdf-add-plugins.sh
15+
- name: Install asdf tools versions
16+
uses: scripts/ci/asdf-install.sh
17+
- name: "Check that 'docs' folder is up to date"
18+
run: scripts/ci/check-rendered-site-up-to-date.sh
19+
checkPipeline:
20+
name: Rendered CI pipeline is up to date
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: checkout
24+
uses: "actions/checkout@master"
25+
with:
26+
submodules: recursive
27+
- name: Install asdf
28+
uses: "asdf-vm/actions/[email protected]"
29+
- name: Install asdf plugins
30+
uses: scripts/ci/asdf-add-plugins.sh
31+
- name: Install asdf tools versions
32+
uses: scripts/ci/asdf-install.sh
33+
- name: Check that the CI pipeline definition is up-to-date with the dhall configuration
34+
run: scripts/ci/check-rendered-site-up-to-date.sh
35+
dhallFormat:
36+
name: dhall-format
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: checkout
40+
uses: "actions/checkout@master"
41+
with:
42+
submodules: recursive
43+
- name: Install asdf
44+
uses: "asdf-vm/actions/[email protected]"
45+
- name: Install asdf plugins
46+
uses: scripts/ci/asdf-add-plugins.sh
47+
- name: Install asdf tools versions
48+
uses: scripts/ci/asdf-install.sh
49+
- env:
50+
CHECK: 'true'
51+
name: Check that dhall files are formatted
52+
run: scripts/dhall-format.sh
53+
dhallLint:
54+
name: dhall-format
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: checkout
58+
uses: "actions/checkout@master"
59+
with:
60+
submodules: recursive
61+
- name: Install asdf
62+
uses: "asdf-vm/actions/[email protected]"
63+
- name: Install asdf plugins
64+
uses: scripts/ci/asdf-add-plugins.sh
65+
- name: Install asdf tools versions
66+
uses: scripts/ci/asdf-install.sh
67+
- env:
68+
CHECK: 'true'
69+
name: Check that dhall files are linted properly
70+
run: scripts/dhall-format.sh
1071
prettier:
1172
name: Prettier formatting
1273
runs-on: ubuntu-latest
1374
steps:
14-
- uses: actions/checkout@master
15-
with:
16-
submodules: recursive
17-
18-
- name: Install asdf
19-
uses: asdf-vm/actions/[email protected]
20-
21-
- name: Install asdf plugins
22-
run: 'scripts/asdf-add-plugins.sh'
23-
24-
- name: Install asdf tools versions
25-
run: 'scripts/asdf-install.sh'
26-
27-
- name: Check Prettier formatting
28-
run: 'scripts/check-prettier.sh'
29-
30-
check-rendered-up-to-date:
31-
name: Rendered 'docs/' up to date
75+
- name: checkout
76+
uses: "actions/checkout@master"
77+
with:
78+
submodules: recursive
79+
- name: Install asdf
80+
uses: "asdf-vm/actions/[email protected]"
81+
- name: Install asdf plugins
82+
uses: scripts/ci/asdf-add-plugins.sh
83+
- name: Install asdf tools versions
84+
uses: scripts/ci/asdf-install.sh
85+
- name: Check Prettier formatting
86+
run: scripts/ci/check-prettier.sh
87+
shellcheck:
88+
name: shellcheck
89+
runs-on: ubuntu-latest
90+
steps:
91+
- name: checkout
92+
uses: "actions/checkout@master"
93+
with:
94+
submodules: recursive
95+
- name: Install asdf
96+
uses: "asdf-vm/actions/[email protected]"
97+
- name: Install asdf plugins
98+
uses: scripts/ci/asdf-add-plugins.sh
99+
- name: Install asdf tools versions
100+
uses: scripts/ci/asdf-install.sh
101+
- name: Lint shell scripts
102+
run: scripts/ci/shellcheck.sh
103+
shfmt:
104+
name: shfmt
32105
runs-on: ubuntu-latest
33106
steps:
34-
- uses: actions/checkout@master
35-
with:
36-
submodules: recursive
37-
38-
- name: Install asdf
39-
uses: asdf-vm/actions/[email protected]
40-
41-
- name: Install asdf plugins
42-
run: 'scripts/asdf-add-plugins.sh'
43-
44-
- name: Install asdf tools versions
45-
run: 'scripts/asdf-install.sh'
46-
47-
- name: Check that 'docs' folder is up to date
48-
run: 'scripts/check-rendered-site-up-to-date.sh'
107+
- name: checkout
108+
uses: "actions/checkout@master"
109+
with:
110+
submodules: recursive
111+
- name: Install asdf
112+
uses: "asdf-vm/actions/[email protected]"
113+
- name: Install asdf plugins
114+
uses: scripts/ci/asdf-add-plugins.sh
115+
- name: Install asdf tools versions
116+
uses: scripts/ci/asdf-install.sh
117+
- name: Check that scripts are formatted consistently
118+
run: scripts/ci/shfmt.sh
119+
name: CI
120+
on:
121+
pull_request:
122+
branches:
123+
- master
124+
push:
125+
branches:
126+
- master

.tool-versions

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
hugo 0.65.3
22
yarn 1.22.2
33
nodejs 13.10.1
4+
dhall 1.33.0
5+
shellcheck 0.7.1
6+
shfmt 3.1.1
7+
fd 7.4.0
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname ${BASH_SOURCE[0]})"/..
3+
cd "$(dirname "${BASH_SOURCE[0]}")"/../..
44
set -euxo pipefail
55

66
asdf plugin-add hugo https://github.com/beardix/asdf-hugo.git
7-
asdf plugin-add yarn
87

98
# https://github.com/asdf-vm/asdf-nodejs#install
109
asdf plugin-add nodejs
1110
~/.asdf/plugins/nodejs/bin/import-release-team-keyring
11+
12+
OTHER_PACKAGES=(
13+
"yarn"
14+
"dhall"
15+
"shellcheck"
16+
"shfmt"
17+
"fd"
18+
)
19+
20+
for package in "${OTHER_PACKAGES[@]}"; do
21+
asdf plugin-add "${package}"
22+
done
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname ${BASH_SOURCE[0]})"/..
3+
cd "$(dirname "${BASH_SOURCE[0]}")"/../..
44
set -euxo pipefail
55

66
asdf install

scripts/check-prettier.sh scripts/ci/check-prettier.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname ${BASH_SOURCE[0]})"/..
3+
cd "$(dirname ${BASH_SOURCE[0]})"/../..
44
set -euxo pipefail
55

66
yarn
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "${BASH_SOURCE[0]}")"/../..
4+
set -euxo pipefail
5+
6+
scripts/ci/render-ci-pipeline.sh
7+
8+
git diff --exit-code .github/workflows/ci.yaml

scripts/check-rendered-site-up-to-date.sh scripts/ci/check-rendered-site-up-to-date.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env bash
22

3-
cd "$(dirname ${BASH_SOURCE[0]})"/..
3+
cd "$(dirname ${BASH_SOURCE[0]})"/../..
44
set -euxo pipefail
55

6-
OUTPUT=`mktemp -d -t hugoTmpFolder_XXXXXXX`
6+
OUTPUT=$(mktemp -d -t hugoTmpFolder_XXXXXXX)
77
cleanup() {
8-
rm -rf "$OUTPUT"
8+
rm -rf "$OUTPUT"
99
}
1010
trap cleanup EXIT
1111

scripts/ci/dhall/imports.dhall

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let GitHubActions =
2+
https://raw.githubusercontent.com/ggilmore/github-actions-dhall/escape-keywords/package.dhall sha256:fc4617f320aaf431b916daef11d102f8ca4d9cb5759f9945cf3873844fa3b4f0
3+
4+
in { GitHubActions }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let GitHubActions = (../imports.dhall).GitHubActions
2+
3+
let Setup = ../setup.dhall
4+
5+
let SetupSteps = Setup.SetupSteps
6+
7+
let Job = Setup.Job
8+
9+
in Job::{
10+
, name = Some "Rendered 'docs/' is up to date"
11+
, steps =
12+
SetupSteps
13+
# [ GitHubActions.Step::{
14+
, name = Some "Check that 'docs' folder is up to date"
15+
, run = Some "scripts/ci/check-rendered-site-up-to-date.sh"
16+
}
17+
]
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let GitHubActions = (../imports.dhall).GitHubActions
2+
3+
let Setup = ../setup.dhall
4+
5+
let SetupSteps = Setup.SetupSteps
6+
7+
let Job = Setup.Job
8+
9+
in Job::{
10+
, name = Some "Rendered CI pipeline is up to date"
11+
, steps =
12+
SetupSteps
13+
# [ GitHubActions.Step::{
14+
, name = Some
15+
"Check that the CI pipeline definition is up-to-date with the dhall configuration"
16+
, run = Some "scripts/ci/check-rendered-site-up-to-date.sh"
17+
}
18+
]
19+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let GitHubActions = (../imports.dhall).GitHubActions
2+
3+
let Setup = ../setup.dhall
4+
5+
let SetupSteps = Setup.SetupSteps
6+
7+
let Job = Setup.Job
8+
9+
in Job::{
10+
, name = Some "dhall-format"
11+
, steps =
12+
SetupSteps
13+
# [ GitHubActions.Step::{
14+
, name = Some "Check that dhall files are formatted"
15+
, run = Some "scripts/dhall-format.sh"
16+
, env = Some (toMap { CHECK = "true" })
17+
}
18+
]
19+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let GitHubActions = (../imports.dhall).GitHubActions
2+
3+
let Setup = ../setup.dhall
4+
5+
let SetupSteps = Setup.SetupSteps
6+
7+
let Job = Setup.Job
8+
9+
in Job::{
10+
, name = Some "dhall-format"
11+
, steps =
12+
SetupSteps
13+
# [ GitHubActions.Step::{
14+
, name = Some "Check that dhall files are linted properly"
15+
, run = Some "scripts/dhall-format.sh"
16+
, env = Some (toMap { CHECK = "true" })
17+
}
18+
]
19+
}

scripts/ci/dhall/jobs/prettier.dhall

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let GitHubActions = (../imports.dhall).GitHubActions
2+
3+
let Setup = ../setup.dhall
4+
5+
let SetupSteps = Setup.SetupSteps
6+
7+
let Job = Setup.Job
8+
9+
in Job::{
10+
, name = Some "Prettier formatting"
11+
, steps =
12+
SetupSteps
13+
# [ GitHubActions.Step::{
14+
, name = Some "Check Prettier formatting"
15+
, run = Some "scripts/ci/check-prettier.sh"
16+
}
17+
]
18+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let GitHubActions = (../imports.dhall).GitHubActions
2+
3+
let Setup = ../setup.dhall
4+
5+
let SetupSteps = Setup.SetupSteps
6+
7+
let Job = Setup.Job
8+
9+
in Job::{
10+
, name = Some "shellcheck"
11+
, steps =
12+
SetupSteps
13+
# [ GitHubActions.Step::{
14+
, name = Some "Lint shell scripts"
15+
, run = Some "scripts/ci/shellcheck.sh"
16+
}
17+
]
18+
}

0 commit comments

Comments
 (0)