From f1061ae8bea3073ad9e382601357c12eb4277ac4 Mon Sep 17 00:00:00 2001 From: Elmer Bulthuis Date: Thu, 21 Sep 2023 10:53:53 +0200 Subject: [PATCH] polishing up (#14) --- .circleci/config.yml | 50 ---------------------------- .editorconfig | 9 +++++ .github/workflows/publish.yml | 18 ++++++++++ .github/workflows/test.yml | 40 ++++++++++++++++++++++ .gitignore | 13 ++++++-- .idea/.gitignore | 3 -- .idea/codeStyles/codeStyleConfig.xml | 5 --- .idea/modules.xml | 8 ----- .idea/reduxr.iml | 15 --------- .idea/vcs.xml | 6 ---- .vscode/extensions.json | 17 +++++----- .vscode/settings.json | 17 +++++----- Cargo.lock | 7 ++++ README.md | 9 +---- cspell.json | 11 ++++++ pre-commit | 5 --- src/store.rs | 2 +- 17 files changed, 114 insertions(+), 121 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .editorconfig create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .idea/.gitignore delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/reduxr.iml delete mode 100644 .idea/vcs.xml create mode 100644 Cargo.lock create mode 100644 cspell.json delete mode 100755 pre-commit diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9b8b95a..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,50 +0,0 @@ -version: 2.1 - -executors: - rust: - docker: - - image: circleci/rust:1.37 - -jobs: - clippy: - executor: rust - steps: - - run: rustup component add clippy - - checkout - - run: cargo clippy --all-targets - - test: - executor: rust - steps: - - checkout - - run: cargo test --all-targets - - run: cargo test --doc - - publish: - executor: rust - steps: - - checkout - - run: sed -i 's/^version\s*=.*$/version = "'$(echo $CIRCLE_TAG | sed -nre 's/^v(.*)$/\1/p')'"/' Cargo.toml - - run: cargo publish --allow-dirty - -workflows: - version: 2 - main: - jobs: - - clippy: - filters: - tags: - only: /.*/ - - test: - filters: - tags: - only: /.*/ - - publish: - context: cargo-publish - requires: [clippy, test] - filters: - branches: - ignore: /.*/ - tags: - # v1.0.0 - only: /^v\d+\.\d+\.\d+$/ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b2bf576 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +insert_final_newline = true +end_of_line = lf +indent_style = space +indent_size = 4 +max_line_length = 100 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..69de1ae --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,18 @@ +on: + push: + tags: + - v* + +jobs: + + publish-crates: + runs-on: ubuntu-latest + container: rust:1.64-alpine3.15 + env: + CARGO_HOME: ${{ github.workspace }}/.cargo + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + steps: + - uses: actions/checkout@v3 + - run: apk add cargo-edit + - run: cargo set-version ${GITHUB_REF_NAME:1} + - run: cargo publish --allow-dirty diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6233dac --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +on: + - push + - pull_request + +jobs: + + test-unit: + runs-on: ubuntu-latest + container: rust:1.64-alpine3.15 + env: + CARGO_HOME: ${{ github.workspace }}/.cargo + steps: + - uses: actions/checkout@v3 + - run: apk add tar + - uses: actions/cache@v3 + with: + key: ${{ github.job }}-${{ hashFiles('Cargo.lock') }} + path: | + .cargo/ + target/ + - run: apk add build-base + - run: cargo test --all-targets + + test-lint: + runs-on: ubuntu-latest + container: rust:1.64-alpine3.15 + env: + CARGO_HOME: ${{ github.workspace }}/.cargo + steps: + - uses: actions/checkout@v3 + - run: apk add tar + - uses: actions/cache@v3 + with: + key: ${{ github.job }}-${{ hashFiles('Cargo.lock') }} + path: | + .cargo/ + target/ + - run: apk add musl-dev + - run: rustup component add clippy + - run: cargo clippy --all-targets diff --git a/.gitignore b/.gitignore index 6936990..ad76827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ -/target -**/*.rs.bk -Cargo.lock +.* + +!.gitignore +!.editorconfig + +/target/ +/coverage/ + +!/.vscode/ +!/.github/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 0e40fe8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index a8f7367..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/reduxr.iml b/.idea/reduxr.iml deleted file mode 100644 index f270a33..0000000 --- a/.idea/reduxr.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2fe3c0d..f77b5f8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,14 +1,15 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - // List of extensions which should be recommended for users of this workspace. "recommendations": [ - "rust-lang.rust", - "vadimcn.vscode-lldb" + "rust-lang.rust-analyzer", + "vadimcn.vscode-lldb", + "ryanluker.vscode-coverage-gutters", + "editorconfig.editorconfig", + "tamasfe.even-better-toml" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. - "unwantedRecommendations": [ - - ] -} \ No newline at end of file + "unwantedRecommendations": [] + } + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 10f450d..b82b936 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,9 @@ -// Place your settings in this file to overwrite default and user settings. { - "editor.formatOnSave": true, - "editor.rulers": [ - 100 - ], - "rust.clippy_preference": "on", - "rust.all_targets": true, - "rust-client.channel": "nightly" -} \ No newline at end of file + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll": true, + "source.organizeImports": true + }, + "editor.rulers": [100], + "rust-analyzer.check.command": "clippy" +} diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..74aa17b --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "reduxr" +version = "0.0.0" diff --git a/README.md b/README.md index 2a040cf..b8de866 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,3 @@ # ReduxR - Redux for rust -This repository provides a redux store, with some examples that show how to do redux in rust. - -## Automated tests -Never commit something that breaks the build! You can easily prevent this by linking the `pre-commit` script as a git `pre-commit` hook! -like this: -```bash -ln pre-commit .git/hooks/pre-commit -``` +This repository provides a redux store, with some examples that show how to do redux in rust. diff --git a/cspell.json b/cspell.json new file mode 100644 index 0000000..5ceaad7 --- /dev/null +++ b/cspell.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json", + "version": "0.2", + "language": "en", + "useGitignore": true, + "enableGlobDot": true, + "words": [ + "reduxr", + "todos" + ] +} diff --git a/pre-commit b/pre-commit deleted file mode 100755 index 8c2bfdd..0000000 --- a/pre-commit +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -cargo clippy --all-targets -cargo test --all-targets -cargo test --doc diff --git a/src/store.rs b/src/store.rs index ab1637d..4c55787 100644 --- a/src/store.rs +++ b/src/store.rs @@ -35,7 +35,7 @@ where self } - /// Dispatch action through the middleware and eventualle reduce state with it! + /// Dispatch action through the middleware and eventually reduce state with it! pub fn dispatch(&self, action: Action) { (self.dispatch_handler)(self, action); }