Skip to content

Commit fff783f

Browse files
committed
fix(build): normalize pyth artifacts in optimizer
Move the Pyth artifact rename and checksum rewrite into the CosmWasm optimizer container. CI runners receive root-owned artifacts from the optimizer, so host-side renames fail with permission errors. Signed-off-by: Joseph Chalabi <chalabi.joseph@gmail.com>
1 parent 2d38e7e commit fff783f

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

make/cosmwasm.mk

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,29 @@ build-contracts:
77
-v "$(AKASH_DEVCACHE)/cosmwasm/target":/target \
88
-v "$(AKASH_DEVCACHE)/cosmwasm/artifacts":/code/artifacts \
99
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
10-
$(COSMWASM_OPTIMIZER_IMAGE)
11-
@# Cargo normalizes hyphenated crate names to underscores. Keep the
12-
@# released artifact names aligned with the contract directories.
13-
@artifacts="$(AKASH_DEVCACHE)/cosmwasm/artifacts"; \
14-
for artifact in "pyth_vaa.wasm:pyth-vaa.wasm" "pyth_pro.wasm:pyth-pro.wasm"; do \
15-
old="$${artifact%%:*}"; \
16-
new="$${artifact##*:}"; \
17-
if [ ! -f "$$artifacts/$$old" ]; then \
18-
echo "error: expected $$artifacts/$$old from CosmWasm optimizer" >&2; \
19-
exit 1; \
20-
fi; \
21-
mv -f "$$artifacts/$$old" "$$artifacts/$$new"; \
22-
done; \
23-
if [ -f "$$artifacts/checksums.txt" ]; then \
24-
tmp="$$artifacts/checksums.txt.tmp"; \
25-
sed \
26-
-e 's/pyth_vaa\.wasm/pyth-vaa.wasm/g' \
27-
-e 's/pyth_pro\.wasm/pyth-pro.wasm/g' \
28-
"$$artifacts/checksums.txt" > "$$tmp"; \
29-
mv "$$tmp" "$$artifacts/checksums.txt"; \
30-
fi
10+
--entrypoint /bin/sh \
11+
$(COSMWASM_OPTIMIZER_IMAGE) \
12+
-c 'mkdir -p artifacts && \
13+
rm -f artifacts/pyth-vaa.wasm artifacts/pyth-pro.wasm \
14+
artifacts/pyth_vaa.wasm artifacts/pyth_pro.wasm && \
15+
optimize.sh . && \
16+
cd artifacts && \
17+
for artifact in "pyth_vaa.wasm:pyth-vaa.wasm" "pyth_pro.wasm:pyth-pro.wasm"; do \
18+
old="$${artifact%%:*}"; \
19+
new="$${artifact##*:}"; \
20+
if [ ! -f "$$old" ]; then \
21+
echo "error: expected artifacts/$$old from CosmWasm optimizer" >&2; \
22+
exit 1; \
23+
fi; \
24+
mv -f "$$old" "$$new"; \
25+
done && \
26+
if [ -f checksums.txt ]; then \
27+
sed \
28+
-e "s/pyth_vaa\.wasm/pyth-vaa.wasm/g" \
29+
-e "s/pyth_pro\.wasm/pyth-pro.wasm/g" \
30+
checksums.txt > checksums.txt.tmp && \
31+
mv checksums.txt.tmp checksums.txt; \
32+
fi'
3133

3234
.PHONY: generate-contracts
3335
generate-contracts: build-contracts

0 commit comments

Comments
 (0)