Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rust client sdk #41

Merged
merged 32 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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
9 changes: 8 additions & 1 deletion .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ programs: &programs

client_common: &client_common
- *programs
- ".github/workflows/test-js.yml"
- ".github/workflows/test-js-client.yml"
- ".github/workflows/test-rust-client.yml"
- ".github/workflows/build-rust-client.yml"
- ".github/workflows/main.yml"
- ".github/file-filters.yml"
- ".github/.env"
Expand All @@ -34,8 +36,13 @@ js_client: &js_client
- *client_common
- "clients/js/**"

rust_client: &rust_client
- *client_common
- "clients/rust/**"

clients: &clients
- *js_client
- *rust_client

# Any.

Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/build-rust-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build Rust Client

on:
workflow_call:
inputs:
rust:
type: string
solana:
type: string
workflow_dispatch:
inputs:
rust:
description: Rust version
default: 1.68.0
required: true
type: string
solana:
description: Solana version
default: 1.16.8
required: true
type: string

env:
CACHE: true

jobs:
build_sdk:
name: Build
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3

- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV

- name: Install Rust
uses: metaplex-foundation/actions/install-rust@v1
with:
toolchain: ${{ inputs.rust || env.RUST_VERSION }}

- name: Install Solana
uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ inputs.solana || env.SOLANA_VERSION }}
cache: ${{ env.CACHE }}

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets --all-features --no-deps --manifest-path ./clients/rust/Cargo.toml

- name: Build Rust client
shell: bash
working-directory: clients/rust
run: cargo build --release

- name: Upload Rust client builds
uses: actions/upload-artifact@v3
with:
name: rust-client-builds
# First wildcard ensures exported paths are consistently under the clients folder.
path: ./client*/rust/target/release/*mpl_token_metadata*
if-no-files-found: error
36 changes: 12 additions & 24 deletions .github/workflows/create-proposal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,21 @@ jobs:
- name: Determine program version
run: |
IDL_NAME=`echo "${{ inputs.program }}" | tr - _`
VERSION=`jq '.version' ./idls/mpl_${IDL_NAME}.json | sed 's/"//g'`
VERSION=`jq '.version' ./idls/${IDL_NAME}.json | sed 's/"//g'`

MAJOR=`echo ${VERSION} | cut -d. -f1`
MINOR=`echo ${VERSION} | cut -d. -f2`
PATCH=`echo ${VERSION} | cut -d. -f3-4`

case "$PATCH" in
*"beta"*)
PRERELEASE=`echo ${PATCH} | cut -d. -f2`
PATCH=`echo ${PATCH} | cut -d- -f1`
;;
*)
PRERELEASE=0
;;
esac

if [ $PRERELEASE -eq 0 ]; then
if [ "${{ inputs.bump }}" == "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "${{ inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
PATCH=`echo ${VERSION} | cut -d. -f3`

if [ "${{ inputs.bump }}" == "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "${{ inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi

echo PROGRAM_VERSION="${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_ENV
Expand Down
File renamed without changes.
92 changes: 92 additions & 0 deletions .github/workflows/deploy-rust-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Deploy Rust Client

on:
workflow_dispatch:
inputs:
level:
description: Level
required: true
default: patch
type: choice
options:
- patch
- minor
- major
- rc
- beta
- alpha
- release
- version
version:
description: Version
required: false
type: string
dry_run:
description: Dry run
required: true
default: true
type: boolean

env:
CACHE: true

jobs:
build_rust_client:
name: Rust Client
uses: ./.github/workflows/build-rust-client.yml
secrets: inherit

test_rust_client:
name: Rust Client
needs: build_rust_client
uses: ./.github/workflows/test-rust-client.yml
secrets: inherit

publish_crate:
name: Rust Client / Publish Crate
runs-on: ubuntu-latest
needs: test_rust_client
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.SVC_TOKEN }}

- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV

- name: Install Rust
uses: metaplex-foundation/actions/install-rust@v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Install Solana
uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
cache: ${{ env.CACHE }}

- name: Install cargo-release
uses: metaplex-foundation/actions/install-cargo-release@v1
with:
cache: ${{ env.CACHE }}

- name: Publish Crate
working-directory: ./clients/rust
run: |
if [ "${{ inputs.level }}" == "version" ]; then
BUMP=${{ inputs.version }}
else
BUMP=${{ inputs.level }}
fi

if [ "${{ inputs.dry_run }}" == "false" ]; then
OPTIONS="--no-confirm --execute"
fi

if [ "${{ inputs.level }}" == "version" ]; then

cargo login ${{ secrets.CRATES_TOKEN }}
cargo release $BUMP $OPTIONS
19 changes: 17 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
js_changed: ${{ steps.changes.outputs.js_client }}
rust_changed: ${{ steps.changes.outputs.rust_client }}
permissions:
contents: write
steps:
Expand Down Expand Up @@ -98,9 +99,23 @@ jobs:
with:
filters: .github/file-filters.yml

test_js:
test_js_client:
if: needs.generate_clients.outputs.js_changed == 'true'
name: JS Client
needs: generate_clients
uses: ./.github/workflows/test-js.yml
uses: ./.github/workflows/test-js-client.yml
secrets: inherit

build_rust_client:
if: needs.generate_clients.outputs.rust_changed == 'true'
name: Rust Client
needs: generate_clients
uses: ./.github/workflows/build-rust-client.yml
secrets: inherit
febo marked this conversation as resolved.
Show resolved Hide resolved

test_rust_client:
if: needs.generate_clients.outputs.rust_changed == 'true'
name: Rust Client
needs: generate_clients
uses: ./.github/workflows/test-rust-client.yml
secrets: inherit
File renamed without changes.
42 changes: 42 additions & 0 deletions .github/workflows/test-rust-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test Rust Client

on:
workflow_call:
inputs:
program_matrix:
type: string

env:
CACHE: true

jobs:
test_sdk:
name: Test
runs-on: ubuntu-latest-16-cores
steps:
- name: Git checkout
uses: actions/checkout@v3

- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV

- name: Install Rust
uses: metaplex-foundation/actions/install-rust@v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Install Solana
uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
cache: ${{ env.CACHE }}

- name: Download program builds
uses: actions/download-artifact@v3
with:
name: program-builds

- name: Run tests
shell: bash
working-directory: configs/client-scripts
run: RUST_LOG=error ./test-rust-client.sh
Loading