Extend plugin diagnostics with warnings (#2702) #874
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@bbdd97482f2d439126582a59689eb1c855944955 | |
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@7b1c307e0dcbda6122208f10795a713336a9b35a | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab | |
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/setup-scarb@v1 | |
- 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: "http://188.34.188.184:7070/rpc/v0_7" | |
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@72d65cee1f8033ef0c8b5d79eaf0c45c7c578ce3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
draft: true | |
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 }} | |
publish-snforge-scarb-plugin: | |
name: Publish snforge_scarb_plugin | |
uses: ./.github/workflows/publish_plugin.yml | |
secrets: inherit | |
publish-to-registry: | |
name: Publish packages to the registry | |
runs-on: ubuntu-latest | |
needs: [ create-release, publish-snforge-scarb-plugin ] | |
env: | |
SCARB_REGISTRY_AUTH_TOKEN: ${{ secrets.SCARB_REGISTRY_AUTH_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a | |
with: | |
toolchain: stable | |
- uses: software-mansion/setup-scarb@v1 | |
with: | |
scarb-version: "2.8.5" | |
- name: Publish sncast_std | |
working-directory: sncast_std | |
run: scarb publish --allow-dirty | |
- name: Publish snforge_std | |
working-directory: snforge_std | |
run: | | |
../scripts/set_plugin_version.sh | |
scarb publish --allow-dirty |