Skip to content

feat: Cluster smart-contract #780

feat: Cluster smart-contract

feat: Cluster smart-contract #780

Workflow file for this run

name: ci
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
pull-requests: read
packages: write
concurrency:
# Support push/pr as event types with different behaviors each:
# 1. push: queue up builds
# 2. pr: only allow one run per PR
group: ${{ github.workflow }}-${{ github.event_name }}${{ github.event.pull_request.number }}
# If there is already a workflow running for the same pull request, cancel it
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
RUST_STABLE: 1.85.0
RUST_NIGHTLY: nightly-2025-02-23
jobs:
changed-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changed
with:
filters: |
rust:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
cargo-toml:
- '**/Cargo.toml'
rustfmt-toml:
- 'rustfmt.toml'
clippy-toml:
- 'clippy.toml'
deny-toml:
- 'deny.toml'
dockerfile:
- 'Dockerfile'
version:
- 'VERSION'
outputs:
rust: ${{ steps.changed.outputs.rust }}
cargo-toml: ${{ steps.changed.outputs.cargo-toml }}
rustfmt-toml: ${{ steps.changed.outputs.rustfmt-toml }}
clippy-toml: ${{ steps.changed.outputs.clippy-toml }}
deny-toml: ${{ steps.changed.outputs.deny-toml }}
dockerfile: ${{ steps.changed.outputs.dockerfile }}
version: ${{ steps.changed.outputs.version }}
bump-version:
needs: [changed-files]
if: github.event_name == 'pull_request' && (needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.dockerfile == 'true')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: 'main'
- id: get-current-version
run: echo MAIN_VERSION=$(cat VERSION) >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
token: ${{ secrets.RELEASE_PAT }}
- id: bump-version
run: |
MAIN_MAJOR=$(echo "$MAIN_VERSION" | cut -d. -f1)
MAIN_MINOR=$(echo "$MAIN_VERSION" | cut -d. -f2)
TODAY=$(date +"%y%m%d")
if [[ $MAIN_MAJOR == $TODAY ]]; then
NEW_VERSION=$MAIN_MAJOR.$((MAIN_MINOR + 1))
else
NEW_VERSION=$TODAY.0
fi
LOCAL_VERSION=$(cat VERSION)
if [[ $LOCAL_VERSION == $NEW_VERSION ]]; then
exit 0
fi
echo "${NEW_VERSION}" > VERSION
git config user.name "Github Bot"
git config user.email "github@walletconnect.com"
git add VERSION
git commit -m "Bump VERSION to ${NEW_VERSION}"
git push
misspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-misspell@v1
cargo-build:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true'
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE }}
- uses: Swatinem/rust-cache@v2
- run: cargo build --workspace --all-features
cargo-test:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true'
runs-on:
group: ubuntu-runners
strategy:
fail-fast: false
matrix:
test: [doc, unit, integration]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE }}
- uses: Swatinem/rust-cache@v2
- run: |
TEST_KIND=${{ matrix.test }}
if [[ $TEST_KIND == 'doc' ]] ; then
cargo test --workspace --doc --all-features
elif [[ $TEST_KIND == 'unit' ]]; then
RUST_LOG=info cargo test --all-features --workspace --exclude wcn_node
elif [[ $TEST_KIND == 'integration' ]]; then
RUST_LOG=info,openraft=error,relay_rocks=warn cargo test -p wcn_node --all-features --release
else
echo Unexpected test kind $TEST_KIND
exit 1
fi
cargo-fmt:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.rustfmt-toml == 'true'
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_NIGHTLY }}
components: rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
cargo-clippy:
needs: [changed-files]
if: needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.clippy-toml == 'true'
runs-on:
group: ubuntu-runners
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_NIGHTLY }}
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets --all-features --tests -- -D warnings
cargo-deny:
needs: [changed-files]
if: needs.changed-files.outputs.cargo-toml == 'true' || needs.changed-files.outputs.deny-toml == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
rust-version: ${{ env.RUST_STABLE }}
command: check license
docker-build-push:
needs: [changed-files, cargo-build, cargo-test, cargo-fmt, cargo-clippy, cargo-deny]
if: |
needs.changed-files.result != 'failure' &&
(needs.changed-files.outputs.rust == 'true' || needs.changed-files.outputs.dockerfile == 'true') &&
needs.cargo-build.result != 'failure' &&
needs.cargo-test.result != 'failure' &&
needs.cargo-fmt.result != 'failure' &&
needs.cargo-clippy.result != 'failure' &&
needs.cargo-deny.result != 'failure' &&
!cancelled()
runs-on:
group: ubuntu-runners
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- uses: docker/setup-buildx-action@v2
- id: read-version
run: echo VERSION=$(cat VERSION) >> $GITHUB_ENV
- id: docker-meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/walletconnectfoundation/wcn-node
${{ steps.login-ecr.outputs.registry }}/irn
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha
${{ github.ref_name == 'main' && env.VERSION || '' }}
- uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.docker-meta.outputs.tags }}
push: true
release:
needs: [changed-files]
if: github.ref_name == 'main' && needs.changed-files.outputs.version == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_PAT }}
- id: generate-changelog
run: |
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [[ "$LAST_TAG" ]]; then
CHANGELOG=$(git log ${LAST_TAG}..HEAD --pretty=format:"* %s")
else
CHANGELOG=$(git log --pretty=format:"* %s")
fi
echo "::set-output name=changelog::$CHANGELOG"
- name: push-tag
run: |
VERSION=$(cat VERSION)
git tag $VERSION
git push origin "$VERSION"
echo VERSION=$VERSION >> $GITHUB_ENV
- uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
body: ${{ steps.generate-changelog.outputs.changelog }}
token: ${{ secrets.RELEASE_PAT }}