Skip to content

Commit 0b0c0e9

Browse files
committed
Merge remote-tracking branch 'origin/master' into feature/p-token
2 parents 1661b80 + 682df6b commit 0b0c0e9

37 files changed

Lines changed: 863 additions & 268 deletions
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Kup relies on cachix registry k-framework-binary.
5+
CACHE="k-framework-binary"
6+
OWNER_REPO="${OWNER_REPO:-$(git remote get-url origin | sed -E 's#(git@github.com:|https://github.com/)##; s#\.git$##')}"
7+
REV="${REV:-${GITHUB_SHA:-$(git rev-parse HEAD)}}"
8+
UNAME_S="$(uname -s)"
9+
UNAME_M="$(uname -m)"
10+
case "${UNAME_S}-${UNAME_M}" in
11+
Linux-x86_64) SYSTEM="x86_64-linux" ;;
12+
Linux-aarch64 | Linux-arm64) SYSTEM="aarch64-linux" ;;
13+
Darwin-x86_64) SYSTEM="x86_64-darwin" ;;
14+
Darwin-arm64) SYSTEM="aarch64-darwin" ;;
15+
*)
16+
echo "Unsupported platform: ${UNAME_S}-${UNAME_M}" >&2
17+
exit 1
18+
;;
19+
esac
20+
PIN_API_URL="https://app.cachix.org/api/v1/cache/${CACHE}/pin"
21+
CHECK_PACKAGES=(kmir kmir.rust)
22+
23+
SUMMARY="${GITHUB_STEP_SUMMARY:-/dev/stdout}"
24+
25+
{
26+
echo "## Cachix Publish Summary"
27+
echo "CACHE: $CACHE"
28+
echo "OWNER_REPO: $OWNER_REPO"
29+
echo "REV: $REV"
30+
echo "SYSTEM: $SYSTEM"
31+
echo "PACKAGES: ${CHECK_PACKAGES[*]}"
32+
} >> "$SUMMARY"
33+
34+
# Verify push + pin together for each package. Both can become visible with delay.
35+
PIN_VISIBILITY_TIMEOUT_SECONDS=120 # 2 minutes
36+
PIN_VISIBILITY_INTERVAL_SECONDS=5 # 5 seconds
37+
PIN_VISIBILITY_ATTEMPTS=$((PIN_VISIBILITY_TIMEOUT_SECONDS / PIN_VISIBILITY_INTERVAL_SECONDS))
38+
for i in $(seq 1 "$PIN_VISIBILITY_ATTEMPTS"); do
39+
PIN_JSON="$(curl -fsSL "${PIN_API_URL}?q=${REV}")"
40+
ALL_OK=1
41+
42+
for PKG in "${CHECK_PACKAGES[@]}"; do
43+
KEY="github:${OWNER_REPO}/${REV}#packages.${SYSTEM}.${PKG}"
44+
STORE_PATH="$(
45+
echo "$PIN_JSON" \
46+
| jq -r --arg k "$KEY" 'map(select(.name == $k)) | first | (.lastRevision.storePath // .storePath // .store_path // .path // "")'
47+
)"
48+
if [ -z "$STORE_PATH" ]; then
49+
PIN_STATUS="pin-missing"
50+
PUSH_STATUS="000"
51+
ALL_OK=0
52+
{
53+
echo "key-${PKG}: ${KEY}"
54+
echo "pin-status-${PKG}: ${PIN_STATUS}"
55+
echo "push-http-${PKG}: ${PUSH_STATUS}"
56+
}
57+
continue
58+
fi
59+
60+
PIN_STATUS="pin-ok"
61+
HASH="$(basename "$STORE_PATH" | cut -d- -f1)"
62+
PUSH_NARINFO_URL="https://${CACHE}.cachix.org/${HASH}.narinfo"
63+
PUSH_STATUS="$(curl -sS -o /dev/null -w '%{http_code}' "$PUSH_NARINFO_URL")" || PUSH_STATUS="000"
64+
if [ "$PUSH_STATUS" != "200" ]; then
65+
ALL_OK=0
66+
fi
67+
68+
{
69+
echo "key-${PKG}: ${KEY}"
70+
echo "store-path-${PKG}: ${STORE_PATH}"
71+
echo "pin-status-${PKG}: ${PIN_STATUS}"
72+
echo "push-http-${PKG}: ${PUSH_STATUS}"
73+
}
74+
done
75+
76+
if [ "$ALL_OK" = "1" ]; then
77+
echo "cachix-status: push-and-pin-ok-for-all-packages" >> "$SUMMARY"
78+
exit 0
79+
fi
80+
81+
echo "cachix-check-attempt-${i}: not-ready, retrying in ${PIN_VISIBILITY_INTERVAL_SECONDS}s"
82+
sleep "$PIN_VISIBILITY_INTERVAL_SECONDS"
83+
done
84+
85+
echo "cachix-status: push-or-pin-missing-after-${PIN_VISIBILITY_TIMEOUT_SECONDS}s-for-at-least-one-package" >> "$SUMMARY"
86+
exit 1

