Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
32c5e87
update compiler to support compact > compactc
andrew-fleming Aug 27, 2025
3130243
remove comment
andrew-fleming Aug 27, 2025
b0a3f8d
add link to compact dev tools
andrew-fleming Aug 27, 2025
305dec1
update and simplify compact installation in CI
andrew-fleming Aug 27, 2025
1af5be9
improve comments
andrew-fleming Aug 27, 2025
14bfd2b
update readme and index doc
andrew-fleming Aug 27, 2025
42ed037
highlight PATH
andrew-fleming Aug 29, 2025
8c7d7d9
fix conflicts
andrew-fleming Sep 1, 2025
9c52416
add error classes
andrew-fleming Sep 1, 2025
675cc63
refactor compiler and runCompiler: better separation of concerns, mor…
andrew-fleming Sep 1, 2025
ac196d8
improve compiler docs
andrew-fleming Sep 1, 2025
6b7c475
add docs to error classes
andrew-fleming Sep 1, 2025
889e224
dont cache tests
andrew-fleming Sep 2, 2025
aa57487
add test, add compiler tests
andrew-fleming Sep 2, 2025
25d8861
update yarn.lock
andrew-fleming Sep 2, 2025
18deca0
tidy up tests
andrew-fleming Sep 2, 2025
86bee9f
fix fmt
andrew-fleming Sep 2, 2025
90165a4
fix fmt
andrew-fleming Sep 2, 2025
cdd0eec
fix comment
andrew-fleming Sep 2, 2025
4b6e91d
fix test
andrew-fleming Sep 2, 2025
b313b33
fix strings
andrew-fleming Sep 3, 2025
93ca42b
fix fmt
andrew-fleming Sep 3, 2025
905afdc
improve conditionals
andrew-fleming Sep 3, 2025
aaf50db
add runCompiler tests
andrew-fleming Sep 3, 2025
544656b
Merge branch 'main' into integrate-compact-toolchain
andrew-fleming Sep 3, 2025
8d94e35
fix double skip-zk flag
andrew-fleming Sep 3, 2025
7334317
fix fmt
andrew-fleming Sep 3, 2025
492eea8
Apply suggestions from code review
andrew-fleming Sep 3, 2025
d6b172c
improve index doc
andrew-fleming Sep 3, 2025
3c83355
Apply suggestions from code review
andrew-fleming Sep 3, 2025
d5d0bb0
Apply suggestions from code review
andrew-fleming Sep 4, 2025
573d75f
improve ora mock -> add spinner mock, add spinner tests
andrew-fleming Sep 4, 2025
535c18a
add fromArgs deduplicate flag test
andrew-fleming Sep 4, 2025
e401ded
add vitest config to compact
andrew-fleming Sep 4, 2025
5811c86
improve validation flow
andrew-fleming Sep 4, 2025
28af700
add more validateEnvironment tests
andrew-fleming Sep 4, 2025
4608b5e
move all error handling to runCompiler, keep progress reporting in Co…
andrew-fleming Sep 4, 2025
82c4ba1
update compiler tests (mostly validateEnvironment)
andrew-fleming Sep 4, 2025
6dcf789
update tests with full error handling responsibilities
andrew-fleming Sep 4, 2025
3373d3e
tidy up test
andrew-fleming Sep 4, 2025
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
82 changes: 29 additions & 53 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,81 +26,57 @@ jobs:
- name: Setup Environment
uses: ./.github/actions/setup

- name: Install Compact compiler
id: setup
- name: Install Compact developer tools
shell: bash
run: |
set -euo pipefail
# Create directory for compiler
COMPACT_HOME="$HOME/compactc"
mkdir -p "$COMPACT_HOME"

# Create URL
ZIP_FILE="compactc_v${COMPILER_VERSION}_x86_64-unknown-linux-musl.zip"
DOWNLOAD_URL="https://d3fazakqrumx6p.cloudfront.net/artifacts/compiler/compactc_${COMPILER_VERSION}/${ZIP_FILE}"

echo "⬇️ Downloading Compact compiler..."
curl -Ls "$DOWNLOAD_URL" -o "$COMPACT_HOME/compactc.zip"

echo "📦 Extracting..."
unzip -q "$COMPACT_HOME/compactc.zip" -d "$COMPACT_HOME"
chmod +x "$COMPACT_HOME"/{compactc,compactc.bin,zkir}

echo "📁 Setting environment variables..."
echo "COMPACT_HOME=$COMPACT_HOME" >> "$GITHUB_ENV"
echo "$COMPACT_HOME" >> "$GITHUB_PATH"

echo "✅ Verifying installation..."
if [ ! -f "$COMPACT_HOME/compactc" ]; then
echo "::error::❌ compactc not found in $COMPACT_HOME"
exit 1
fi
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/midnightntwrk/compact/releases/latest/download/compact-installer.sh | sh
echo "$HOME/.compact/bin" >> "$GITHUB_PATH"

