Skip to content

Commit

Permalink
renovate-config-validator: validate shareable config preset (super-li…
Browse files Browse the repository at this point in the history
…nter#4674)

* renovate-config-validator: validate default.json

* Add RENOVATE_SHAREABLE_CONFIG_PRESET_FILE

* Allow specifying multiple additional files with a environment variable

* Add break
  • Loading branch information
massongit authored Sep 29, 2023
1 parent 4952859 commit 50d462e
Show file tree
Hide file tree
Showing 17 changed files with 250 additions and 147 deletions.
10 changes: 4 additions & 6 deletions .automation/test/renovate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ This folder holds the test cases for **renovate**.

## Additional Docs

No Additional information is needed for this test case.
Due to the nature of the naming of files, we have `2` subfolders in this directory.

## Good Test Cases
- `good` is for working, and correct renovate config files
- `bad` is for invalid, and incorrect renovate config files

The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
## Good Test Cases

- **Note:** They are linted utilizing the default linter rules.

## Bad Test Cases

The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.

- **Note:** They are linted utilizing the default linter rules.
{"mode":"full","isActive":false}
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions .automation/test/renovate/bad/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ignooooooooorePaths": [
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**",
"**/examples/**",
"**/__tests__/**",
"**/tests/**",
"**/__fixtures__/**"
],
"iggggggggnoreDeps": [
"go",
"node-fetch"
],
"constraaaaaaaaaints": {
"go": "1.20"
}
}
18 changes: 18 additions & 0 deletions .automation/test/renovate/bad/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ignooooooooorePaths": [
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**",
"**/examples/**",
"**/__tests__/**",
"**/tests/**",
"**/__fixtures__/**"
],
"iggggggggnoreDeps": [
"go",
"node-fetch"
],
"constraaaaaaaaaints": {
"go": "1.20"
}
}
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions .automation/test/renovate/good/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ignorePaths": [
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**",
"**/examples/**",
"**/__tests__/**",
"**/tests/**",
"**/__fixtures__/**"
],
"ignoreDeps": [
"go",
"node-fetch"
],
"constraints": {
"go": "1.20"
}
}
18 changes: 18 additions & 0 deletions .automation/test/renovate/good/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ignorePaths": [
"**/node_modules/**",
"**/bower_components/**",
"**/vendor/**",
"**/examples/**",
"**/__tests__/**",
"**/tests/**",
"**/__fixtures__/**"
],
"ignoreDeps": [
"go",
"node-fetch"
],
"constraints": {
"go": "1.20"
}
}
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
LOCAL_UPDATES: true
RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES: "default.json,hoge.json"

- name: Run Test Suite
run: make IMAGE=${{ matrix.images.target }} test
Expand All @@ -76,6 +77,7 @@ jobs:
-e TEST_CASE_RUN=true \
-e ANSIBLE_DIRECTORY=.automation/test/ansible \
-e ACTIONS_RUNNER_DEBUG=true \
-e RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES="default.json,hoge.json" \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/super-linter/super-linter:${tag}"
Expand All @@ -88,6 +90,7 @@ jobs:
-e RUN_LOCAL=true \
-e OUTPUT_DETAILS=detailed \
-e ACTIONS_RUNNER_DEBUG=true \
-e RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES="default.json,hoge.json" \
-e ERROR_ON_MISSING_EXEC_BIT=true \
-v "${GITHUB_WORKSPACE}:/tmp/lint" \
"ghcr.io/super-linter/super-linter:${tag}"
Expand Down
279 changes: 140 additions & 139 deletions README.md

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions lib/functions/buildFileList.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,20 @@ function BuildFileList() {
fi

# See https://docs.renovatebot.com/configuration-options/
if [[ "${BASE_FILE}" =~ renovate.+json5? ]] ||
[ "${BASE_FILE}" == ".renovaterc" ] || [[ "${BASE_FILE}" =~ .renovaterc.+json5? ]]; then
if [[ "${BASE_FILE}" =~ renovate.json5? ]] ||
[ "${BASE_FILE}" == ".renovaterc" ] || [[ "${BASE_FILE}" =~ .renovaterc.json5? ]]; then
FILE_ARRAY_RENOVATE+=("${FILE}")
fi

# See https://docs.renovatebot.com/config-presets/
IFS="," read -r -a RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES_ARRAY <<<"${RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES}"
for file_name in "${RENOVATE_SHAREABLE_CONFIG_PRESET_FILE_NAMES_ARRAY[@]}"; do
if [ "${BASE_FILE}" == "${file_name}" ]; then
FILE_ARRAY_RENOVATE+=("${FILE}")
break
fi
done

#######################
# Get the shell files #
#######################
Expand Down
20 changes: 20 additions & 0 deletions lib/functions/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ function LintCodebase() {
fi
fi

#####################
# Check if Renovate #
#####################
if [[ ${FILE_TYPE} == *"RENOVATE"* ]]; then
debug "FILE_TYPE for FILE ${FILE} is related to Renovate: ${FILE_TYPE}"
if [[ ${FILE} == *"good"* ]]; then
debug "Setting FILE_STATUS for FILE ${FILE} to 'good'"
#############
# Good file #
#############
FILE_STATUS='good'
elif [[ ${FILE} == *"bad"* ]]; then
debug "Setting FILE_STATUS for FILE ${FILE} to 'bad'"
############
# Bad file #
############
FILE_STATUS='bad'
fi
fi

#######################################
# Check if Cargo.toml for Rust Clippy #
#######################################
Expand Down

0 comments on commit 50d462e

Please sign in to comment.