Skip to content

Commit 4bccfb7

Browse files
committed
Control scope of recursion when validating Dependabot configuration files
The project infrastructure validates the Dependabot configuration files against their JSON schema. In addition to the repository's own Dependabot configuration file at the standard location, a reusable standardized "asset" configuration file for GitHub Actions workflows is hosted in the repository. There is a need to eventually add additional "asset" files to configure Dependabot for other dependency management frameworks. Previously, in order to provide validation coverage for all the dependabot.yml files in the repository, a "globstar" was used to cause the validator to recursively search the entire file tree under the repository. That approach is problematic because the repository contains externally maintained files (e.g., the npm packages under the node_modules folder). Searching and validating these files is inefficient at best and the cause of spurious failures at worst. This is avoided by targeting the search. In order to support the addition of more "asset" Dependabot configuration files in the future, a globstar is still used, but the recursion is limited to the folder dedicated as a container for those files, which will never lead to unintended files being validated.
1 parent 29d3918 commit 4bccfb7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Taskfile.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ tasks:
359359
SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
360360
SCHEMA_PATH:
361361
sh: task utility:mktemp-file TEMPLATE="dependabot-schema-XXXXXXXXXX.json"
362-
DATA_PATH: "**/dependabot.yml"
362+
# The Dependabot configuration file for the repository.
363+
DATA_PATH: ".github/dependabot.yml"
364+
# The asset Dependabot configuration files.
365+
ASSETS_DATA_PATH: "workflow-templates/assets/dependabot/**/dependabot.yml"
363366
PROJECT_FOLDER:
364367
sh: pwd
365368
WORKING_FOLDER:
@@ -372,6 +375,12 @@ tasks:
372375
--all-errors \
373376
-s "{{.SCHEMA_PATH}}" \
374377
-d "{{.PROJECT_FOLDER}}/{{.DATA_PATH}}"
378+
- |
379+
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
380+
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
381+
--all-errors \
382+
-s "{{.SCHEMA_PATH}}" \
383+
-d "{{.PROJECT_FOLDER}}/{{.ASSETS_DATA_PATH}}"
375384
376385
docs:generate:
377386
desc: Create all generated documentation content

0 commit comments

Comments
 (0)