Skip to content

Commit

Permalink
Adding ci for tests in github actions
Browse files Browse the repository at this point in the history
Correcting Makefile issues and pulling AS
Correcting gas cost failing test expected values
  • Loading branch information
sacherjj committed Jan 10, 2025
1 parent 2178ad3 commit 0287609
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 170 deletions.
75 changes: 0 additions & 75 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -447,78 +447,3 @@ volumes:
trigger:
ref:
- refs/tags/v*

---
kind: pipeline
type: docker
name: nightly-testing

environment:
RUSTC_WRAPPER: '/root/.cargo/bin/cachepot'
CACHEPOT_BUCKET: 'drone-sccache'
CACHEPOT_S3_KEY_PREFIX: ci
CACHEPOT_REGION: 'us-east-2'
CARGO_INCREMENTAL: '0'

__buildenv: &buildenv
image: casperlabs/node-build-u1804
volumes:
- name: rustup
path: "/root/.rustup"
- name: cargo
path: "/root/.cargo"
- name: drone
path: "/drone"
environment:
AWS_ACCESS_KEY_ID:
from_secret: cachepot_aws_ak
AWS_SECRET_ACCESS_KEY:
from_secret: cachepot_aws_sk

steps:
- name: setup
<<: *buildenv
commands:
- make setup

- name: nctl-compile
<<: *buildenv
commands:
- bash -c ./ci/nctl_compile.sh

- name: nctl-nightly-tests
<<: *buildenv
environment:
AWS_ACCESS_KEY_ID:
from_secret: put-drone-aws-ak
AWS_SECRET_ACCESS_KEY:
from_secret: put-drone-aws-sk
commands:
- bash -c ./ci/nightly-test.sh

- name: notify
image: plugins/slack
settings:
webhook:
from_secret: slack_webhook_nightly
template:
- |
Nightly Test Run Status: *{{ uppercasefirst build.status }}*
Author: {{ build.author }}
Drone Build: <{{ build.link }}|#{{ build.number }}>
Commit Link: <https://github.com/{{repo.owner}}/{{repo.name}}/commit/{{build.commit}}|{{ truncate build.commit 10 }}>
when:
status:
- failure
- success

volumes:
- name: rustup
temp: {}
- name: cargo
temp: {}
- name: drone
temp: {}

trigger:
cron: [ nightly-tests-cron, feat-2-0 ]
50 changes: 50 additions & 0 deletions .github/workflows/casper-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: casper-node
permissions:
contents: read

on:
push:
branches:
- dev
- trying
- staging
- 'release-**'
- 'feat-**'
paths-ignore:
- '**.md'

pull_request:
branches:
- dev
- 'release-**'
- 'feat-**'
paths-ignore:
- '**.md'

jobs:
lints:
name: tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- uses: Swatinem/rust-cache@v2

- name: setup
run: make setup

- name: check-std-features
run: make check-std-features

- name: check-testing-features
run: make check-testing-features

- name: test
run: make test CARGO_FLAGS=--release

- name: test-contracts
run: make test-contracts CARGO_FLAGS=--release
41 changes: 4 additions & 37 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #tag v2.4.0
uses: actions/checkout@v4 #tag v2.4.0
with:
persist-credentials: false

- name: Get nightly toolchain from smart_contracts dir
id: nightly-toolchain
run: echo "::set-output name=version::$(cat smart_contracts/rust-toolchain)"
- uses: Swatinem/rust-cache@v2

- name: Get nightly toolchain for docs
id: nightly-toolchain-doc
run: echo "::set-output name=version::nightly-2024-01-01"

- name: Get stable from rust-toolchain.toml
id: stable-toolchain
run: echo "::set-output name=version::$(sed -nr 's/channel\s+=\s+\"(.*)\"/\1/p' rust-toolchain.toml)"

- name: Install Toolchain - Stable
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #tag v1.0.7
with:
profile: minimal
toolchain: ${{ steps.stable-toolchain.outputs.version }}
components: rustfmt, clippy
target: wasm32-unknown-unknown

