diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml deleted file mode 100644 index 43f0b12b..00000000 --- a/.github/actions/setup-rust/action.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: "Setup Rust" -description: "Setup Rust" -runs: - using: "composite" - steps: - - name: Set up cargo cache ${{ env.PLUGIN_RUST_VERSION }} - uses: Swatinem/rust-cache@v2 - - - name: Get Rustc version - run: | - source scripts/ci/rust-version.sh - echo "PLUGIN_RUST_VERSION=$rust_stable" >> $GITHUB_ENV - shell: bash - - - name: Install Rust ${{ env.PLUGIN_RUST_VERSION }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.PLUGIN_RUST_VERSION }} - override: true - profile: minimal - diff --git a/.github/actions/setup-solana/action.yaml b/.github/actions/setup-solana/action.yml similarity index 54% rename from .github/actions/setup-solana/action.yaml rename to .github/actions/setup-solana/action.yml index 693d6c99..0f0fa2ae 100644 --- a/.github/actions/setup-solana/action.yaml +++ b/.github/actions/setup-solana/action.yml @@ -3,15 +3,15 @@ description: "Setup Solana" runs: using: "composite" steps: - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Cache Solana Tool Suite id: cache-solana with: path: | ~/.cache/solana/ ~/.local/share/solana/ - key: solana-${{ runner.os }}-v0000-${{ env.SOLANA_VERSION }} - - uses: nick-fields/retry@v2 + key: solana-${{ runner.os }}-v${{ env.SOLANA_CLI_VERSION }} + - uses: nick-fields/retry@v3 if: steps.cache-solana.outputs.cache-hit != 'true' with: retry_wait_seconds: 300 @@ -19,12 +19,10 @@ runs: max_attempts: 10 retry_on: error shell: bash - command: sh -c "$(curl -sSfL https://release.solana.com/${{ env.SOLANA_VERSION }}/install)" - - run: sh -c "$(curl -sSfL https://release.solana.com/${{ env.SOLANA_VERSION }}/install)" + command: sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_CLI_VERSION }}/install)" + - run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH shell: bash - - - run: | - echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH - shell: bash - - run: solana-install init ${{ env.SOLANA_VERSION }} + - run: solana-keygen new --no-bip39-passphrase shell: bash + - run: solana config set --url localhost + shell: bash \ No newline at end of file diff --git a/.github/workflows/bump-release.yaml b/.github/workflows/bump-release.yaml deleted file mode 100644 index c67dfd0a..00000000 --- a/.github/workflows/bump-release.yaml +++ /dev/null @@ -1,224 +0,0 @@ -# name: Bump and Release - -# on: -# workflow_dispatch: -# inputs: -# bump: -# description: 'New version' -# required: true -# default: 'patch' -# type: choice -# options: -# - major -# - minor -# - patch -# - rc -# - beta -# - alpha -# extra_args: -# description: 'Extra args to pass to bump-version.sh, e.g: --dry-run.' -# required: false -# default: '--exclude clockwork-thread-program-v1' - -# env: -# CARGO_TERM_COLOR: always -# ANCHOR_VERSION: v0.27.0 -# PUBLISH_PREFIX: clockwork - -# jobs: -# build-all: -# runs-on: ${{ matrix.os }} -# strategy: -# fail-fast: true -# matrix: -# include: -# - os: macos-latest -# target: x86_64-apple-darwin -# - os: macos-latest -# target: aarch64-apple-darwin -# - os: ubuntu-20.04 -# target: x86_64-unknown-linux-gnu -# steps: -# - uses: actions/checkout@v3 - -# - name: Install core deps for mac if needed -# if: contains(runner.os, 'mac') -# run: | -# env HOMEBREW_NO_AUTO_UPDATE=1 brew install jq -# - name: Install core deps -# if: contains(runner.os, 'linux') -# uses: awalsh128/cache-apt-pkgs-action@latest -# with: -# packages: jq pkg-config build-essential libudev-dev libssl-dev -# execute_install_scripts: true - -# - name: Install Rust Stable to use with tools -# uses: actions-rs/toolchain@v1 -# with: -# toolchain: stable -# override: true -# profile: minimal - -# - name: Install cargo-edit -# uses: baptiste0928/cargo-install@v2 -# with: -# crate: cargo-edit -# version: "0.11.9" - -# - name: Run version bump script -# run: | -# source ./scripts/ci/bump-version.sh ${{ github.event.inputs.bump }} ${{ github.event.inputs.extra_args }} -# echo "$old_version" > OLD_VERSION - -# - name: Create artificats of changes from diff -# run: | -# git status --porcelain | sed s/^...// | tar -cvf changes.tar --files-from - -# mkdir -p changes -# cd changes -# mv ../changes.tar . -# tar -xvf changes.tar -# rm changes.tar -# cd - -# shell: bash - -# - name: Upload source with bumped version -# uses: actions/upload-artifact@v3 -# with: -# if-no-files-found: error -# name: bumped_source -# path: changes/**/* - -# - name: Env variables -# run: | -# chmod +x ./scripts/ci/solana-version.sh -# echo "CI_TAG=v$(cat VERSION)" >> $GITHUB_ENV -# SOLANA_VERSION="$(./scripts/ci/solana-version.sh)" -# SOLANA_VERSION="v${SOLANA_VERSION#=}" -# echo "SOLANA_VERSION=$SOLANA_VERSION" >> "$GITHUB_ENV" - -# - uses: ./.github/actions/setup-solana/ - -# - name: Install anchor -# uses: baptiste0928/cargo-install@v2 -# with: -# crate: anchor-cli -# args: --git https://github.com/coral-xyz/anchor --tag ${{ env.ANCHOR_VERSION }} - -# - name: Install Rust ${{ env.PLUGIN_RUST_VERSION }} -# uses: ./.github/actions/setup-rust/ - -# - uses: Swatinem/rust-cache@v2 -# with: -# key: tarball-${{ runner.target }}-build-${{ hashFiles('**/Cargo.lock') }} -# - name: Build release tarball -# run: | -# chmod +x ./scripts/ci/create-tarball.sh -# chmod +x ./scripts/build-all.sh -# ./scripts/ci/create-tarball.sh --target ${{ matrix.target }} - -# - name: Upload tarball -# uses: actions/upload-artifact@v3 -# with: -# if-no-files-found: error -# name: release_build -# path: clockwork-geyser-plugin-release-* - - -# release: -# needs: -# - build-all -# runs-on: ubuntu-20.04 -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/download-artifact@v3 -# with: -# name: bumped_source - -# - name: Install jq -# if: contains(runner.os, 'mac') -# run: | -# env HOMEBREW_NO_AUTO_UPDATE=1 brew install jq -# - name: Install jq -# if: contains(runner.os, 'linux') -# uses: awalsh128/cache-apt-pkgs-action@latest -# with: -# packages: jq -# execute_install_scripts: true - -# - name: Install Rust Stable to use with tools -# uses: actions-rs/toolchain@v1 -# with: -# toolchain: stable -# override: true -# profile: minimal - -# - name: Env variables -# run: | -# chmod +x ./scripts/ci/solana-version.sh -# echo "CI_TAG=v$(cat VERSION)" >> $GITHUB_ENV -# echo "OLD_VERSION=v$(cat OLD_VERSION)" >> $GITHUB_ENV -# SOLANA_VERSION="$(./scripts/ci/solana-version.sh)" -# SOLANA_VERSION="v${SOLANA_VERSION#=}" -# echo "SOLANA_VERSION=$SOLANA_VERSION" >> "$GITHUB_ENV" -# chmod +x ./scripts/ci/rust-version.sh -# source scripts/ci/rust-version.sh -# echo "PLUGIN_RUST_VERSION=$rust_stable" >> $GITHUB_ENV - -# - name: Commit and tag -# uses: EndBug/add-and-commit@v9 -# with: -# message: Bump from ${{ env.OLD_VERSION }} to ${{ env.CI_TAG }} -# tag: ${{ env.CI_TAG }} - -# - uses: actions/download-artifact@v3 -# with: -# name: release_build - -# - name: Publish Github release -# uses: softprops/action-gh-release@v1 -# with: -# fail_on_unmatched_files: true -# name: ${{ env.CI_TAG }} -# tag_name: ${{ env.CI_TAG }} -# body: | -# clockwork-geyser-plugin ${{ env.CI_TAG }} -# solana ${{ env.SOLANA_VERSION }} -# rust ${{ env.PLUGIN_RUST_VERSION }} -# # this gh action ignores the working directory, and defaults to the root of the repo -# files: | -# clockwork-geyser-plugin-release-* - - -# publish-crate: -# needs: -# - build-all -# - release -# runs-on: ubuntu-20.04 -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/download-artifact@v3 -# with: -# name: bumped_source - -# - name: Install Rust Stable to use with tools -# uses: actions-rs/toolchain@v1 -# with: -# override: true -# toolchain: stable -# profile: minimal - -# - name: Install cargo-publish-workspace-v2 -# uses: baptiste0928/cargo-install@v2 -# with: -# crate: cargo-publish-workspace-v2 - -# - name: Env variables -# run: | -# echo "CI_TAG=v$(cat VERSION)" >> $GITHUB_ENV - -# - name: Publish to crates.io -# env: -# CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} -# run: | -# cargo +stable publish-workspace --crate-prefix ${{ env.PUBLISH_PREFIX }} -- --allow-dirty --no-verify - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b4de07ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: Lints and Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + SOLANA_CLI_VERSION: 1.18.2 + ANCHOR_CLI_VERSION: 0.29.0 + +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Setup Solana CLI + uses: ./.github/actions/setup-solana/ + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Setup Anchor CLI + run: npm install -g @coral-xyz/anchor-cli@${{ env.ANCHOR_CLI_VERSION }} + - name: Cargo tests + run: cargo test + env: + RUST_BACKTRACE: 1 + - name: Anchor tests + run: anchor test + timeout-minutes: 10 + + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run cargo fmt + run: cargo fmt --all -- --check + + - name: Run cargo clippy + run: cargo clippy --all-targets -- -D warnings \ No newline at end of file diff --git a/.github/workflows/code-scan.yaml b/.github/workflows/code-scan.yaml deleted file mode 100644 index 000c3b9b..00000000 --- a/.github/workflows/code-scan.yaml +++ /dev/null @@ -1,59 +0,0 @@ -# name: Code scan - -# on: -# push: -# branches: -# - main -# pull_request: -# branches: -# - main -# env: -# CARGO_TERM_COLOR: always - -# jobs: -# build: -# name: Build -# runs-on: ubuntu-latest -# container: projectserum/build:v0.27.0 -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 -# - name: Install default toolchain -# run: rustup default stable -# - uses: Swatinem/rust-cache@v2 -# - name: Build -# run: cargo build --locked - -# audit: -# needs: build -# name: Audit ${{ matrix.node.path }} -# runs-on: ubuntu-latest -# container: projectserum/build:v0.27.0 -# strategy: -# fail-fast: false -# matrix: -# node: -# - cmd: export PATH=$PWD/soteria-linux-develop/bin:$PATH && cd programs/network && soteria -analyzeAll . -# path: programs/network -# - cmd: export PATH=$PWD/soteria-linux-develop/bin:$PATH && cd programs/thread && soteria -analyzeAll . -# path: programs/thread -# - cmd: export PATH=$PWD/soteria-linux-develop/bin:$PATH && cd programs/webhook && soteria -analyzeAll . -# path: programs/webhook -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 -# - name: Install BPF toolchain -# run: | -# rustup default stable -# cd /root/.local/share/solana/install/active_release/bin/sdk/bpf -# rm -rf dependencies/* -# ./scripts/install.sh -# rustup default bpf -# cd $GITHUB_WORKSPACE -# cargo update -# - name: Install Soteria auditor -# run : | -# sh -c "$(curl -k https://supercompiler.xyz/install)" -# export PATH=$PWD/soteria-linux-develop/bin:$PATH -# - name: Run soteria on ${{ matrix.node.path }} -# run: ${{ matrix.node.cmd }} diff --git a/.github/workflows/update-solana.yaml b/.github/workflows/update-solana.yaml deleted file mode 100644 index 0db40bec..00000000 --- a/.github/workflows/update-solana.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# name: Update Solana - -# on: -# schedule: -# - cron: "00 00 * * *" # Run this worflow daily -# workflow_dispatch: - -# jobs: -# update-solana: -# name: Update Solana -# runs-on: ubuntu-latest -# timeout-minutes: 30 -# steps: -# - uses: actions/checkout@v2 -# - uses: clockwork-xyz/update-solana@v1.0.1 -# with: -# reviewers: nickgarfield -# labels: dependencies \ No newline at end of file diff --git a/Anchor.toml b/Anchor.toml index 7f38de21..62d7c96b 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -1,5 +1,5 @@ [provider] -cluster = "mainnet" +cluster = "localnet" wallet = "~/.config/solana/id.json" [programs.localnet]