diff --git a/.github/workflows/pull-request-docs.yml b/.github/workflows/pull-request-docs.yml deleted file mode 100644 index 3cba9da..0000000 --- a/.github/workflows/pull-request-docs.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Docs Pull Request - -on: - pull_request: - paths: - - 'docs/**' - push: - branches: [master] - paths: - - 'docs/**' - -jobs: - check_non_docs: - outputs: - run_all_github_action_checks: ${{ steps.check_files.outputs.run_all_github_action_checks }} - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - fetch-depth: 2 - - - name: check modified files - id: check_files - run: | - echo "========== check paths of modified files ==========" - echo "::set-output name=run_all_github_action_checks::true" - git diff --name-only HEAD^ HEAD > files.txt - while IFS= read -r file - do - if [[ $file != docs/** ]]; then - echo "Found modified non-'docs' file(s)" - echo "::set-output name=run_all_github_action_checks::false" - break - fi - done < files.txt - - all_github_action_checks: - runs-on: ubuntu-latest - needs: check_non_docs - if: needs.check_non_docs.outputs.run_all_github_action_checks == 'true' - steps: - - run: echo "Done" diff --git a/.github/workflows/pull-request-token-lending.yml b/.github/workflows/pull-request-token-lending.yml new file mode 100644 index 0000000..bf32e67 --- /dev/null +++ b/.github/workflows/pull-request-token-lending.yml @@ -0,0 +1,61 @@ +name: Token Lending Pull Request + +on: + pull_request: + paths-ignore: + - 'docs/**' + push: + branches: [master] + paths-ignore: + - 'docs/**' + +jobs: + cargo-test-sbf: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set env vars + run: | + source ci/rust-version.sh + echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV + source ci/solana-version.sh + echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ env.RUST_STABLE }} + override: true + profile: minimal + + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUST_STABLE}} + + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/bin/rustfilt + key: cargo-sbf-bins-${{ runner.os }} + + - uses: actions/cache@v2 + with: + path: ~/.cache/solana + key: solana-${{ env.SOLANA_VERSION }} + + - name: Install dependencies + run: | + ./ci/install-build-deps.sh + ./ci/install-program-deps.sh + echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH + - name: Build and test + run: ./ci/cargo-test-sbf.sh token-lending + + - name: Upload programs + uses: actions/upload-artifact@v2 + with: + name: token-lending-programs + path: "target/deploy/*.so" + if-no-files-found: error \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7934828..025e52e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -3,11 +3,11 @@ name: Pull Request on: pull_request: paths-ignore: - - 'docs/**' + - 'docs/**' push: branches: [master] paths-ignore: - - 'docs/**' + - 'docs/**' jobs: all_github_action_checks: @@ -28,7 +28,6 @@ jobs: run: | source ci/rust-version.sh echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV - - uses: actions-rs/toolchain@v1 with: toolchain: ${{ env.RUST_STABLE }} @@ -51,7 +50,6 @@ jobs: run: | source ci/rust-version.sh echo "RUST_NIGHTLY=$rust_nightly" >> $GITHUB_ENV - - uses: actions-rs/toolchain@v1 with: toolchain: ${{ env.RUST_NIGHTLY }} @@ -68,7 +66,6 @@ jobs: key: cargo-clippy-${{ hashFiles('**/Cargo.lock') }} restore-keys: | cargo-clippy- - - name: Install dependencies run: ./ci/install-build-deps.sh @@ -89,7 +86,6 @@ jobs: echo "RUST_STABLE=$rust_stable" >> $GITHUB_ENV source ci/solana-version.sh echo "SOLANA_VERSION=$solana_version" >> $GITHUB_ENV - - uses: actions-rs/toolchain@v1 with: toolchain: ${{ env.RUST_STABLE }} @@ -121,14 +117,5 @@ jobs: ./ci/install-build-deps.sh ./ci/install-program-deps.sh echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH - - name: Build and test - run: | - cargo test-bpf - - - name: Upload programs - uses: actions/upload-artifact@v2 - with: - name: programs - path: "target/deploy/*.so" - if-no-files-found: error \ No newline at end of file + run: ./ci/cargo-build-test.sh diff --git a/ci/cargo-build-test.sh b/ci/cargo-build-test.sh index d341ff2..ecddb4f 100755 --- a/ci/cargo-build-test.sh +++ b/ci/cargo-build-test.sh @@ -11,31 +11,15 @@ export RUSTBACKTRACE=1 set -x -# Build all C examples -make -C examples/c - -# Build/test all BPF programs -cargo +"$rust_stable" test-bpf -- --nocapture -rm -rf target/debug # Prevents running out of space on github action runners # Build/test all host crates cargo +"$rust_stable" build cargo +"$rust_stable" test -- --nocapture -# Run test-client sanity check -cargo +"$rust_stable" run --manifest-path=utils/test-client/Cargo.toml - # client_ristretto isn't in the workspace, test it explictly # client_ristretto disabled because it requires RpcBanksService, which is no longer supported. #cargo +"$rust_stable" test --manifest-path=themis/client_ristretto/Cargo.toml -- --nocapture -SWAP_PROGRAM_OWNER_FEE_ADDRESS="HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN" \ - cargo +"$rust_stable" build-bpf \ - --manifest-path=token-swap/program/Cargo.toml \ - --features production \ - --bpf-out-dir target/deploy-production -mv target/deploy-production/spl_token_swap.so target/deploy/spl_token_swap_production.so - # # Check generated C headers # cargo run --manifest-path=utils/cgen/Cargo.toml # @@ -44,4 +28,4 @@ mv target/deploy-production/spl_token_swap.so target/deploy/spl_token_swap_produ # git diff --exit-code token-swap/program/inc/token-swap.h # cc token-swap/program/inc/token-swap.h -o target/token-swap.gch -exit 0 +exit 0 \ No newline at end of file diff --git a/ci/cargo-test-sbf.sh b/ci/cargo-test-sbf.sh new file mode 100755 index 0000000..fcd1b4e --- /dev/null +++ b/ci/cargo-test-sbf.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -e +cd "$(dirname "$0")/.." + +source ./ci/rust-version.sh stable +source ./ci/solana-version.sh + +export RUSTFLAGS="-D warnings" +export RUSTBACKTRACE=1 + +usage() { + exitcode=0 + if [[ -n "$1" ]]; then + exitcode=1 + echo "Error: $*" + fi + echo "Usage: $0 [program-directory]" + exit $exitcode +} + +program_directory=$1 +if [[ -z $program_directory ]]; then + usage "No program directory provided" +fi + +cd $program_directory +run_dir=$(pwd) + +if [[ -r $run_dir/Cargo.toml ]]; then + # Build/test just one BPF program + set -x + cd $run_dir + cargo +"$rust_stable" test-sbf -- --nocapture + exit 0 +fi + +run_all=1 +for program in $run_dir/program{,-*}; do + # Build/test all program directories + if [[ -r $program/Cargo.toml ]]; then + run_all= + ( + set -x + cd $program + cargo +"$rust_stable" test-sbf -- --nocapture + ) + fi +done + +if [[ -n $run_all ]]; then + # Build/test all directories + set -x + for directory in $(ls -d $run_dir/*/); do + cd $directory + cargo +"$rust_stable" test-sbf -- --nocapture + done +fi \ No newline at end of file diff --git a/token-lending/program/tests/update_reserve.rs b/token-lending/program/tests/update_reserve.rs index c0455f7..1ae72ce 100644 --- a/token-lending/program/tests/update_reserve.rs +++ b/token-lending/program/tests/update_reserve.rs @@ -61,6 +61,8 @@ async fn test_update_reserve() { host_fee_percentage: 15, }, deposit_staking_pool: COption::None, + deposit_limit: 2147483647u64, + borrow_limit: 2147483647u64, }; let before_test_reserve = usdc_test_reserve.get_state(&mut banks_client).await; assert_ne!(before_test_reserve.config, new_config);