- name: Install Toolchain - Nightly
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #tag v1.0.7
with:
profile: minimal
toolchain: ${{ steps.nightly-toolchain.outputs.version }}
components: rustfmt, clippy
target: wasm32-unknown-unknown

- name: Install Toolchain - Nightly for docs
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #tag v1.0.7
with:
profile: minimal
toolchain: ${{ steps.nightly-toolchain-doc.outputs.version }}
components: rustfmt, clippy
target: wasm32-unknown-unknown

- uses: Swatinem/rust-cache@v1
- name: setup
run: make setup

- name: fmt
run: make check-format
Expand Down
66 changes: 9 additions & 57 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This supports environments where $HOME/.cargo/env has not been sourced (CI, CLion Makefile runner)
CARGO = $(or $(shell which cargo), $(HOME)/.cargo/bin/cargo)
RUSTUP = $(or $(shell which rustup), $(HOME)/.cargo/bin/rustup)
NPM = $(or $(shell which npm), /usr/bin/npm)

PINNED_NIGHTLY := $(shell cat smart_contracts/rust-toolchain)
PINNED_STABLE := $(shell sed -nr 's/channel *= *\"(.*)\"/\1/p' rust-toolchain.toml)
Expand All @@ -19,15 +18,6 @@ CLIENT_CONTRACTS = $(shell find ./smart_contracts/contracts/client -mindepth 1 -
CARGO_HOME_REMAP = $(if $(CARGO_HOME),$(CARGO_HOME),$(HOME)/.cargo)
RUSTC_FLAGS = "--remap-path-prefix=$(CARGO_HOME_REMAP)=/home/cargo --remap-path-prefix=$$PWD=/dir"

# AssemblyScript Contracts
CLIENT_CONTRACTS_AS = $(shell find ./smart_contracts/contracts_as/client -mindepth 1 -maxdepth 1 -type d)
TEST_CONTRACTS_AS = $(shell find ./smart_contracts/contracts_as/test -mindepth 1 -maxdepth 1 -type d)
EXAMPLE_CONTRACTS_AS = $(shell find ./smart_contracts/contracts_as/example -mindepth 1 -maxdepth 1 -type d)

CLIENT_CONTRACTS_AS := $(patsubst %, build-contract-as/%, $(CLIENT_CONTRACTS_AS))
TEST_CONTRACTS_AS := $(patsubst %, build-contract-as/%, $(TEST_CONTRACTS_AS))
EXAMPLE_CONTRACTS_AS := $(patsubst %, build-contract-as/%, $(EXAMPLE_CONTRACTS_AS))

CONTRACT_TARGET_DIR = target/wasm32-unknown-unknown/release
CONTRACT_TARGET_DIR_AS = target_as

Expand Down Expand Up @@ -55,17 +45,8 @@ build-contracts-rs: build-all-contracts-rs strip-all-contracts
.PHONY: build-client-contracts
build-client-contracts: build-client-contracts-rs strip-client-contracts

build-contract-as/%:
cd $* && $(NPM) run asbuild

.PHONY: build-contracts-as
build-contracts-as: \
$(CLIENT_CONTRACTS_AS) \
$(TEST_CONTRACTS_AS) \
$(EXAMPLE_CONTRACTS_AS)

.PHONY: build-contracts
build-contracts: build-contracts-rs build-contracts-as
build-contracts: build-contracts-rs

resources/local/chainspec.toml: generate-chainspec.sh resources/local/chainspec.toml.in
@./$<
Expand All @@ -78,12 +59,8 @@ test-rs: resources/local/chainspec.toml build-contracts-rs
test-rs-no-default-features:
cd smart_contracts/contract && $(DISABLE_LOGGING) $(CARGO) test $(CARGO_FLAGS) --no-default-features --features=version-sync

.PHONY: test-as
test-as: setup-as
cd smart_contracts/contract_as && npm run asbuild && npm run test

.PHONY: test
test: test-rs-no-default-features test-rs test-as
test: test-rs-no-default-features test-rs

.PHONY: test-contracts-rs
test-contracts-rs: build-contracts-rs
Expand All @@ -93,11 +70,6 @@ test-contracts-rs: build-contracts-rs
test-contracts-timings: build-contracts-rs
$(DISABLE_LOGGING) $(CARGO) test --release $(filter-out --release, $(CARGO_FLAGS)) -p casper-engine-tests -- --ignored --test-threads=1 repeated_ffi_call_should_gas_out_quickly

.PHONY: test-contracts-as
test-contracts-as: build-contracts-rs build-contracts-as
@# see https://github.com/rust-lang/cargo/issues/5015#issuecomment-515544290
$(DISABLE_LOGGING) $(CARGO) test $(CARGO_FLAGS) --manifest-path "execution_engine_testing/tests/Cargo.toml" --features "use-as-wasm" -- --ignored

.PHONY: test-contracts
test-contracts: test-contracts-rs

Expand Down Expand Up @@ -154,11 +126,6 @@ lint-smart-contracts:
audit-rs:
$(CARGO) audit

.PHONY: audit-as
audit-as:
@# Runs a vulnerability scan that fails if there are prod vulnerabilities with a moderate level or above.
cd smart_contracts/contract_as && $(NPM) audit --production --audit-level=moderate

.PHONY: audit
audit: audit-rs

Expand All @@ -168,7 +135,7 @@ doc:
cd smart_contracts/contract && RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--cfg docsrs" $(CARGO_PINNED_NIGHTLY) doc --all-features $(CARGO_FLAGS) --no-deps

.PHONY: check-rs
check-rs: \
check: \
check-format \
doc \
lint \
Expand All @@ -181,15 +148,9 @@ check-rs: \
test-rs-no-default-features \
test-contracts-rs

.PHONY: check
check: \
check-rs \
test-as

.PHONY: clean
clean:
rm -rf resources/local/chainspec.toml
rm -rf $(CONTRACT_TARGET_DIR_AS)
$(CARGO) clean

.PHONY: build-for-packaging
Expand All @@ -210,29 +171,20 @@ bench: build-contracts-rs

.PHONY: setup-cargo-packagers
setup-cargo-packagers:
$(CARGO) install cargo-rpm || exit 0
$(CARGO) install cargo-deb || exit 0

.PHONY: setup-audit
setup-audit:
cargo install cargo-audit

.PHONY: setup-rs
setup-rs: smart_contracts/rust-toolchain
setup: smart_contracts/rust-toolchain
$(RUSTUP) update
$(RUSTUP) toolchain install $(PINNED_STABLE) $(PINNED_NIGHTLY) $(NIGHTLY_FOR_DOC)
$(RUSTUP) toolchain install $(PINNED_STABLE) $(PINNED_NIGHTLY)
$(RUSTUP) target add --toolchain $(PINNED_STABLE) wasm32-unknown-unknown
$(RUSTUP) target add --toolchain $(PINNED_NIGHTLY) wasm32-unknown-unknown
$(RUSTUP) component add --toolchain $(PINNED_NIGHTLY) rustfmt clippy-preview
$(CARGO) install cargo-audit


.PHONY: setup-nightly-rs
setup-nightly-rs:
$(RUSTUP) update
$(RUSTUP) toolchain install nightly
$(RUSTUP) target add --toolchain nightly wasm32-unknown-unknown

.PHONY: setup-as
setup-as: smart_contracts/contract_as/package.json
cd smart_contracts/contract_as && $(NPM) ci

.PHONY: setup
setup: setup-rs
$(RUSTUP) t add --toolchain nightly wasm32-unknown-unknown
1 change: 0 additions & 1 deletion utils/global-state-update-gen/src/generic/state_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ impl<T: StateReader> StateTracker<T> {

/// Sets the bid for the given account.
pub fn set_bid(&mut self, bid_kind: BidKind, slash_instead_of_unbonding: bool) {
println!("set bid");
// skip bridge records since they shouldn't need to be overwritten
if let BidKind::Bridge(_) = bid_kind {
return;
Expand Down

0 comments on commit 0287609

Please sign in to comment.