Skip to content

Commit

Permalink
Fix GH CI Rust setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Oct 4, 2024
1 parent 38fd480 commit 6c76ec9
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 43 deletions.
12 changes: 6 additions & 6 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ inputs:
cargo-cache-local-key:
description: The key to cache local cargo dependencies. Skips local cargo caching if not provided.
required: false
rust:
description: Install Rust if `true`. Defaults to `false`.
required: false
solana:
description: Install Solana if `true`. Defaults to `false`.
required: false
Expand All @@ -23,6 +20,9 @@ inputs:
runs:
using: 'composite'
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Setup pnpm
uses: pnpm/action-setup@v3

Expand All @@ -41,14 +41,13 @@ runs:
run: pnpm zx ./scripts/ci/set-env.mjs

- name: Install Rust
if: ${{ inputs.rust == 'true' }}
uses: dtolnay/rust-toolchain@master
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
components: rustc, cargo, rustfmt, clippy
cache: true

- name: Install Solana
if: ${{ inputs.solana == 'true' }}
uses: metaplex-foundation/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
Expand Down Expand Up @@ -98,5 +97,6 @@ runs:
.cargo/registry/index/
.cargo/registry/cache/
.cargo/git/db/
~/.cache/solana/
key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}
10 changes: 1 addition & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/setup
with:
rust: true

- name: Format Programs
run: pnpm programs:format
Expand Down Expand Up @@ -50,8 +48,6 @@ jobs:

- name: Setup Environment
uses: ./.github/actions/setup
with:
rust: true

- name: Format Client Rust
run: pnpm clients:rust:format
Expand All @@ -71,8 +67,6 @@ jobs:
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-programs
rust: true
solana: true

- name: Build Programs
run: pnpm programs:build
Expand All @@ -93,7 +87,7 @@ jobs:
test_programs:
name: Test Programs
runs-on: ubuntu-latest
needs: format_and_lint_programs
needs: build_programs
steps:
- name: Git Checkout
uses: actions/checkout@v4
Expand All @@ -103,8 +97,6 @@ jobs:
with:
cargo-cache-key: cargo-program-tests
cargo-cache-fallback-key: cargo-programs
rust: true
solana: true

- name: Test Programs
run: pnpm programs:test
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/publish-rust-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
uses: ./.github/actions/setup
with:
cargo-cache-key: cargo-rust-client
rust: true
solana: true

- name: Format Rust Client
run: pnpm clients:rust:format
Expand Down Expand Up @@ -74,7 +72,6 @@ jobs:
with:
cargo-cache-key: cargo-publish-rust-client
cargo-cache-fallback-key: cargo-rust-client
rust: true

- name: Install Cargo Release
run: which cargo-release || cargo install cargo-release
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repository = "https://github.com/dephy-io/dephy-id"
license = "Apache-2.0"

[workspace.metadata.cli]
solana = "2.0.13"
solana = "1.18.25"

[workspace.dependencies]
anchor-lang = "0.30.1"
Expand Down
35 changes: 19 additions & 16 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use arrayref::array_ref;
use clap::{Args, Parser, Subcommand, ValueEnum};
use dephy_id_program_client::{
instructions::{
ActivateDeviceBuilder, CreateDeviceBuilder, CreateProductBuilder, InitializeBuilder,
CreateActivatedDeviceNonSignerBuilder,
ActivateDeviceBuilder, CreateActivatedDeviceNonSignerBuilder, CreateDeviceBuilder,
CreateProductBuilder, InitializeBuilder,
},
types::{self, DeviceActivationSignature, CreateActivatedDeviceArgs},
types::{self, CreateActivatedDeviceArgs, DeviceActivationSignature},
DEVICE_MESSAGE_PREFIX, DEVICE_MINT_SEED_PREFIX, EIP191_MESSAGE_PREFIX, ID as PROGRAM_ID,
PRODUCT_MINT_SEED_PREFIX, PROGRAM_PDA_SEED_PREFIX,
};
Expand Down Expand Up @@ -80,9 +80,9 @@ enum DeviceSigningAlgorithm {
Secp256k1,
}

