Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:
# and those archives are committed so that `go get` works without a Rust
# toolchain. `libs` rebuilds all four whenever the Rust side changes and
# `commit-libs` pushes them back to the branch; `test` runs against whatever
# archive is committed.
# archive is committed, so `libs` tests (native) or links (cross) each archive
# before uploading it.

jobs:
test:
Expand All @@ -37,11 +38,17 @@ jobs:
fail-fast: false
matrix:
include:
# cross: the Go env that links the second, cross-built target.
- os: ubuntu-24.04
targets: "x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu"
cross: "GOARCH=arm64 CC=aarch64-linux-gnu-gcc"
- os: macos-15
targets: "aarch64-apple-darwin x86_64-apple-darwin"
cross: "GOARCH=amd64"
runs-on: ${{ matrix.os }}
# Both legs see the same commit, so either one's answer is the job's.
outputs:
built: ${{ steps.rust.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
- uses: tj-actions/changed-files@v45
Expand All @@ -52,6 +59,7 @@ jobs:
Cargo.toml
Cargo.lock
scripts/build-lib.sh
.github/workflows/ci.yml
- if: steps.rust.outputs.any_changed == 'true'
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -64,7 +72,7 @@ jobs:
name: Cross toolchain for aarch64
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
sudo apt-get install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
{
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc"
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc"
Expand All @@ -74,10 +82,21 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.22"
# Upload only what this runner built: the checkout also holds the other
# platform's committed archives, and merge-multiple would write both copies.
- if: steps.rust.outputs.any_changed == 'true'
name: Remove the committed archives
run: rm -f rgbconsignment/lib/*/librgb_consignment.a
- if: steps.rust.outputs.any_changed == 'true'
name: Build archives
run: |
for t in ${{ matrix.targets }}; do ./scripts/build-lib.sh "$t"; done
# The cross-built archive cannot run here, so it is only linked.
- if: steps.rust.outputs.any_changed == 'true'
name: Test the native archive, link the cross-built one
run: |
go test ./rgbconsignment
env CGO_ENABLED=1 ${{ matrix.cross }} go test -c -o /dev/null ./rgbconsignment
- if: steps.rust.outputs.any_changed == 'true'
uses: actions/upload-artifact@v4
with:
Expand All @@ -87,19 +106,45 @@ jobs:

commit-libs:
needs: libs
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
# Without a rebuild there is nothing to commit; running anyway would delete the archives.
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') && needs.libs.outputs.built == 'true'
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
# Start from no file so a missing artifact cannot leave a stale archive behind.
- name: Remove the committed archives
run: rm -f rgbconsignment/lib/*/librgb_consignment.a
- uses: actions/download-artifact@v4
with:
pattern: libs-*
path: rgbconsignment/lib
merge-multiple: true
# Names all four archives, so a missing artifact fails here instead of
# reaching the commit as a deleted archive.
- name: Check all four archives arrived intact
run: |
python3 - rgbconsignment/lib/{darwin,linux}_{amd64,arm64}/librgb_consignment.a <<'PY'
import os
import sys

for path in sys.argv[1:]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: Nothing checks that all four archives arrived. After the rm -f at L110, a missing artifact reaches the commit step as a deleted archive, and this loop passes on the rest. Fail unless all four rgbconsignment/lib/{darwin,linux}_{amd64,arm64}/librgb_consignment.a exist.

assert os.path.exists(path), f"{path}: missing, its libs artifact did not arrive"
data = open(path, "rb").read()
assert data[:8] == b"!<arch>\n", f"{path}: not an ar archive"
off, size = 8, 0
while off < len(data):
assert off + 60 <= len(data) and data[off + 58:off + 60] == b"`\n", f"{path}: bad member header at {off}"
size = int(data[off + 48:off + 58].strip() or 0)
off += 60 + size + size % 2
# Only an odd-sized last member may drop its padding byte.
assert off == len(data) or (size % 2 and off == len(data) + 1), \
f"{path}: archive ends at {len(data)}, its members at {off}"
print(path, "ok")
PY
- name: Commit rebuilt archives
uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
112 changes: 23 additions & 89 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ license = "Apache-2.0"


[workspace.dependencies]
amplify = { version = "4.8.1", default-features = false }
amplify = { version = "=4.8.1", default-features = false }
clap = { version = "4.5.4", features = ["derive"] }
env_logger = "0.11.3"
log = "0.4.21"
rgb-ops = { version = "0.11.1-rc.10", default-features = false, features = [
# Exact pins keep the RGB crate versions rgb-lib 3f571ac and the enclave decode
# with, so a newer prerelease cannot change the strict encoding under us.
rgb-ops = { version = "=0.11.2-rc.1", default-features = false, features = [
"serde",
] }
rgb-strict-types = "1.0.1"
rgb-strict-types = "=1.0.5"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
thiserror = "2.0"
Expand Down
Loading