diff --git a/.github/workflows/pr-actions.yml b/.github/workflows/pr-actions.yml index c2e30d42bb85..dfc5319e81b6 100644 --- a/.github/workflows/pr-actions.yml +++ b/.github/workflows/pr-actions.yml @@ -69,21 +69,11 @@ jobs: - run: | case $PR_ACTION in - format) - npm run format - ;; - submodules) - npm run sync - ;; - refcache) - npm install --omit=optional - npm run check:links - ;; - all) + all|refcache) npm install --omit=optional - npm run sync - npm run format - npm run check:links + ;& + format|submodules) + npm run fix:$PR_ACTION ;; esac git status diff --git a/content/en/docs/contributing/_index.md b/content/en/docs/contributing/_index.md index 8ec8066b23be..9811c7734fd2 100644 --- a/content/en/docs/contributing/_index.md +++ b/content/en/docs/contributing/_index.md @@ -380,18 +380,18 @@ GitHub also automatically assigns labels to a PR to help reviewers. #### Fix content issues automatically -Before submitting a change to the repository, run the following command and -address any reported issues. Also commit any files changed by the `fix` script: +Before submitting a change to the repository, run the following command and (i) +address any reported issues, (ii) commit any files changed by the script: ```sh npm run test-and-fix ``` -To separately test and fix issues with your files, run: +To separately test and fix all issues with your files, run: ```sh -npm run test # checks but does not update any files -npm run fix # may update files +npm run test # Checks but does not update any files +npm run fix:all # May update files ``` To list available NPM scripts, run `npm run`. diff --git a/package.json b/package.json index 6425b503bef6..8512ec4b3e00 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "spelling": "cSpell:ignore docsy elemetry HTMLTEST hugo loglevel netlify prebuild precheck preinstall postbuild postget textlint -", + "spelling": "cSpell:ignore docsy elemetry HTMLTEST hugo loglevel netlify prebuild precheck preinstall postbuild postget refcache textlint -", "Notes": [ "The 'all' runs _all_ named scripts in sequence, even if one fails; and exits with failure in that case." ], @@ -21,7 +21,7 @@ "_get:submodule:non-lang": "npm run _get:submodule -- content-modules/opentelemetry-specification themes/docsy", "_get:submodule": "set -x && git submodule update --init ${DEPTH:- --depth 1}", "_list:check:*": "npm run --loglevel=warn | grep -Ee '^\\s*check:[^:]+$'", - "_list:fix:*": "npm run --loglevel=warn | grep -Ee '^\\s*fix:[^:]+$'", + "_list:fix:*": "npm run --loglevel=warn | grep -Ee '^\\s*fix:[^:]+$' | grep -v 'fix:all'", "_ls-bad-filenames": "find assets content static -name '*_*' ! -name '_*'", "_prebuild": "npm run seq -- get:submodule cp:spec", "_prepare:docsy": "cd themes/docsy && npm install", @@ -29,6 +29,7 @@ "_rename-to-kebab-case": "find assets content static -name '*_*' ! -name '_*' -exec sh -c 'mv \"$1\" \"${1//_/-}\"' _ {} \\;", "_serve:hugo": "hugo server -DFE --minify", "_serve:netlify": "netlify dev -c \"npm run _serve:hugo\"", + "_sync": "./scripts/sync-submodules.pl", "all": "bash -c 'x=0; for c in \"$@\"; do npm run $c || x=$((x+1)); done; ((!x)) || (echo \"ERROR: some scripts failed!\" && exit 1)' -", "build:preview": "set -x && npm run _build -- --minify", "build:production": "hugo --cleanDestinationDir --minify", @@ -49,11 +50,14 @@ "cp:spec": "./scripts/content-modules/cp-pages.sh", "diff:check": "npm run _diff:check || (echo; echo 'WARNING: the files above have not been committed'; echo)", "diff:fail": "npm run _diff:check || (echo; echo 'ERROR: the files above have changed. Locally rerun `npm run test-and-fix` and commit changes'; echo; exit 1)", + "fix:all": "npm run seq -- $(npm -s run _list:fix:*)", "fix:dict": "find content layouts -name \"*.md\" -print0 | xargs -0 ./scripts/normalize-cspell-front-matter.pl", "fix:filenames": "npm run _rename-to-kebab-case", "fix:format": "npm run format", "fix:markdown": "npm run check:markdown -- --fix", - "fix": "npm run seq -- $(npm -s run _list:fix:*)", + "fix:refcache": "npm run check:links", + "fix:submodules": "npm run _sync", + "fix": "npm run fix:all", "format": "npm run _check:format -- --write", "get:submodule": "npm run _get:${GET:-submodule}", "install:netlify-cli": "npm list netlify-cli || npm install netlify-cli", @@ -70,6 +74,7 @@ "prepare": "npm run seq -- get:submodule _prepare:docsy", "preserve:hugo": "npm run _prebuild", "preserve:netlify": "npm run seq -- _prebuild install:netlify-cli", + "prefix:submodules": "npm run update:submodule", "schemas:update": "npm run update:submodule content-modules/opentelemetry-specification", "seq": "bash -c 'for cmd in \"$@\"; do npm run $cmd || exit 1; done' - ", "serve:hugo": "npm run _serve:hugo",