Skip to content

Commit

Permalink
Alpha Release
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandarmilicevic committed Apr 8, 2024
0 parents commit c89cbaf
Show file tree
Hide file tree
Showing 418 changed files with 52,596 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[alias]
xtask = "run --package xtask --"

[doc.extern-map.registries]
crates-io = "https://docs.rs/"
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cubist-node-sdk/src/config/schema/*.schema.json linguist-generated=true
22 changes: 22 additions & 0 deletions .github/actions/run-with-ssh-key/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Rust as cubist-readonly-bot
description: Rust as cubist-readonly-bot

inputs:
run:
description: "Commands to run"
required: true
secret-ssh-key:
description: "Secret ssh key to use"
required: true

runs:
using: "composite"
steps:
- name: Start ssh-agent and run command
shell: bash
run: |
set -e
eval "$(ssh-agent -s)"
ssh-add <(echo "${{ inputs.secret-ssh-key }}")
ssh -o "StrictHostKeyChecking=no" [email protected] || true
${{ inputs.run }}
49 changes: 49 additions & 0 deletions .github/actions/rust-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Rust with caching and sccaching support
description: Rust with caching and sccaching support

inputs:
key:
description: "Key to use for the cache (combined with date)"
required: true
additional-restore-key:
description: "Additional key to use for the restore (combined with date)"
type: false
path:
description: "Additional paths to cache"
required: false

runs:
using: "composite"
steps:
# From https://github.com/actions/cache#creating-a-cache-key
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash

- name: Cache target directory and cargo directories
uses: actions/cache@v3
with:
path: |
target
~/.cargo/bin
~/.cargo/registry
~/.cargo/git
~/.cache/sccache
~/.rustup
${{ inputs.path }}
key: ${{ inputs.key }}-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ inputs.key }}-${{ steps.get-date.outputs.date }}
${{ inputs.additional-retore-key }}-${{ steps.get-date.outputs.date }}
- name: Install sccache
shell: bash
run: |
set -euo pipefail
wget -O sccache.tgz -q https://github.com/mozilla/sccache/releases/download/v0.3.0/sccache-v0.3.0-x86_64-unknown-linux-musl.tar.gz
tar xzvf sccache.tgz
sudo cp -vf sccache-v0.3.0-x86_64-unknown-linux-musl/sccache /usr/bin/sccache
sudo chmod -v +x /usr/bin/sccache
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 10
- package-ecosystem: "npm"
directory: "/cubist-node-sdk" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 10
39 changes: 39 additions & 0 deletions .github/workflows/config-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Config schema

on:
workflow_dispatch:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
branches: [ "main" ]
paths:
- ".github/workflows/config-schema.yml"
- "cubist-config/**"
- "cubist-node-sdk/src/config/**/*.schema.json"
push:
branches: ["main"]

env:
CARGO_TERM_COLOR: always

jobs:
schema-check:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3

- name: Generate schema files and make sure they're the same as the checked-in ones
run: |
set -eu
cargo xtask generate-schema /tmp/
echo "Comparing config.schema.json"
diff /tmp/config.schema.json cubist-node-sdk/src/config/schema/config.schema.json
echo "Comparing pre_compile_manifest.schema.json"
diff /tmp/pre_compile_manifest.schema.json cubist-node-sdk/src/config/schema/pre_compile_manifest.schema.json
echo "Comparing axelar_manifest.schema.json"
diff /tmp/axelar_manifest.schema.json cubist-node-sdk/src/config/schema/axelar_manifest.schema.json
# Only run a single instance of this workflow per branch/tag
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
16 changes: 16 additions & 0 deletions .github/workflows/leaked_secrets_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Leaked Secrets Scan
on: [pull_request]
jobs:
TruffleHog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run TruffleHog on changes in PR
uses: trufflesecurity/trufflehog@main
with:
path: ./
base: ${{ github.event.repository.default_branch }}
head: HEAD
extra_args: --debug --only-verified
67 changes: 67 additions & 0 deletions .github/workflows/node-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Node.js SDK

on:
# Run every day at 1am to initialize the daily cache
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
branches: [ "main" ]
push:
branches: ["main"]

env:
CARGO_TERM_COLOR: always
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 1G


jobs:
node-sdk-build:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
defaults:
run:
working-directory: cubist-node-sdk
strategy:
matrix:
node-version: [ 18.x, 20.x ]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache-dependency-path: cubist-node-sdk/yarn.lock
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
- name: Lint
run: yarn lint
- name: Set up Rust with caching
uses: ./.github/actions/rust-cache
with:
key: node-${{ hashFiles('Cargo.lock') }}
additional-restore-key: rust-${{ hashFiles('Cargo.lock') }}

- name: Build Cubist
run: cargo build --bin cubist

- name: Build
run: yarn build

- name: Test
run: |
set -eu
if [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ] && [ ! -z "${{ secrets.CUBIST_TESTNET_MNEMONIC }}" ]; then
echo 'CUBIST_TESTNET_MNEMONIC = "${{ secrets.CUBIST_TESTNET_MNEMONIC }}"' > .env
fi
yarn test
# Only run a single instance of this workflow per branch/tag
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.node-version }}
cancel-in-progress: true
62 changes: 62 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Rust

on:
# Run every day at 1am to initialize the daily cache
schedule:
- cron: "0 1 * * *"
workflow_dispatch:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
branches: [ "main" ]
push:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
RUSTC_WRAPPER: sccache
SCCACHE_CACHE_SIZE: 1G

jobs:
rust-build:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v3

- name: Set up Rust with caching
uses: ./.github/actions/rust-cache
with:
key: rust-${{ hashFiles('Cargo.lock') }}
additional-restore-key: node-${{ hashFiles('Cargo.lock') }}

- name: Run clippy
run: cargo clippy --profile ci --examples --tests -- -D warnings

- name: Run fmt
run: cargo fmt -- --check

- name: Rust doc
run: utils/mk-rust-docs.sh
shell: bash
env:
CARGO_DOC_EXTRA_ARGS: --profile ci

- name: Run tests
uses: ./.github/actions/run-with-ssh-key
with:
secret-ssh-key: ${{ secrets.CUBIST_DEV_READONLY_BOT_SSH_PRIVATE_KEY }}
run: |
if [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ] && [ ! -z "${{ secrets.CUBIST_TESTNET_MNEMONIC }}" ]; then
# Mnemonic for 0x70666c5b9879109d4082481093576533c84866c4
echo 'CUBIST_TESTNET_MNEMONIC = "${{ secrets.CUBIST_TESTNET_MNEMONIC }}"' > .env
fi
cargo test --profile ci --verbose -- --nocapture
- name: Print sccache stats
if: ${{ always() }}
run: sccache --show-stats

# Only run a single instance of this workflow per branch/tag
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*~
\#*\#
.\#*
.env*
target/*
.vscode
.DS_Store
5 changes: 5 additions & 0 deletions .rusty-hook.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[hooks]
pre-commit = "cargo fmt --check && cargo clippy --tests --examples -- -D warnings && env RUSTDOCFLAGS='-D warnings' cargo doc --package 'cubist*' --no-deps"

[logging]
verbose = true
Loading

0 comments on commit c89cbaf

Please sign in to comment.