Skip to content

mock_call appendix revamp (#2020) #586

mock_call appendix revamp (#2020)

mock_call appendix revamp (#2020) #586

Workflow file for this run

name: Release
on:
push:
branches:
- 'master'
tags:
- v[0-9]+.*
permissions:
contents: write
jobs:
verify-version:
name: Verify that version that triggered this workflow is greater than most recent release
runs-on: ubuntu-latest
outputs:
versionIsValid: ${{ steps.validVersion.outputs.versionIsValid }}
version: ${{ steps.validVersion.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: 'npm'
cache-dependency-path: scripts/package-lock.json
- run: npm ci
working-directory: scripts
- name: Get version from Cargo.toml
id: lookupVersion
uses: mikefarah/yq@c35ec752e38ea0c096d3c44e13cfc0797ac394d8
with:
cmd: yq -oy '"v" + .workspace.package.version' 'Cargo.toml'
- name: Get version from the latest releases
id: lookupVersionRelease
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: foundry-rs
repo: starknet-foundry
excludes: prerelease, draft
- name: Compare versions
id: validVersion
run: |
RELEASE_VERSION=${{ steps.lookupVersionRelease.outputs.release }}
COMMIT_VERSION=${{ steps.lookupVersion.outputs.result }}
echo "Project version from newest release = $RELEASE_VERSION"
echo "Project version from this commit = $COMMIT_VERSION"
IS_VALID=$(node ./scripts/compareVersions.js $RELEASE_VERSION $COMMIT_VERSION)
echo "versionIsValid=$IS_VALID" >> "$GITHUB_OUTPUT"
echo "version=$COMMIT_VERSION" >> "$GITHUB_OUTPUT"
- name: Output job skipped
if: ${{ steps.validVersion.outputs.versionIsValid == 'false' }}
run: echo "Version from commit is not greater from newest release, skipping build"
build-binaries:
name: Build ${{ matrix.target }}
needs: verify-version
if: ${{ needs.verify-version.outputs.versionIsValid == 'true' }}
runs-on: ${{ matrix.os }}
continue-on-error: true
env:
# Cross-compiled targets will override this to `cross`.
CARGO: cargo
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
# Use cross to link oldest GLIBC possible.
cross: true
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
cross: true
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@dc6353516c68da0f06325f42ad880f76a5e77ec9
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84
with:
workspaces: starknet-foundry
- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@cross
- name: Enable cross-compilation
if: matrix.cross
shell: bash
run: |
echo "CARGO=cross" >> $GITHUB_ENV
- name: Build
run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
set -euxo pipefail
PKG_FULL_NAME="starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}"
echo "PKG_FULL_NAME=$PKG_FULL_NAME" >> $GITHUB_ENV
chmod +x ./scripts/package.sh
./scripts/package.sh "${{ matrix.target }}" "$PKG_FULL_NAME"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: ${{ env.PKG_FULL_NAME }}.*
test-binary:
name: Test binary
runs-on: ${{ matrix.os }}
needs: [ build-binaries, verify-version ]
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- uses: software-mansion/[email protected]
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl
- name: Move artifacts to staging director
shell: bash
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/starknet-foundry-* artifacts/
- name: Get binary path
shell: bash
run: |
if [[ ${{ matrix.target }} == *windows* ]]; then
BINARY_PATH="artifacts/starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}.zip"
else
BINARY_PATH="artifacts/starknet-foundry-${{ needs.verify-version.outputs.version }}-${{ matrix.target }}.tar.gz"
fi
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
- name: Unpack artifact
shell: bash
run: |
if [[ ${{ matrix.target }} == *windows* ]]; then
unzip ${{ env.BINARY_PATH }}
else
tar xzvf ${{ env.BINARY_PATH }}
fi
- name: Install universal-sierra-compiler
uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Smoke test
shell: bash
env:
RPC_URL: ${{ secrets.CHEATNET_RPC_URL }}
run: |
BINARY_PATH="${{ env.BINARY_PATH }}"
BINARY_PATH="${BINARY_PATH%.tar.gz}"
BINARY_PATH="${BINARY_PATH%.zip}"
BINARY_PATH="${BINARY_PATH#artifacts/}"
if [[ ${{ matrix.target }} == *windows* ]]; then
SNFORGE_PATH=$(readlink -f $BINARY_PATH/bin/snforge.exe)
SNCAST_PATH=$(readlink -f $BINARY_PATH/bin/sncast.exe)
else
SNFORGE_PATH=$(readlink -f $BINARY_PATH/bin/snforge)
SNCAST_PATH=$(readlink -f $BINARY_PATH/bin/sncast)
fi
REPO_URL=${{ github.repositoryUrl }}
REVISION=${{ github.sha }}
./scripts/smoke_test.sh "$RPC_URL" "$SNFORGE_PATH" "$SNCAST_PATH" "$REPO_URL" "$REVISION"
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [ test-binary, verify-version ]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts-dl
- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/starknet-foundry-* artifacts/
- name: Create GitHub release
id: create-release
uses: taiki-e/create-gh-release-action@8df4de6534ceacdaed10a08f73418ca751f31793
with:
token: ${{ secrets.GITHUB_TOKEN }}
changelog: CHANGELOG.md
allow-missing-changelog: false
title: $version
ref: refs/tags/${{ needs.verify-version.outputs.version }}
- name: Upload artifacts to the release
working-directory: artifacts
run: gh release upload "$TAG" *
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.create-release.outputs.computed-prefix }}${{ steps.create-release.outputs.version }}
deploy-docs:
name: Deploy documentation
needs: [ create-release, verify-version ]
permissions:
contents: read
pages: write
id-token: write
if: ${{ !contains(needs.verify-version.outputs.version, '-') }}
uses: ./.github/workflows/docs.yml