From 999229aaa1488c678ac8a70b23aa85e354325f38 Mon Sep 17 00:00:00 2001 From: edsonalcala Date: Fri, 6 Sep 2024 13:56:46 +0100 Subject: [PATCH] fix: added github workflow and update pr template --- .github/PULL_REQUEST_TEMPLATE.md | 32 +++++--- .github/actions/install-just/action.yml | 21 ++++++ .github/actions/setup-rust/action.yml | 12 +++ .github/workflows/release.yml | 87 ---------------------- .github/workflows/test.yml | 63 +++++++--------- .github/CONTRIBUTING.md => CONTRIBUTING.md | 0 justfile | 3 + 7 files changed, 86 insertions(+), 132 deletions(-) create mode 100644 .github/actions/install-just/action.yml create mode 100644 .github/actions/setup-rust/action.yml delete mode 100644 .github/workflows/release.yml rename .github/CONTRIBUTING.md => CONTRIBUTING.md (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e2cefa7..f89f3b1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,16 +2,13 @@ Thank you for your Pull Request. Please provide a description above and review the requirements below. -Bug fixes and new features should include tests. +Bug fixes and new examples should include tests. -Contributors guide: https://github.com/alloy-rs/examples/blob/main/CONTRIBUTING.md +Contributors guide: https://github.com/Omni-rs/examples/blob/main/CONTRIBUTING.md -The contributors guide includes instructions for running rustfmt and building the -documentation. +The contributors guide includes instructions for running and building the documentation. --> - - ## Motivation -## PR Checklist +## Notes to reviewers + + + +## How has it been tested? + + + +## Checklist -- [ ] Added Documentation -- [ ] Breaking changes \ No newline at end of file +- [ ] Does the example follow the contributing guidelines? +- [ ] Does the example have a README.md? +- [ ] Does the example have tests? +- [ ] Updated README.md +- [ ] Does the Github workflow pass? \ No newline at end of file diff --git a/.github/actions/install-just/action.yml b/.github/actions/install-just/action.yml new file mode 100644 index 0000000..e5f3dd6 --- /dev/null +++ b/.github/actions/install-just/action.yml @@ -0,0 +1,21 @@ +name: 'Install Just' +description: 'Installs Just command runner with caching' +runs: + using: "composite" + steps: + - name: Cache Just + uses: actions/cache@v4 + id: cache-just + with: + path: ~/.cargo/bin/just + key: ${{ runner.os }}-just-${{ hashFiles('**/justfile') }} + + - name: Install Just + if: steps.cache-just.outputs.cache-hit != 'true' + uses: taiki-e/install-action@v2 + with: + tool: just + + - name: Verify Just Installation + run: just --version + shell: bash diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 0000000..1d9c93a --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -0,0 +1,12 @@ +name: "Setup Rust Environment" +description: "Setup Rust environment with caching" +runs: + using: "composite" + steps: + - name: "${{ matrix.toolchain }}" + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.toolchain }} + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 47ae18d..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,87 +0,0 @@ -name: Test & Release - -permissions: - pull-requests: write - contents: write - -on: - push: - branches: [ main ] - pull_request: - -env: - CARGO_TERM_COLOR: always - RUSTFLAGS: '-D warnings' - CARGO_INCREMENTAL: 0 - RUST_BACKTRACE: short - -jobs: - clippy: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Run clippy - run: cargo clippy --all-targets -- -D clippy::all -D clippy::nursery - - cargo-fmt: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: Run cargo fmt - run: cargo fmt --check - - # there're sometimes warnings, which signal, that the generated doc - # won't look as expected, when rendered, and sometimes errors, which will prevent doc from being - # generated at release time altogether. - cargo-doc: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - - name: run cargo doc - run: RUSTDOCFLAGS="-D warnings" cargo doc - - test: - needs: cargo-fmt - strategy: - matrix: - platform: [ubuntu-latest, macos-latest] - toolchain: [stable] - runs-on: ${{ matrix.platform }} - - steps: - - uses: actions/checkout@v2 - - name: "${{ matrix.toolchain }}" - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.toolchain }} - default: true - - uses: Swatinem/rust-cache@v1 - - name: Add wasm32 target - run: rustup target add wasm32-unknown-unknown - - name: Check with stable features - run: cargo check --verbose - - name: Run tests with unstable features - run: NEAR_RPC_TIMEOUT_SECS=100 cargo test --verbose --features unstable - - release-plz: - runs-on: ubuntu-latest - needs: [clippy, cargo-fmt, cargo-doc, test] - if: github.ref == 'refs/heads/main' - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.MY_GITHUB_TOKEN }} - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - - name: Run release-plz - uses: MarcoIeni/release-plz-action@v0.5 - env: - # https://release-plz.ieni.dev/docs/github/trigger - GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85b0336..e2df016 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,51 +11,42 @@ env: jobs: clippy: runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Run clippy - run: cargo clippy --all-targets -- -D clippy::all -D clippy::nursery + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-just + - run: just lint cargo-fmt: runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v4 - - name: Run cargo fmt - run: cargo fmt --check - - # there're sometimes warnings, which signal, that the generated doc - # won't look as expected, when rendered, and sometimes errors, which will prevent doc from being - # generated at release time altogether. - cargo-doc: - runs-on: ubuntu-20.04 - + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-just + - run: just fmt + + build: + needs: [clippy, cargo-fmt] + strategy: + matrix: + platform: [ubuntu-latest, macos-latest] + toolchain: [stable, nightly] + runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v4 - - name: run cargo doc - run: RUSTDOCFLAGS="-D warnings" cargo doc + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-just + - uses: ./.github/actions/setup-rust + - run: just check - test: - needs: cargo-fmt + tests: + needs: [build] strategy: matrix: platform: [ubuntu-latest, macos-latest] - toolchain: [stable] + toolchain: [stable, nightly] runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - name: "${{ matrix.toolchain }}" - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.toolchain }} - default: true - - uses: Swatinem/rust-cache@v1 - - name: Add wasm32 target - run: rustup target add wasm32-unknown-unknown - - name: Check with stable features - run: cargo check --verbose - - name: Run tests with unstable features - run: NEAR_RPC_TIMEOUT_SECS=100 cargo test --verbose --features unstable \ No newline at end of file + - uses: actions/checkout@v4 + - uses: ./.github/actions/install-just + - uses: ./.github/actions/setup-rust + - uses: foundry-rs/foundry-toolchain@v1 + - name: Run all tests + run: just test-all \ No newline at end of file diff --git a/.github/CONTRIBUTING.md b/CONTRIBUTING.md similarity index 100% rename from .github/CONTRIBUTING.md rename to CONTRIBUTING.md diff --git a/justfile b/justfile index 5874cf7..df5a531 100644 --- a/justfile +++ b/justfile @@ -17,3 +17,6 @@ check-wasm: # Run example run PROJECT: cargo test -p {{PROJECT}} -- --nocapture + +test-all: + cargo test --workspace -- --nocapture \ No newline at end of file