.github/workflows/release.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,17 @@ jobs:
167167
env:
168168
CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_PRIVATE_KFB_TOKEN }}'
169169
GC_DONT_GC: '1'
170+
OWNER_REPO: '${{ github.repository }}'
171+
REV: '${{ github.sha }}'
170172
with:
171173
packages: jq
172174
script: |
173175
export PATH="$(nix build github:runtimeverification/kup --no-link --json | jq -r '.[].outputs | to_entries[].value')/bin:$PATH"
174-
kup publish k-framework-binary .#kmir --keep-days 180
175-
kup publish k-framework-binary .#kmir.rust --keep-days 180
176+
kup publish k-framework-binary .#kmir --keep-days 180 || true
177+
kup publish k-framework-binary .#kmir.rust --keep-days 180 || true
178+
179+
# Cachix has not been responding to 'cachix pin' requests made under the hood by kup. So we need to manually verify the push and pin.
180+
.github/scripts/check-cachix-pin.sh
176181
177182
- name: 'On failure, delete drafted release'
178183
if: failure()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Test Cachix Pin'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: 'Git ref (tag or SHA) of an existing release to verify'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
verify-cachix-pin:
13+
name: 'Verify Cachix Pin'
14+
runs-on: [self-hosted, linux, normal]
15+
steps:
16+
- name: 'Check out code'
17+
uses: actions/checkout@v4
18+
19+
- name: 'Verify cachix publish and pin'
20+
uses: workflow/nix-shell-action@v3
21+
env:
22+
CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_PRIVATE_KFB_TOKEN }}'
23+
GC_DONT_GC: '1'
24+
OWNER_REPO: '${{ github.repository }}'
25+
REV: '${{ inputs.ref }}'
26+
with:
27+
packages: jq
28+
script: bash .github/scripts/check-cachix-pin.sh

.github/workflows/update-dependencies.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ jobs:
5050
git checkout "${VERSION}"
5151
cd ../..
5252
sed -i 's!__smir_version__: Final = '"'[0-9a-f]*'"'!__smir_version__: Final = '"'${VERSION}'"'!' kmir/src/kmir/__init__.py
53-
git add deps/stable-mir-json kmir/src/kmir/__init__.py
53+
CHANNEL=$(grep '^channel' deps/stable-mir-json/rust-toolchain.toml | sed 's!channel = "\(.*\)"!\1!')
54+
sed -i 's!^channel = ".*"!channel = "'"${CHANNEL}"'"!' rust-toolchain.toml
55+
git add deps/stable-mir-json kmir/src/kmir/__init__.py rust-toolchain.toml
5456
git commit -m "deps/stable-mir-json: sync submodule ${VERSION}" || true
5557
- name: 'Update Nix flake inputs'
5658
run: |

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test: test-unit test-integration smir-parse-tests
2121
stable-mir-json: CARGO_BUILD_OPTS =
2222
stable-mir-json:
2323
cd deps/stable-mir-json && cargo build ${CARGO_BUILD_OPTS}
24+
cd deps/stable-mir-json && cargo build --release ${CARGO_BUILD_OPTS}
2425
cd deps/stable-mir-json && cargo run --bin cargo_stable_mir_json -- ${TOP_DIR}/deps/stable-mir-json ${TOP_DIR}/deps
2526
${TOP_DIR}/deps/.stable-mir-json/release.sh --version || ${TOP_DIR}/deps/.stable-mir-json/debug.sh --version
2627

deps/stable-mir-json

Submodule stable-mir-json updated 58 files

deps/stable-mir-json_release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a5b714d89d0c12c7f4b00602a95ad2d3a34530f0
1+
047ca6ac01786e1b616e13a216d70268b9785e17

flake.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
flake-utils.url = "github:numtide/flake-utils";
88

9-
stable-mir-json-flake.url = "github:runtimeverification/stable-mir-json/a5b714d89d0c12c7f4b00602a95ad2d3a34530f0";
9+
stable-mir-json-flake.url = "github:runtimeverification/stable-mir-json/047ca6ac01786e1b616e13a216d70268b9785e17";
1010
stable-mir-json-flake = {
1111
inputs.nixpkgs.follows = "nixpkgs";
1212
inputs.flake-utils.follows = "flake-utils";

kmir/src/kmir/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from typing import Final
33

44
__version__: Final = version('kmir')
5-
__smir_version__: Final = 'a5b714d89d0c12c7f4b00602a95ad2d3a34530f0'
5+
__smir_version__: Final = '047ca6ac01786e1b616e13a216d70268b9785e17'

0 commit comments

Comments
 (0)