Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cargo test keeps failing on github actions but passes on local machine

Unit-tests are giving this error:

/home/runner/.cargo/bin/cargo unit-test --locked
    Updating crates.io index
    Updating git repository `https://github.com/enigmampc/SecretNetwork`
    Updating git repository `https://github.com/Haseeb30000/secret-toolkit`
 Downloading crates ...
  Downloaded rand_chacha v0.2.2
.....
.....
  Downloaded rust_decimal v1.25.0
error: failed to parse manifest at `/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_decimal-1.25.0/Cargo.toml`
Error: failed to parse manifest at `/home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_decimal-1.25.0/Cargo.toml`
Caused by:
  failed to parse the `edition` key
Caused by:
  this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.
Error: The process '/home/runner/.cargo/bin/cargo' failed with exit code 101

I keep changed the version of rust_decimal to v-1.25.0 but it still gives error.
Here’s cargo.toml

[package]

name = "pool_party"
version = "0.1.0"
edition = "2018"

exclude = [
  # Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
  "contract.wasm",
  "hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
# for quicker tests, cargo test --lib
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-std = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.0", features = ["staking"] }
cosmwasm-storage = { git = "https://github.com/enigmampc/SecretNetwork", tag = "v1.0.0" }
secret-toolkit = { git = "https://github.com/Haseeb30000/secret-toolkit",  branch = "master" }


schemars = "0.7"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
serde_json = "1.0.1"
snafu = { version = "0.6.3" }
bincode2 = "2.0.1"
subtle = { version = "2.2.3", default-features = false }
base64 = "0.12.3"
hex = "0.4.2"
rust_decimal = { version = "1.25.0", default-features = false}

rand_chacha = { version = "0.2.2", default-features = false }
#rand_core = { version =  "0.5.1", default-features = false }
rand = { version = "0.7.3" }
sha2 = { version = "0.9.1", default-features = false }

[dev-dependencies]
cosmwasm-schema = { version = "0.10.0" }

All cargo build and cargo unit-test works just fine.
cargo test passes on my local macbook pro (M1) but fails on github actions with the error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here the .yaml

# Based on https://github.com/actions-rs/example/blob/master/.github/workflows/quickstart.yml

on: [push, pull_request]

name: Basic

jobs:

  test:
    name: Test Suite
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: 1.46.0
          target: wasm32-unknown-unknown
          override: true

      - name: Run unit tests
        uses: actions-rs/cargo@v1
        with:
          command: unit-test
          args: --locked
        env:
          RUST_BACKTRACE: 1

      - name: Compile WASM contract
        uses: actions-rs/cargo@v1
        with:
          command: wasm
          args: --locked
        env:
          RUSTFLAGS: "-C link-arg=-s"

      - name: Run integration tests
        uses: actions-rs/cargo@v1
        with:
          command: integration-test
          args: --locked


  lints:
    name: Lints
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: 1.46.0
          override: true
          components: rustfmt, clippy

      - name: Run cargo fmt
        uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - name: Run cargo clippy
        uses: actions-rs/cargo@v1
        with:
          command: clippy
          args: -- -D warnings

      # TODO: we should check
      # CHANGES_IN_REPO=$(git status --porcelain)
      # after this, but I don't know how
      - name: Generate Schema
        uses: actions-rs/cargo@v1
        with:
          command: schema
          args: --locked

The cargo test is failing with a failed with exit code 101. I have changed from rust_decimal=1.17.0 to rust_decimal=1.25.0 but it still fails

>Solution :

You’re using too old version on CI (1.46.0). Update it to use more recent version that supports the 2021 edition:

jobs:

  test:
    name: Test Suite
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: 1.62.0
          target: wasm32-unknown-unknown
          override: true

...

  lints:
    name: Lints
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v2

      - name: Install stable toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: 1.62.0
          override: true
          components: rustfmt, clippy
...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading