Skip to content

Commit

Permalink
Merge pull request #54 from Flouse/record-codehash
Browse files Browse the repository at this point in the history
chore: record code_hash of contracts in CI
  • Loading branch information
ashuralyk authored Jan 25, 2024
2 parents f4d8f90 + fcd3282 commit 8eecb9f
Showing 1 changed file with 61 additions and 11 deletions.
72 changes: 61 additions & 11 deletions .github/workflows/capsule.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
name: Capsule build/test
on:
push:
pull_request:
paths:
- contracts/**
- lib/**
- tests/**

jobs:
capsule:
capsule-build-and-test:
strategy:
fail-fast: false
matrix:
include:
- target: debug
cargo-option: ""
target-dir: "build/debug"
- target: testnet
cargo-option: "--release"
target-dir: "build/release"
- target: mainnet
cargo-option: "--release -- --features release_export"
target-dir: "build/release"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/checkout@v4

- name: Prepare capsule v0.10.2
run: |
Expand All @@ -28,10 +38,50 @@ jobs:
run: cargo install cross --git https://github.com/cross-rs/cross

- name: Capsule build
run: capsule build
run: capsule build ${{ matrix.cargo-option }}

- name: Capsule test -- --nocapture
run: capsule test
- name: Capsule test
run: capsule test ${{ matrix.cargo-option }}



- name: List all the contract binaries of ${{ github.ref }}
run: ls -l ${{ matrix.target-dir }}

- name: Archive the contract binaries ${{ github.sha }}
uses: actions/upload-artifact@v4
with:
name: contract-binaries-${{ matrix.target }}-${{ github.sha }}
path: |
build/debug
build/release
outputs:
spore-contract-ref: ${{ github.sha }}

record-code-hash:
needs: capsule-build-and-test
strategy:
matrix:
target: [debug, testnet, mainnet]
runs-on: ubuntu-20.04
steps:
# TODO: add this codehash util into the `tests` directory
# or, simply use `ckb-cli util blake2b --binary-path ...` to get the codehash
- name: Checkout a code_hash tool
uses: actions/checkout@v4
with:
repository: Flouse/spore-contract
ref: codehash-tool

- uses: actions/download-artifact@v4
with:
name: contract-binaries-${{ matrix.target }}-${{ needs.capsule-build-and-test.outputs.spore-contract-ref }}
path: build

- name: Build codehash-tool
working-directory: build
run: cargo build

- name: Record code_hash of contract binaries
working-directory: build
run: |
echo "spore-contract-commit: ${{ needs.capsule-build-and-test.outputs.spore-contract-ref }}\n"
./target/debug/code_hash

0 comments on commit 8eecb9f

Please sign in to comment.