forked from devfile/alizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement nightly run script and workflow
Signed-off-by: thepetk <[email protected]>
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
on: | ||
schedule: | ||
- cron: "*/5 * * * *" | ||
|
||
name: Production & Community Registries Check | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
check-registry: | ||
name: Check registry entries | ||
runs-on: 'ubuntu-latest' | ||
outputs: | ||
matrix: ${{ steps.get-stacks.outputs.matrix }} | ||
steps: | ||
- name: Checkout code | ||
id: checkout-code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup go | ||
id: setup-go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.19.5' | ||
- name: Run registries check | ||
id: build | ||
run: | | ||
go build alizer.go | ||
bash test/check_registry/check_registry.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
# Fetch all entries from registries | ||
echo ":: Creating Registry Entries JSON..." | ||
echo "" | ||
echo "" | ||
REGISTRY_ENTRIES_OUTPUT=$(go run test/check_registry/check_registry.go) | ||
ENTRIES_PASSED=0 | ||
ENTRIES_FAILED=0 | ||
|
||
for entry in $(echo $REGISTRY_ENTRIES_OUTPUT | jq -c '.[]') | ||
do | ||
# Assign variables for this entry | ||
devfile=$(jq -r '.Devfile' <<< $entry) | ||
path="tmp/$devfile" | ||
found_matching=1 | ||
repo=$(jq -r '.Repo' <<< $entry) | ||
registry=$(jq -r '.Registry' <<< $entry) | ||
revision=$(jq -r '.Revision' <<< $entry) | ||
subdir=$(jq -r '.SubDir' <<< $entry) | ||
|
||
# Clone project according to data | ||
echo ":: Cloning project for entry <$devfile>" | ||
echo "" | ||
echo "" | ||
|
||
if [ "$revision" != "" ]; then | ||
echo "$devfile -> found revision $revision for repo $repo" | ||
git clone --single-branch --branch $revision $repo tmp/$devfile | ||
else | ||
git clone $repo tmp/$devfile | ||
fi | ||
|
||
if [ "$subdir" != "" ]; then | ||
path="$path/$subdir" | ||
fi | ||
|
||
# Checking with alizer | ||
echo "" | ||
echo "" | ||
echo ":: Running alizer against path $path" | ||
echo "" | ||
echo "" | ||
alizer_output=$(./alizer devfile --registry $registry $path) | ||
for raw_selected_devfile_name in $(echo $alizer_output | jq -c '.[].Name') | ||
do | ||
selected_devfile_name=$(sed -e 's/^"//' -e 's/"$//' <<<"$raw_selected_devfile_name") | ||
# Loop through the list of proposed devfiles to find the correct one | ||
if [[ "$selected_devfile_name" == *"$devfile"* ]]; then | ||
# If devfile name is contained inside selected one success | ||
echo "------------------" | ||
echo "SUCCESS - Devfile Name: $devfile <> Matched Devfile Name: $selected_devfile_name" | ||
echo "------------------" | ||
echo "" | ||
let ENTRIES_PASSED++ | ||
found_matching=1 | ||
fi | ||
# If the correct devfile is not matched throw error | ||
if [ "$found_matching" == "0" ]; then | ||
let ENTRIES_FAILED++ | ||
echo "[FAIL] Project $repo matched with $selected_devfile_name name. Expected $devfile (PASSED: $ENTRIES_PASSED / FAILED: $ENTRIES_FAILED)" | ||
exit 1 | ||
fi | ||
done | ||
rm -rf tmp/$devfile | ||
done | ||
echo "[OK] PASSED: $ENTRIES_PASSED / FAILED: $ENTRIES_FAILED" |