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
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ on: [push, pull_request]

name: Continuous integration

permissions:
contents: read

jobs:
Prepare:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -37,6 +40,47 @@ jobs:
- name: Running cargo fmt
run: cargo fmt --all -- --check

symbol_versions:
name: Symbol Version Prefixes
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Check simplicity-sys symbol prefixes match its version
run: ./simplicity-sys/check-symbol-versions.sh

vendored_libsimplicity:
name: Vendored libsimplicity
runs-on: ubuntu-latest
steps:
- name: Checkout Crate
uses: actions/checkout@v4
- name: Read vendored libsimplicity revision
id: libsimplicity
run: |
set -euo pipefail
echo "rev=$(sed -n '2p' simplicity-sys/depend/simplicity-HEAD-revision.txt)" >> "$GITHUB_OUTPUT"
- name: Checkout libsimplicity
uses: actions/checkout@v4
with:
repository: BlockstreamResearch/simplicity
ref: ${{ steps.libsimplicity.outputs.rev }}
path: libsimplicity
- name: Re-vendor libsimplicity and check for differences
env:
LIBSIMPLICITY_REV: ${{ steps.libsimplicity.outputs.rev }}
run: |
set -euo pipefail
cd simplicity-sys
# vendor-simplicity.sh asks before deleting the existing vendored copy.
echo y | ./vendor-simplicity.sh depend ../libsimplicity
if [ -n "$(git status --porcelain --untracked-files=all -- .)" ]; then
echo "simplicity-sys does not match libsimplicity $LIBSIMPLICITY_REV re-vendored with vendor-simplicity.sh:"
git status --short --untracked-files=all -- .
git diff --stat -- .
exit 1
fi

simpcli_test:
name: SimpCLI Tests
runs-on: ubuntu-latest
Expand Down
29 changes: 29 additions & 0 deletions simplicity-sys/check-symbol-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail

# Check that every versioned symbol prefix in simplicity-sys matches the crate version.
#
# vendor-simplicity.sh renames every libsimplicity symbol to `rustsimplicity_<major>_<minor>_*`
# and the allocator hooks to `rust_<major>_<minor>_*`, so that semver-incompatible versions of

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In 0316258:

This is fine, but the pattern is really rust_0_<minor>_*. When the major version changes to 1, if ever, we would change the pattern to rust_<major>_*, dropping the minor version which would no longer indicate a semver-incompatible release.

Basically the rule is that we try to encode the "major version according to Rust's semver rules" and nothing more than that.

# this crate can be linked into the same binary. A file that keeps an older prefix (for example
# one copied in by hand instead of vendored) silently defeats that, so fail if any prefix other
# than the current one appears.

cd "$(dirname "$0")"

VERSION_CODE=$(grep "^version" Cargo.toml | sed 's/\./_/g' | sed 's/.*"\(.*\)".*/\1/' | cut -d_ -f1-2)

# Each output line is `file:line:match`; keep only matches that are not the current version.
STALE=$(grep -rnoE '(rustsimplicity|rust)_[0-9]+_[0-9]+' Cargo.toml depend src \
| grep -vE ":(rustsimplicity|rust)_${VERSION_CODE}\$" || true)

if [ -n "$STALE" ]; then
echo "Found symbol prefixes that do not match the simplicity-sys version code ${VERSION_CODE}:"
echo "$STALE"
echo
echo "Expected only rustsimplicity_${VERSION_CODE}_* and rust_${VERSION_CODE}_*."
echo "Re-run vendor-simplicity.sh rather than copying libsimplicity files in by hand."
exit 1
fi

echo "All symbol prefixes match version code ${VERSION_CODE}."
Loading