-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for generating the trigger queue
- Loading branch information
Showing
7 changed files
with
891 additions
and
4 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
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,102 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
dir="$(dirname "$BASH_SOURCE")" | ||
|
||
tmpJson="$(mktemp)" | ||
trap 'rm $tmpJson' EXIT | ||
|
||
jq -n -c ' | ||
# input arch and test values | ||
# output unique buildId string | ||
def buildId($arch): | ||
[$arch, .[] | tostring] | join("-") | ||
; | ||
[ | ||
# add new test cases here | ||
# each item will be used for each architecture generated | ||
# [ ".build.resloved", "count", "skips" ] | ||
[ null, 1, 0 ], # buildable, tried once | ||
[ null, 23, 0 ], # buildable, tried many but less than skip threshold | ||
[ null, 24, 0 ], # buildable, tried many, just on skip threshold | ||
[ null, 25, 23 ], # buildable, final skip | ||
[ null, 25, 24 ], # buildable, no longer skipped | ||
[ {}, 3, 0 ], # build "complete" (not queued or skipped) | ||
empty # trailing comma | ||
] as $data | ||
| [ "amd64", "arm32v7", "windows-amd64" ] | ||
| to_entries | ||
| ( | ||
# making a list of build objects as a "builds.json" | ||
map( | ||
(.key | tostring) as $archindex | ||
| .value as $arch | ||
| $data | to_entries[] | ||
| (.value | buildId($arch)) as $buildId | ||
| .key as $index | ||
| .value[0] as $resolved | ||
| { | ||
($buildId): { | ||
$buildId, | ||
"build": { | ||
$arch, | ||
$resolved, | ||
"resolvedParents": { | ||
(if $arch | startswith("windows") then | ||
"windows:ltsc2022" | ||
else | ||
"debian:fake" | ||
end | ||
): { | ||
"manifests": [{ | ||
"platform": ( | ||
if $arch | startswith("windows") then | ||
{ | ||
"architecture": "amd64", | ||
"os": "windows", | ||
"os.version": "10.0.20348.12345" | ||
} | ||
else | ||
{ | ||
"architecture": ($arch | rtrimstr("v6")|rtrimstr("v7")|rtrimstr("v8")), | ||
"os": "linux" | ||
} | ||
end | ||
) | ||
}] | ||
} | ||
} | ||
}, | ||
"source": { | ||
"arches": { | ||
($arch): { | ||
"tags": [("a","b","c") | . * ($index + 1)] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
) | ||
| add | ||
), ( | ||
# making a list of minimal build records like in "past-jobs.json" | ||
map( | ||
(.key | tostring) as $archindex | ||
| .value as $arch | ||
| $data | to_entries[] | ||
| (.value | buildId($arch)) as $buildId | ||
| .value[1] as $count | ||
| .value[2] as $skips | ||
| { | ||
($buildId|tostring): { | ||
$count, | ||
$skips | ||
} | ||
} | ||
) | ||
| add | ||
) | ||
' > "$tmpJson" | ||
|
||
head -n1 "$tmpJson" | jq --tab '.' > "$dir/in.json" | ||
tail -n1 "$tmpJson" | jq --tab '.' > "$dir/past-jobs.json" |
Oops, something went wrong.