Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ updates:
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
open-pull-requests-limit: 10
84 changes: 42 additions & 42 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -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
127 changes: 63 additions & 64 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions .github/workflows/upgrade-flakes.yaml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 20 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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).
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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`)
Expand All @@ -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?

Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/util/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<String>>,
Expand Down
2 changes: 1 addition & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down