summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-10-11 03:56:30 -0300
committerEuAndreh <eu@euandre.org>2020-10-11 04:19:20 -0300
commit6d2fae4d2749d893f5d027d5b4756e709a3847af (patch)
treed99d02b8039e233d2e5ae833b2752ef144274ffc /scripts
parentMark slides + article on feature flags as unpublished (diff)
downloadeuandre.org-6d2fae4d2749d893f5d027d5b4756e709a3847af.tar.gz
euandre.org-6d2fae4d2749d893f5d027d5b4756e709a3847af.tar.xz
Decouple testing with Nix
Use Nix for build isolation not for test running.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/assert-content.sh25
-rwxr-xr-xscripts/assert-nixfmt.sh16
-rwxr-xr-xscripts/assert-shellcheck.sh6
-rwxr-xr-xscripts/assert-spelling.sh36
-rwxr-xr-xscripts/assert-todos.sh12
-rw-r--r--scripts/publish-env.sh4
-rw-r--r--scripts/spelling/en.txt39
-rw-r--r--scripts/spelling/fr.txt8
-rw-r--r--scripts/spelling/international.txt142
-rw-r--r--scripts/spelling/pt.txt127
10 files changed, 394 insertions, 21 deletions
diff --git a/scripts/assert-content.sh b/scripts/assert-content.sh
index a0d661f..e694580 100755
--- a/scripts/assert-content.sh
+++ b/scripts/assert-content.sh
@@ -8,23 +8,8 @@ red() { echo -e "${red}${1}${end}"; }
## Constant definitions
-JSON="${1:-}"
-[[ -z "${JSON}" ]] && {
- red 'Missing input JSON file.'
- cat <<EOF
-Usage:
- $0 <SITE_JSON_PATH>
-
- Arguments
- SITE_JSON_PATH Path to the site.json file which contains data and metadata about pages of the site.
-
-Examples:
- $0 _site/site.json
- $0 result/site.json
- $0 \$(nix-build -A subtasks.docs)/site.json
-EOF
- exit 2
-}
+jekyll build
+JSON='_site/site.json'
LANGS=(en pt fr)
IGNORED_PAGES=(site.json sitemap.xml *.atom)
@@ -138,6 +123,11 @@ for til in $(jq -r '.tils[] | @base64' "${JSON}"); do
assert-frontmatter "$til" 'post' '_tils'
done
+echo Linting slides... >&2
+for slide in $(jq -r '.slides[] | @base64' "${JSON}"); do
+ assert-frontmatter "$slide" 'post' '_slides'
+done
+
echo Asserting unique refs... >&2
KNOWN_IDS=()
assert-unique-ref() {
@@ -163,5 +153,6 @@ assert-unique-ref() {
assert-unique-ref "$(jq -r '.pages[] | @base64' "${JSON}")"
assert-unique-ref "$(jq -r '.articles[] | @base64' "${JSON}")"
assert-unique-ref "$(jq -r '.tils[] | @base64' "${JSON}")"
+assert-unique-ref "$(jq -r '.slides[] | @base64' "${JSON}")"
echo Done. >&2
diff --git a/scripts/assert-nixfmt.sh b/scripts/assert-nixfmt.sh
new file mode 100755
index 0000000..7a68fa9
--- /dev/null
+++ b/scripts/assert-nixfmt.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+cd ../
+
+format() {
+ nix_file="${1}"
+ diff <(nixfmt < "${nix_file}") "${nix_file}" || {
+ echo "The file '${nix_file}' is unformatted. To fix it, run:"
+ echo " nixfmt ${nix_file}"
+ exit 1
+ }
+}
+export -f format
+
+find . -type f -name '*.nix' -print0 | xargs -0 -I% bash -c "format %"
diff --git a/scripts/assert-shellcheck.sh b/scripts/assert-shellcheck.sh
new file mode 100755
index 0000000..e24c29c
--- /dev/null
+++ b/scripts/assert-shellcheck.sh
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+cd ../
+
+git ls-files | grep '\.sh$' | xargs shellcheck
diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh
new file mode 100755
index 0000000..caaecfa
--- /dev/null
+++ b/scripts/assert-spelling.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+cd ../
+
+export LANG=C.UTF-8
+
+for DICT in scripts/spelling/*.txt; do
+ diff <(sort "$DICT") "$DICT" || {
+ echo "The $DICT dictionary is unsorted. To fix it, run:" >&2
+ echo " LANG=C.UTF-8 sort docs/$DICT | sponge docs/$DICT" >&2
+ exit 1
+ }
+done
+
+OUT="$(mktemp)"
+shopt -s globstar
+jekyll build
+for f in _site/**/*.html; do
+ if ! grep -E '^_site/pastebin' <(echo "$f") > /dev/null; then
+ if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then
+ l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)"
+ hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT"
+ fi
+ fi
+done
+
+if [[ -s "$OUT" ]]; then
+ printf "\nvvv Mispelled words detected by hunspell.\n\n"
+ sort < "$OUT" | uniq
+ printf "\n^^^\n" >&2
+ exit 1
+else
+ echo "No spelling errors detected"
+ exit 0
+fi
diff --git a/scripts/assert-todos.sh b/scripts/assert-todos.sh
new file mode 100755
index 0000000..a59b4cd
--- /dev/null
+++ b/scripts/assert-todos.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+cd ../
+
+# shellcheck disable=2046
+if grep -R FIXME $(git ls-files) | \
+ grep -Ev '^(vendor/|.git/|scripts/assert-todos.sh|templates)'; then
+ echo "Found dangling FIXME markers on the project."
+ echo "You should write them down properly on TODOs.org."
+ exit 1
+fi
diff --git a/scripts/publish-env.sh b/scripts/publish-env.sh
deleted file mode 100644
index d5e8be2..0000000
--- a/scripts/publish-env.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env bash
-
-export SERVER_URL=root@euandre.org
-export DOCS_SERVER_PATH="/home/user-data/www/default/"
diff --git a/scripts/spelling/en.txt b/scripts/spelling/en.txt
new file mode 100644
index 0000000..bebfc76
--- /dev/null
+++ b/scripts/spelling/en.txt
@@ -0,0 +1,39 @@
+Patches
+Rollout
+Slides
+aren
+autocommit
+backend
+behaviour
+couldn
+cronjobs
+curation
+declaratively
+decrypting
+didn
+doesn
+duplications
+embeddable
+filesystem
+filesystems
+isn
+maintainence
+oday
+portuguese
+portuguse
+pre
+programmatically
+realising
+reimplementation
+repo
+reproducibility
+scriptable
+shouldn
+symlinks
+syncable
+só
+tradeoffs
+untrusted
+ve
+wasn
+wouldn
diff --git a/scripts/spelling/fr.txt b/scripts/spelling/fr.txt
new file mode 100644
index 0000000..aa09184
--- /dev/null
+++ b/scripts/spelling/fr.txt
@@ -0,0 +1,8 @@
+'
+AJA
+dimanche
+earned
+oday
+ppris
+só
+ujourd'hui
diff --git a/scripts/spelling/international.txt b/scripts/spelling/international.txt
new file mode 100644
index 0000000..3536249
--- /dev/null
+++ b/scripts/spelling/international.txt
@@ -0,0 +1,142 @@
+144p
+1D
+250GB
+2D
+2nix
+32GB
+500GB
+81F90EC3CD356060
+8GB
+André
+Atom
+B1
+BN
+BSON
+BY
+BY-SA
+Bitbucket
+CI
+CLI
+Cantrill
+Clojure
+CouchDB
+DVCS
+Datomic
+EuAndreh
+F
+FFI
+FTS
+Fastmail
+GADTs
+GPLv
+GPLv3
+GTK
+GitLab
+Gmail
+GuixSD
+HN
+HTTPS
+Halloway
+Haskell
+IndexedDB
+JS
+JSON
+Joyent
+L1
+LaTeX
+Lerna
+LilyPond
+LiquidHaskell
+Mailutils
+Matroska
+Mentat
+Merkle
+NPM
+Nextcloud
+NixOS
+POSIX
+Pastebin
+PouchDB
+README
+RSS
+Raku
+Reddit
+SA
+SSD
+Sourcehut
+Spacemacs
+StackOverflow
+Staltz
+TAB
+TBs
+TOML
+TypeScript
+UI
+URL
+VPN
+WebAssembly
+Yandex
+YouTube
+Zig
+boneco
+brainer
+buildGoModule
+cargo2nix
+carte
+cgit
+ci
+clojure
+datalog
+datom
+datoms
+dl
+edn
+en
+euandreh
+eval
+fr
+gcrypt
+gt
+guix
+guixbuild
+h1
+h6
+hinarioespirita
+html
+i5
+i7
+ify
+intbytes
+ish
+jekyll
+jemoji
+js
+kramdown
+libre
+lockfile
+lockfiles
+lt
+merkle
+myrepos
+nixos
+no-brainer
+node2nix
+noinform
+npm
+org
+pastebin
+pastebins
+plaintext
+progn
+pt
+sbcl
+songbooks
+sourcehut
+sr
+swift2nix
+systemd
+touchpad
+v8
+xyz
+youtube
diff --git a/scripts/spelling/pt.txt b/scripts/spelling/pt.txt
new file mode 100644
index 0000000..65d4ac8
--- /dev/null
+++ b/scripts/spelling/pt.txt
@@ -0,0 +1,127 @@
+Abaixo
+Agosto
+Anna
+Aprendi
+Atualizado
+Blog
+Cópia
+H
+HEA
+I
+L
+Lista
+Me
+Patches
+Postado
+Postagens
+Quando
+T
+Usar
+Visite
+Website
+achar
+arquivo
+artigos
+buscar
+categoria
+chegar
+comece
+comentário
+como
+completar
+conhecimentos
+contatar
+criar
+código
+da
+dados
+de
+desta
+diretamente
+direto
+discussão
+discussões
+distribuir
+do
+dobráveis
+dou eu
+e
+earned
+email
+empacotá
+encontra
+engasgo
+entrada
+envelope
+escreva
+escrever
+escrevo
+esforço
+estou
+eu
+existentes
+extra
+fazer
+ficou
+formatos
+gerar
+impressão
+inglês
+interessantes
+internet
+intervalos
+jeito
+las
+licenciado
+licença
+log
+los
+mandar
+mande
+me
+mensagem
+na
+navegador
+no
+nome
+normalmente
+novo
+o
+oday
+oje
+ordená
+os
+padrão
+para
+parar
+pessoal
+por
+post
+postagens
+prendi
+procurando
+procure
+produção
+projetos
+pública
+público
+relacionados
+reler
+religioso
+se
+significa
+simples
+sobre
+tempo
+texto
+timestamp
+transpor
+u
+usando
+usar
+versão
+versões
+vindas
+Ícone
+úteis