Skip to content

Commit

Permalink
CI: check-links: enable caching and check for warnings (#3026)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Jul 13, 2023
1 parent 6851ff0 commit 47605c0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 7 deletions.
56 changes: 50 additions & 6 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,59 @@ on:
pull_request:

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

- run: npm install
- run: npm run build
- name: Create NPM cache-hash input file
run: |
mkdir -p tmp
jq '{devDependencies, dependencies, engines, gitHubActionCacheKey}' package.json > tmp/package-ci.json
- name: Create and use reduced-dependencies package.json
run: |
jq '.devDependencies |= with_entries(
select(.key | test("prefix|hugo|run|css"))
)
| del(.dependencies)' \
package.json > tmp/package-min.json
cp tmp/package-min.json package.json
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: tmp/package-ci.json

- run: npm install --no-optional
- run: npm run build+log
- run: npm run _check:links
- uses: actions/upload-artifact@v3
with:
name: build-log-etc
path: |
tmp/build-log.txt
tmp/package*.json
static/refcache.json
check-refcache:
name: REFCACHE updates?
needs: build-and-check-links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with: { name: build-log-etc }
- run: npm run diff:fail

- name: Fail on uncommitted refcache changes
run: npm run diff:fail
check-build-log-for-issues:
name: WARNINGS in build log?
needs: build-and-check-links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with: { name: build-log-etc }
- run: scripts/check-build-log.sh
1 change: 1 addition & 0 deletions .warnings-skip-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WARN docs/specs/opamp/index.md:.*semantic-conventions/tree/main/docs/resource
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"build:preview": "set -x && npm run _build -- --minify --baseURL \"${DEPLOY_PRIME_URL:-/}\"",
"build:production": "hugo --cleanDestinationDir --minify",
"build": "npm run _build",
"build+log": "npm run build | tee tmp/build-log.txt",
"cd:public": "cd public &&",
"check": "npm run all -- check:*",
"check:filenames": "test -z \"$(npm run -s _ls-bad-filenames)\" || npm run -s _filename-error",
Expand Down Expand Up @@ -100,10 +101,11 @@
"@opentelemetry/sdk-trace-web": "^1.8.0",
"@opentelemetry/semantic-conventions": "^1.8.0"
},
"engines-comment": "Ensure that engines.node value stays consistent with the project's .nvmrc",
"enginesComment": "Ensure that engines.node value stays consistent with the project's .nvmrc",
"engines": {
"node": "18.x"
},
"gitHubActionCacheKey": "2023-07-13 - change this key to force cache refresh",
"private": true,
"prettier": {
"proseWrap": "always",
Expand Down
19 changes: 19 additions & 0 deletions scripts/check-build-log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# NOTE: add warning skip patterns, one per line to WARNINGS_SKIP_LIST to
# temporarily skip known warnings or errors.

BUILD_LOG=tmp/build-log.txt
WARNINGS_SKIP_LIST=.warnings-skip-list.txt

WARNINGS=`grep -E -ie 'warn(ing)?|error' $BUILD_LOG | grep -v -f $WARNINGS_SKIP_LIST`

if [ -e $BUILD_LOG ]; then
if [ -n "$WARNINGS" ]; then
echo "WARNINGs or ERRORs found in build log:\n"
echo "$WARNINGS\n"
exit 1
fi
else
echo "INFO: $BUILD_LOG file not found."
fi

0 comments on commit 47605c0

Please sign in to comment.