diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml new file mode 100644 index 00000000..9fb4db65 --- /dev/null +++ b/.github/workflows/audit.yml @@ -0,0 +1,26 @@ +name: Audit + +on: + schedule: + - cron: '0 0 * * *' + push: + branches: + - master + paths: + - "**/Cargo.lock" + - "**/Cargo.toml" + pull_request: + branches: + - master + paths: + - "**/Cargo.lock" + - "**/Cargo.toml" + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..49951ea4 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,77 @@ +name: Build and run tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build-and-test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + project: [./, ./riker-macros/] + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Get current date + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - name: Get current date + if: matrix.os == 'windows-latest' + run: echo "CURRENT_DATE=$(Get-Date -Format "yyyy-MM-dd")" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 + + - name: Cache cargo registry + uses: actions/cache@v2 + with: + path: ~/.cargo/registry + # Add date to the cache to keep it up to date + key: ${{ matrix.project }}-${{ matrix.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + # Restore from outdated cache for speed + restore-keys: | + ${{ matrix.project }}-${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }} + + - name: Cache cargo index + uses: actions/cache@v2 + with: + path: ~/.cargo/git + # Add date to the cache to keep it up to date + key: ${{ matrix.project }}-${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + # Restore from outdated cache for speed + restore-keys: | + ${{ matrix.project }}-${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }} + + - name: Cache cargo target + uses: actions/cache@v2 + with: + path: ${{ matrix.project}}/target + # Add date to the cache to keep it up to date + key: ${{ matrix.project }}-${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + # Restore from outdated cache for speed + restore-keys: | + ${{ matrix.project }}-${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }} + + - name: Build ${{ matrix.project }} + uses: actions-rs/cargo@v1 + with: + command: build + args: --manifest-path=${{ matrix.project }}Cargo.toml --all --release + + - name: Run tests for ${{ matrix.project }} + uses: actions-rs/cargo@v1 + with: + command: test + args: --manifest-path=${{ matrix.project }}Cargo.toml --all --release diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..17361103 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,28 @@ +name: pre-commit + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + pre-commit: + runs-on: ubuntu-latest + strategy: + max-parallel: 1 + matrix: + rust: + - stable + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + components: clippy, rustfmt + - uses: pre-commit/action@v2.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 438323fa..4b73625b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,16 +7,17 @@ repos: language: system entry: sh -c 'touch src/lib.rs' - repo: https://github.com/doublify/pre-commit-rust - rev: 14b3e118cfc36fb87d8d9cbd1305a2238fd85868 + rev: v1.0 hooks: - id: clippy + args: ["--all-targets", "--all-features", "--", "-D", "warnings"] name: cargo clippy https://github.com/rust-lang/rust-clippy/blob/master/README.md . - id: cargo-check name: cargo check https://doc.rust-lang.org/cargo/commands/cargo-check.html . - id: fmt name: rustfmt https://github.com/rust-lang/rustfmt/blob/master/README.md . - - repo: https://github.com/prettier/prettier.git - rev: 2.1.1 + - repo: https://github.com/pre-commit/mirrors-prettier.git + rev: v2.2.0 hooks: - id: prettier name: prettier https://prettier.io/docs/en/ . diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 09139cc3..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -# verified on https://config.travis-ci.com/explore -language: rust -os: linux -dist: xenial -jobs: - fast_finish: true - include: - - rust: stable - script: - - cargo update - - cargo check --all --no-default-features - - cargo test --all-features --all -- --nocapture - - cd riker-macros; cargo test --no-default-features -- --nocapture; cd .. - - name: "pre-commit" - before_install: - - curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - - - sudo apt-get update - - sudo apt-get install -y nodejs - - sudo pip install --upgrade pip - - pip install pre-commit --user - - rustup component add rustfmt --toolchain stable-x86_64-unknown-linux-gnu - - rustup component add clippy --toolchain stable-x86_64-unknown-linux-gnu - script: - - pre-commit run -a diff --git a/README.md b/README.md index 095ff3c4..2b04e1c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Riker -[![Build Status](https://travis-ci.org/riker-rs/riker.svg?branch=master)](https://travis-ci.org/riker-rs/riker) +[![Build status](https://github.com/riker-rs/riker/workflows/Build%20and%20run%20tests/badge.svg)](https://github.com/riker-rs/riker/actions?query=workflow%3A%22Build+and+run+tests%22) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) [![crates.io](https://meritbadge.herokuapp.com/riker)](https://crates.io/crates/riker) [![Released API docs](https://docs.rs/riker/badge.svg)](https://docs.rs/riker) diff --git a/examples/channel.rs b/examples/channel.rs index 4b12ddfc..874486f5 100644 --- a/examples/channel.rs +++ b/examples/channel.rs @@ -26,13 +26,7 @@ impl Actor for GpsActor { println!("{}: pre_start subscribe to {:?}", ctx.myself.name(), topic); let sub = Box::new(ctx.myself()); - self.chan.tell( - Subscribe { - actor: sub.clone(), - topic, - }, - None, - ); + self.chan.tell(Subscribe { actor: sub, topic }, None); } fn recv(&mut self, ctx: &Context, msg: Self::Msg, sender: Sender) { @@ -67,13 +61,7 @@ impl Actor for NavigationActor { println!("{}: pre_start subscribe to {:?}", ctx.myself.name(), topic); let sub = Box::new(ctx.myself()); - self.chan.tell( - Subscribe { - actor: sub.clone(), - topic, - }, - None, - ); + self.chan.tell(Subscribe { actor: sub, topic }, None); } fn recv(&mut self, ctx: &Context, msg: Self::Msg, sender: Sender) { diff --git a/src/lib.rs b/src/lib.rs index 413c3cab..22cbd6f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,8 @@ // #![deny(clippy::nursery)] #![allow(clippy::new_ret_no_self)] #![allow(clippy::large_enum_variant)] +#![allow(clippy::rc_buffer)] +#![allow(clippy::to_string_in_display)] mod validate;