impl Into<types::DeviceSigningAlgorithm> for DeviceSigningAlgorithm {
fn into(self) -> types::DeviceSigningAlgorithm {
match self {
impl From<DeviceSigningAlgorithm> for types::DeviceSigningAlgorithm {
fn from(val: DeviceSigningAlgorithm) -> Self {
match val {
DeviceSigningAlgorithm::Ed25519 => types::DeviceSigningAlgorithm::Ed25519,
DeviceSigningAlgorithm::Secp256k1 => types::DeviceSigningAlgorithm::Secp256k1,
}
Expand Down Expand Up @@ -146,9 +146,9 @@ enum SignatureType {
EthSecp256k1,
}

impl Into<DeviceSigningAlgorithm> for SignatureType {
fn into(self) -> DeviceSigningAlgorithm {
match self {
impl From<SignatureType> for DeviceSigningAlgorithm {
fn from(val: SignatureType) -> Self {
match val {
SignatureType::Ed25519 => DeviceSigningAlgorithm::Ed25519,
SignatureType::Secp256k1 => DeviceSigningAlgorithm::Secp256k1,
SignatureType::EthSecp256k1 => DeviceSigningAlgorithm::Secp256k1,
Expand Down Expand Up @@ -257,13 +257,13 @@ fn get_client(url: &String) -> RpcClient {
let timeout = Duration::from_secs(10);
let commitment_config = CommitmentConfig::processed();
let confirm_transaction_initial_timeout = Duration::from_secs(10);
let client = RpcClient::new_with_timeouts_and_commitment(

RpcClient::new_with_timeouts_and_commitment(
url,
timeout,
commitment_config,
confirm_transaction_initial_timeout,
);
client
)
}

fn read_key(path: &String) -> Keypair {
Expand Down Expand Up @@ -486,7 +486,7 @@ fn dev_create_activated_device(args: DevCreateActivatedDeviceCliArgs) {
.instruction()],
Some(&payer.pubkey()),
&[&payer, &vendor],
latest_block
latest_block,
);

match client.send_and_confirm_transaction(&transaction) {
Expand All @@ -496,7 +496,10 @@ fn dev_create_activated_device(args: DevCreateActivatedDeviceCliArgs) {
eprintln!("Device: {}", device_pubkey);
eprintln!("Mint: {}", did_mint_pubkey);
eprintln!("AToken: {}", did_atoken_pubkey);
println!("{},{},{}", device_pubkey, did_mint_pubkey, did_atoken_pubkey);
println!(
"{},{},{}",
device_pubkey, did_mint_pubkey, did_atoken_pubkey
);
}
Err(err) => {
eprintln!("Error: {:?}", err);
Expand Down Expand Up @@ -698,8 +701,8 @@ fn sign_message(args: SignMessageCliArgs) {
| DeviceActivationSignature::EthSecp256k1(signature_bytes, recovery_id) => {
println!(
"{}{}",
hex::encode(&signature_bytes),
hex::encode(&[recovery_id])
hex::encode(signature_bytes),
hex::encode([recovery_id])
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ pub fn find_product_mint(

pub fn get_product_atoken(product_mint: &Pubkey, device: &Pubkey) -> Pubkey {
spl_associated_token_account::get_associated_token_address_with_program_id(
&device,
&product_mint,
device,
product_mint,
&spl_token_2022::id(),
)
}

pub fn get_device_atoken(user: &Pubkey, device_mint: &Pubkey) -> Pubkey {
spl_associated_token_account::get_associated_token_address_with_program_id(
&user,
&device_mint,
user,
device_mint,
&spl_token_2022::id(),
)
}
15 changes: 11 additions & 4 deletions scripts/program/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ import './dump.mjs';
const buildArgs = cliArguments();

// Build the programs.
await Promise.all(
getProgramFolders().map(async (folder) => {
// await Promise.all(
// getProgramFolders().map(async (folder) => {
// const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
//
// await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`;
// })
// );

// Build the programs.
getProgramFolders().forEach(async (folder) => {
const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');

await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`;
})
);
})

0 comments on commit 6c76ec9

Please sign in to comment.