Skip to content

Commit

Permalink
fix artifact handling for reset
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Feb 19, 2021
1 parent e925bda commit 84839b3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 35 deletions.
2 changes: 1 addition & 1 deletion artifacts.cue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bitte

#artifacts: {
artifacts: {
"catalyst-perf": {
block0: {
url: "s3::https://s3-eu-central-1.amazonaws.com/iohk-vit-artifacts/catalyst-dryrun/block0.bin"
Expand Down
22 changes: 0 additions & 22 deletions artifacts.json

This file was deleted.

2 changes: 1 addition & 1 deletion jormungandr.cue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ import (
}
}

#block0: #artifacts[namespace].block0
#block0: artifacts[namespace].block0
artifact: "local/block0.bin": {
source: #block0.url
options: {
Expand Down
2 changes: 0 additions & 2 deletions overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
final: prev:
let lib = final.lib;
in {
artifacts = builtins.fromJSON (builtins.readFile ./artifacts.json);

jormungandr = inputs.jormungandr.packages.${final.system}.jormungandr;

jormungandr-monitor =
Expand Down
17 changes: 10 additions & 7 deletions scripts/reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,32 @@ aws s3 ls &> /dev/null \

echo "[x] AWS credentials"

artifacts="$(cat artifacts.json || echo '{}')"
# TODO: do this in CUE
artifacts="$(cue export --out json ./artifacts.cue || echo '{}')"

artifacts="$(
echo "$artifacts" \
| jq \
--arg n "$NOMAD_NAMESPACE" \
--arg u "s3::https://s3-eu-central-1.amazonaws.com/iohk-vit-artifacts/$NOMAD_NAMESPACE/block0.bin" \
--arg h "sha256:$(sha256sum block0.bin | awk '{ print $1 }')" \
'.[$n].block0.checksum = $h'
'.[$n].block0: { url: $u, checksum: $h }'
)"

artifacts="$(
echo "$artifacts" \
| jq \
--arg n "$NOMAD_NAMESPACE" \
--arg u "s3::https://s3-eu-central-1.amazonaws.com/iohk-vit-artifacts/$NOMAD_NAMESPACE/database.sqlite3" \
--arg h "sha256:$(sha256sum database.sqlite3 | awk '{ print $1 }')" \
'.[$n].database.checksum = $h'
'.[$n].database: { url: $u, checksum: $h }'
)"

echo "$artifacts" > artifacts.json
echo "$artifacts" | cue import json: - > artifacts.cue

if ! git diff --exit-code ./artifacts.json; then
echo "Found difference in artifacts.json, pushing for consistency"
git add ./artifacts.json
if ! git diff --exit-code ./artifacts.cue; then
echo "Found difference in artifacts.cue, pushing for consistency"
git add ./artifacts.cue
git commit -m "update artifacts for $NOMAD_NAMESPACE"
git push origin nix-jobs-final
fi
Expand Down
4 changes: 2 additions & 2 deletions servicing-station.cue
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ import (
"""
}

#block0: #artifacts[namespace].block0
#block0: artifacts[namespace].block0
artifact: "local/block0.bin": {
source: #block0.url
options: {
checksum: #block0.checksum
}
}

#database: #artifacts[namespace].database
#database: artifacts[namespace].database
artifact: "local/database.sqlite3": {
source: #database.url
options: {
Expand Down

0 comments on commit 84839b3

Please sign in to comment.