diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a7b0ae1..65dedd3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,4 +4,4 @@ updates: directory: "/" schedule: interval: daily - open-pull-requests-limit: 10 \ No newline at end of file + open-pull-requests-limit: 10 diff --git a/.github/settings.yml b/.github/settings.yml index 7411686..f155446 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -1,57 +1,57 @@ # https://github.com/probot/settings branches: - - name: master - protection: - enforce_admins: false - required_pull_request_reviews: - dismiss_stale_reviews: true - require_code_owner_reviews: true - required_approving_review_count: 1 - required_status_checks: - strict: true - restrictions: null - required_linear_history: true + - name: master + protection: + enforce_admins: false + required_pull_request_reviews: + dismiss_stale_reviews: true + require_code_owner_reviews: true + required_approving_review_count: 1 + required_status_checks: + strict: true + restrictions: null + required_linear_history: true labels: - - name: backward breaking change - color: ff0000 + - name: backward breaking change + color: ff0000 - - name: bug - color: ee0701 + - name: bug + color: ee0701 - - name: dependencies - color: 0366d6 + - name: dependencies + color: 0366d6 - - name: enhancement - color: 0e8a16 + - name: enhancement + color: 0e8a16 - - name: experimentation - color: eeeeee + - name: experimentation + color: eeeeee - - name: question - color: cc317c + - name: question + color: cc317c - - name: new feature - color: 0e8a16 + - name: new feature + color: 0e8a16 - - name: security - color: ee0701 + - name: security + color: ee0701 - - name: stale - color: eeeeee + - name: stale + color: eeeeee repository: - allow_merge_commit: true - allow_rebase_merge: true - allow_squash_merge: true - default_branch: main - description: "You shouldn't ever lose your work if you're using Git" - topics: git - has_downloads: true - has_issues: true - has_pages: false - has_projects: false - has_wiki: false - name: dura - private: false + allow_merge_commit: true + allow_rebase_merge: true + allow_squash_merge: true + default_branch: main + description: "You shouldn't ever lose your work if you're using Git" + topics: git + has_downloads: true + has_issues: true + has_pages: false + has_projects: false + has_wiki: false + name: dura + private: false diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bdd0240..a952dc5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,77 +1,76 @@ name: Build -on: [ workflow_call, workflow_dispatch, push, pull_request ] +on: [workflow_call, workflow_dispatch, push, pull_request] jobs: - build: - name: build - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - binary-suffix: linux-x86_64 - - os: macos-latest - binary-suffix: macos-x86_64 - - os: windows-latest - binary-suffix: windows-x86_64 - os: [ ubuntu-latest, macos-latest, windows-latest ] + build: + name: build + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + binary-suffix: linux-x86_64 + - os: macos-latest + binary-suffix: macos-x86_64 + - os: windows-latest + binary-suffix: windows-x86_64 + os: [ubuntu-latest, macos-latest, windows-latest] - steps: - - name: Check out source files - uses: actions/checkout@v3 - with: - fetch-depth: 1 + steps: + - name: Check out source files + uses: actions/checkout@v3 + with: + fetch-depth: 1 - - name: Update Toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: clippy + - name: Update Toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: clippy - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --all-features + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --release --all-features - - name: Rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --check + - name: Rustfmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --check - - name: Cargo Clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-targets --all-features -- -D warnings + - name: Cargo Clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-targets --all-features -- -D warnings - - name: Cargo Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --profile release + - name: Cargo Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --profile release - - name: Basic Testing - continue-on-error: true - if: ${{ matrix.os != 'windows-latest' }} - run: | - ${{ github.workspace }}/target/release/dura serve & - sleep 15s - ${{ github.workspace }}/target/release/dura kill + - name: Basic Testing + continue-on-error: true + if: ${{ matrix.os != 'windows-latest' }} + run: | + ${{ github.workspace }}/target/release/dura serve & + sleep 15s + ${{ github.workspace }}/target/release/dura kill - - name: Basic Testing (Windows) - continue-on-error: true - if: ${{ matrix.os == 'windows-latest' }} - run: | - Start-Process -NoNewWindow ${{ github.workspace }}\target\release\dura.exe serve - Start-Sleep -s 15 - ${{ github.workspace }}\target\release\dura.exe kill - - - name: Upload Binary - uses: actions/upload-artifact@v3 - with: - name: dura-${{ matrix.binary-suffix }}_${{ github.sha }} - path: ${{ github.workspace }}/target/release/dura + - name: Basic Testing (Windows) + continue-on-error: true + if: ${{ matrix.os == 'windows-latest' }} + run: | + Start-Process -NoNewWindow ${{ github.workspace }}\target\release\dura.exe serve + Start-Sleep -s 15 + ${{ github.workspace }}\target\release\dura.exe kill + - name: Upload Binary + uses: actions/upload-artifact@v3 + with: + name: dura-${{ matrix.binary-suffix }}_${{ github.sha }} + path: ${{ github.workspace }}/target/release/dura diff --git a/.github/workflows/upgrade-flakes.yaml b/.github/workflows/upgrade-flakes.yaml index ada8ce2..89fc4ca 100644 --- a/.github/workflows/upgrade-flakes.yaml +++ b/.github/workflows/upgrade-flakes.yaml @@ -1,9 +1,9 @@ -name: 'Update flake lock file' +name: "Update flake lock file" on: - schedule: - - cron: '0 0 * * 1' + schedule: + - cron: "0 0 * * 1" jobs: - createPullRequest: - uses: loophp/flake-lock-update-workflow/.github/workflows/upgrade-flakes.yaml@main + createPullRequest: + uses: loophp/flake-lock-update-workflow/.github/workflows/upgrade-flakes.yaml@main diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c109b39..712aa49 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,10 +1,11 @@ # Contributing to `dura` # Pull request process + 1. Discuss changes before starting. This helps avoid awkward situations, like where something has already been tried or isn't feasible for a non-obvious reason. 2. Add tests, if possible - * [`startup_test.rs`](https://github.com/tkellogg/dura/blob/master/tests/startup_test.rs) is a good place to test out new functionality, and the test code reads fairly well. - * Unit tests are preferred, when feasible. They go inside source files. + - [`startup_test.rs`](https://github.com/tkellogg/dura/blob/master/tests/startup_test.rs) is a good place to test out new functionality, and the test code reads fairly well. + - Unit tests are preferred, when feasible. They go inside source files. 3. Run `$ ./scripts/pre-commit.sh` before pushing. This does almost everything that happens in CI, just faster. 4. Explain the behavior as best as possible. Things like screenshots and GIFs can be helpful when it's visual. 5. Breathe deep. Smell the fresh clean air. @@ -13,30 +14,28 @@ We try to get to PRs within a day. We're usually quicker than that, but sometime Oh! And please be kind. We're all here because we want to help other people. Please remember that. - # Coding guidelines ## Printing output -* All `stdout` is routed through the logger and is JSON. -* Messages to the user should be on `stderr` and are plain text (e.g. can't take a lock) -* Use serialized structs to write JSON logs, so that the structure remains mostly backward compatible. Try not to rename fields, in case someone has written scripts against it. +- All `stdout` is routed through the logger and is JSON. +- Messages to the user should be on `stderr` and are plain text (e.g. can't take a lock) +- Use serialized structs to write JSON logs, so that the structure remains mostly backward compatible. Try not to rename fields, in case someone has written scripts against it. ## Unit tests vs Integration tests -For the purposes of this project, "integration tests" use the filesystem. The [official Rust recommendation](https://doc.rust-lang.org/book/ch11-03-test-organization.html) -is: - -* **Unit tests** go inline inside source files, in a `#[cfg(test)]` module. Structure your code so that - you can use these to test private functions without using the external dependencies like the - filesystem. -* **Integration tests** go "externally", in the `/tests` folder. Use the utilities in `tests/util` to - work with external dependencies easier. - * `git_repo` — makes it easy to work with Git repositories in a temp directory. It does it in a way - that tests can continue to run in parallel without interfering with each other. - * `dura` — makes it easy to call the real `dura` executable in a sub-process. This makes it - possible to run tests in parallel by setting environment varibales only for the sub-process - (e.g. `$DURA_HOME`). It also uses the `util::daemon` module to facilitate working with `dura serve` - by allowing you to make a blocking call to `read_line` to wait the minimum amount of time for - an activity to happen (like startup or snapshots). +For the purposes of this project, "integration tests" use the filesystem. The [official Rust recommendation](https://doc.rust-lang.org/book/ch11-03-test-organization.html) +is: +- **Unit tests** go inline inside source files, in a `#[cfg(test)]` module. Structure your code so that + you can use these to test private functions without using the external dependencies like the + filesystem. +- **Integration tests** go "externally", in the `/tests` folder. Use the utilities in `tests/util` to + work with external dependencies easier. + - `git_repo` — makes it easy to work with Git repositories in a temp directory. It does it in a way + that tests can continue to run in parallel without interfering with each other. + - `dura` — makes it easy to call the real `dura` executable in a sub-process. This makes it + possible to run tests in parallel by setting environment variables only for the sub-process + (e.g. `$DURA_HOME`). It also uses the `util::daemon` module to facilitate working with `dura serve` + by allowing you to make a blocking call to `read_line` to wait the minimum amount of time for + an activity to happen (like startup or snapshots). diff --git a/README.md b/README.md index 902f9bc..35f39ef 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,6 @@ $ git log --all `dura` produces a branch for every real commit you make and makes commits to that branch without impacting your working copy. You keep using Git exactly as you did before. - Let `dura` know that it should stop running in the background with the `kill` command. ```bash @@ -116,8 +115,9 @@ nix develop github:tkellogg/dura ``` ### Cargo Install -1. Install Cargo -2. If you want run release version, type ```cargo install dura``` else type ```cargo install --git https://github.com/tkellogg/dura``` + +1. Install Cargo +2. If you want run release version, type `cargo install dura` else type `cargo install --git https://github.com/tkellogg/dura` ### By Source @@ -127,6 +127,7 @@ nix develop github:tkellogg/dura 4. Run `cargo install --path .` **Note:** If you receive a failure fetching the cargo dependencies try using the local [git client for cargo fetches](https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli). `CARGO_NET_GIT_FETCH_WITH_CLI=true cargo install --path .` ### Windows + 1. Download [rustup-init](https://www.rust-lang.org/tools/install) 2. Clone this repository (e.g., `git clone https://github.com/tkellogg/dura.git`) 3. Navigate to repository base directory (`cd dura`) @@ -146,9 +147,9 @@ runs less frequently than every 5 seconds (potentially a lot less frequently, if ### Does this work on my OS? -- Mac: yes -- Linux: probably -- Windows: yes +- Mac: yes +- Linux: probably +- Windows: yes ### Can I add sub commands and aliases? diff --git a/flake.nix b/flake.nix index 80658e2..e4fc2bb 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ dura = pkgs.rustPlatform.buildRustPackage { pname = "dura"; version = "${shortRev}"; - description = "A background process that saves uncommited changes on git"; + description = "A background process that saves uncommitted changes on git"; src = self; diff --git a/tests/util/daemon.rs b/tests/util/daemon.rs index bf6a91e..023b930 100644 --- a/tests/util/daemon.rs +++ b/tests/util/daemon.rs @@ -7,7 +7,7 @@ use std::time::Duration; /// Main-thread side of a process watcher. The process that's launched is exposed as messages /// (per-line) over a mpsc channel. This is intended to simplify, speed up, and generally make the -/// tests more reliable when they dispatch asynchronously to `dura serve`. However, nothing abot +/// tests more reliable when they dispatch asynchronously to `dura serve`. However, nothing about /// this is intended to be specific to dura. pub struct Daemon { mailbox: Receiver>, diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 3e6ec08..29960f7 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -1,4 +1,4 @@ -// Not every test module -- which are compiled at seperate binaries, use every function, causing dead_code to be emitted. +// Not every test module -- which are compiled at separate binaries, use every function, causing dead_code to be emitted. #![allow(dead_code)] pub mod daemon;