Skip to content

Commit

Permalink
Supporting custom tests for Mustache templates
Browse files Browse the repository at this point in the history
  • Loading branch information
cptanalatriste committed Dec 19, 2024
1 parent 5e46b73 commit 3394d92
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/lint_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,20 @@ jobs:
run: |
echo '{"array": ["dummy"], "variable": "dummy"}' > .mustache_config.json
for yamlfile in $(find . -name "*.yml" -o -name "*.yaml"); do
sed "s|{{\([/#]\)[^}]*}}|{{\1array}}|g" $yamlfile > expanded.tmp # replace mustache arrays
sed -i "s|{{[^#/].\{1,\}}}|{{variable}}|g" expanded.tmp # replace mustache variables
mustache .mustache_config.json expanded.tmp > $yamlfile # perform mustache expansion overwriting original file
filename=$(basename -- "$yamlfile")
extension="${filename##*.}"
filename="${filename%.*}"
test_config="tests/mustache/$filename.config.json"
if [ -e "$test_config" ]; then
mustache $test_config $yamlfile > $yamlfile
else

Check failure on line 113 in .github/workflows/lint_code.yaml

View workflow job for this annotation

GitHub Actions / lint_yaml

113:17 [trailing-spaces] trailing spaces
sed "s|{{\([/#]\)[^}]*}}|{{\1array}}|g" $yamlfile > expanded.tmp # replace mustache arrays
sed -i "s|{{[^#/].\{1,\}}}|{{variable}}|g" expanded.tmp # replace mustache variables
mustache .mustache_config.json expanded.tmp > $yamlfile # perform mustache expansion overwriting original file
fi

Check failure on line 117 in .github/workflows/lint_code.yaml

View workflow job for this annotation

GitHub Actions / lint_yaml

117:15 [trailing-spaces] trailing spaces
done
rm expanded.tmp
- name: Lint YAML
Expand Down
7 changes: 7 additions & 0 deletions tests/mustache/AdGuardHome.mustache.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"filter_allow": [
"clamav.net",
"current.cvd.clamav.net"
],
"allow_workspace_internet": true
}

0 comments on commit 3394d92

Please sign in to comment.