Skip to content

Commit

Permalink
[docsy][CI] Add check-links workflow (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Nov 21, 2024
1 parent 031cd6b commit 9e74043
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: Files

on:
merge_group:
pull_request:
push: { branches: [main] }

jobs:
# check-filenames:
# name: FILENAME check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - run: npm run check:filenames
check-filenames:
name: FILENAME check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run check:filenames

check-formatting:
name: FILE FORMAT
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Links

on:
merge_group:
pull_request:
push: { branches: [main] }

jobs:
build-and-check-links:
name: BUILD and CHECK LINKS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Create NPM cache-hash input file
run: |
mkdir -p tmp
jq '{devDependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: tmp/package-ci.json

- run: npm install --omit=optional

- run: npm run check:links
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,35 @@
"_build": "npm run _hugo-dev --",
"_check:format": "npx prettier --check .",
"_check:links": "make check-links",
"_check:links--warn": "npm run _check:links || (echo; echo 'WARNING: see link-checker output for issues.'; echo)",
"_filename-error": "echo 'ERROR: the following files violate naming conventions; fix using: `npm run fix:filenames`'; echo; npm run -s _ls-bad-filenames; exit 1",
"_filenames-to-kebab-case": "find assets content -name '*_*' ! -name '[_.]*' -exec sh -c 'mv \"$1\" \"${1//_/-}\"' _ {} \\;",
"_get:submodule": "set -x && git submodule update --init ${DEPTH:- --depth 1}",
"_hugo": "hugo --cleanDestinationDir",
"_hugo-dev": "npm run _hugo -- -e dev -DFE",
"_hugo": "hugo --cleanDestinationDir",
"_ls-bad-filenames": "find assets content -name '*_*' ! -name '[_.]*'",
"_prepare:docsy": "cd themes/docsy && npm install",
"_serve": "npm run _hugo-dev -- --minify serve",
"build:preview": "npm run _hugo-dev -- --minify --baseURL \"${DEPLOY_PRIME_URL:-http://localhost}\"",
"build:production": "npm run _hugo -- --minify",
"build": "npm run _build --",
"check:filenames": "test -z \"$(npm run -s _ls-bad-filenames)\" || npm run -s _filename-error",
"check:format": "npm run _check:format || (echo '[help] Run: npm run fix:format'; exit 1)",
"check:links:all": "HTMLTEST_ARGS= npm run _check:links",
"check:links": "npm run _check:links",
"clean": "rm -Rf public",
"fix:filenames": "npm run _filenames-to-kebab-case",
"fix:format": "npm run _check:format -- --write",
"get:submodule": "npm run _get:${GET:-submodule}",
"make:public": "git init -b main public",
"postbuild:preview": "npm run _check:links--warn",
"postbuild:production": "npm run _check:links--warn",
"precheck:links:all": "npm run build",
"precheck:links": "npm run build",
"postbuild:preview": "npm run _check:links",
"postbuild:production": "npm run _check:links",
"prepare": "npm run seq -- get:submodule _prepare:docsy",
"seq": "bash -c 'for cmd in \"$@\"; do npm run $cmd || exit 1; done' - ",
"serve": "npm run _serve",
"test": "npm run check:format && npm run check:links",
"test": "npm run seq -- check:filenames check:format check:links",
"update:dep": "npm install --save-dev autoprefixer@latest postcss-cli@latest",
"update:pkgs": "npx npm-check-updates -u"
},
Expand All @@ -50,5 +56,6 @@
"prettier": {
"proseWrap": "always",
"singleQuote": true
}
},
"spelling": "cSpell:ignore docsy hugo HTMLTEST pkgs netlify precheck postbuild -"
}

0 comments on commit 9e74043

Please sign in to comment.