- name: Install and verify toolchain
run: |
compact update ${{ env.COMPILER_VERSION }}
echo "🤖 Testing installation..."
"$COMPACT_HOME/compactc" --version
compact compile --version
compact compile --language-version

- name: Check compiler and language version
run: |
COMPILER_OUTPUT=$(compactc --version)
COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | head -n 1)
if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then
errMsg="❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION"
# Check toolchain version
COMPILER_OUTPUT=$(compact compile --version)
COMPUTED_COMPILER_VERSION=$(echo "$COMPILER_OUTPUT" | grep -oP '\b[0-9]+\.[0-9]+\.[0-9]+\b' | head -n 1)
if [ "$COMPUTED_COMPILER_VERSION" != "$COMPILER_VERSION" ]; then
errMsg="❌ Compiler version mismatch!%0AExpected: $COMPILER_VERSION%0AGot: $COMPUTED_COMPILER_VERSION"
echo "::error::$errMsg"
exit 1
fi
echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION"

# Check language version using new command
LANGUAGE_OUTPUT=$(compact compile --language-version)
COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b[0-9]+\.[0-9]+\.[0-9]+\b' | tail -n 1)
if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then
errMsg="❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION"
echo "::error::$errMsg"
exit 1
fi
echo "✅ Compiler version matches: $COMPUTED_COMPILER_VERSION"

LANGUAGE_OUTPUT=$(compactc --language-version)
COMPUTED_LANGUAGE_VERSION=$(echo "$LANGUAGE_OUTPUT" | grep -oP '\b0\.[0-9]+\.[0-9]+\b' | tail -n 1)
if [ "$COMPUTED_LANGUAGE_VERSION" != "$LANGUAGE_VERSION" ]; then
errMsg="❌ Language version mismatch!%0AExpected: $LANGUAGE_VERSION%0AGot: $COMPUTED_LANGUAGE_VERSION"
echo "::error::$errMsg"
exit 1
fi

echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION"
fi
echo "✅ Language version matches: $COMPUTED_LANGUAGE_VERSION"

- name: Compile contracts (with retry on hash mismatch)
shell: bash
run: |
set -euo pipefail

compile() {
echo "⚙️ Running Compact compilation..."
if ! output=$(turbo compact --concurrency=1 2>&1); then
echo "❌ Compilation failed."
if echo "$output" | grep -q "Hash mismatch" && [ -d "$HOME/.cache/midnight/zk-params" ]; then
echo "⚠️ Hash mismatch detected *and* zk-params exists. Removing cache..."
echo "Hash mismatch detected. Clearing zk-params cache..."
rm -rf "$HOME/.cache/midnight/zk-params"
echo "::notice::♻️ Retrying compilation after clearing zk-params..."
turbo compact --concurrency=1 || { echo "::error::❌ Retry also failed."; exit 1; }
echo "Retrying compilation..."
turbo compact --concurrency=1
else
echo "🚫 Compilation failed for another reason or zk-params missing. No retry."
echo "$output"
exit 1
fi
fi
}

compile

- name: Run type checks
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@

Make sure you have [nvm](https://github.com/nvm-sh/nvm), [yarn](https://yarnpkg.com/getting-started/install), and [turbo](https://turborepo.com/docs/getting-started/installation) installed on your machine.

Follow Midnight's [compact installation guide](https://docs.midnight.network/develop/tutorial/building/#midnight-compact-compiler) and confirm that `compactc` is in the `PATH` env variable.
Follow Midnight's [Compact Developer Tools installation guide](https://docs.midnight.network/develop/tutorial/building/#midnight-compact-compiler) and confirm that `compact` is in the `PATH` env variable.

```bash
$ compactc
$ compact compile --version

Compactc version: 0.24.0
Usage: compactc.bin <flag> ... <source-pathname> <target-directory-pathname>
--help displays detailed usage information
0.24.0
```

## Set up the project
Expand All @@ -32,7 +31,7 @@ Usage: compactc.bin <flag> ... <source-pathname> <target-directory-pathname>
> - [node](https://nodejs.org/)
> - [yarn](https://yarnpkg.com/getting-started/install)
> - [turbo](https://turborepo.com/docs/getting-started/installation)
> - [compact](https://docs.midnight.network/develop/tutorial/building/#midnight-compact-compiler)
> - [compact](https://docs.midnight.network/blog/compact-developer-tools)

Clone the repository:

Expand Down
4 changes: 3 additions & 1 deletion compact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
"scripts": {
"build": "tsc -p .",
"types": "tsc -p tsconfig.json --noEmit",
"test": "yarn vitest run",
"clean": "git clean -fXd"
},
"devDependencies": {
"@types/node": "22.14.0",
"fast-check": "^3.15.0",
"typescript": "^5.8.2"
"typescript": "^5.8.2",
"vitest": "^3.1.3"
},
"dependencies": {
"chalk": "^5.4.1",
Expand Down
Loading
Loading