Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9d1b120

Browse files
committedJun 21, 2021
Add support for Windows and non-GNU Linux
1 parent 1acfeb5 commit 9d1b120

File tree

12 files changed

+478
-63
lines changed

12 files changed

+478
-63
lines changed
 

‎.github/ISSUE_TEMPLATE/bug_report.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ A clear description of what the bug is.
1313
**Instructions to reproduce the bug**
1414
A clear explanation of how to reproduce the bug.
1515

16-
**System information:**
17-
- OS: [e.g. macOS Mojave 10.14.5]
16+
**Environment information:**
1817
- Paxos version: [e.g. 0.0.0]
18+
- OS: [e.g. macOS Big Sur 11.4 (20F71)]
1919

2020
**Additional context**
2121
Add any other context about the problem here.

‎.github/workflows/ci.yml

+152-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,166 @@
11
name: Continuous integration
22
on: [push, pull_request]
3+
defaults:
4+
run:
5+
shell: bash
36
jobs:
4-
ci:
7+
ci-linux:
58
name: Build and test on Linux
69
runs-on: ubuntu-latest
710
steps:
811
- uses: actions/checkout@v2
9-
- uses: azure/docker-login@v1
12+
- if: ${{ github.event_name == 'push' }}
13+
uses: azure/docker-login@v1
1014
with:
1115
username: stephanmisc
1216
password: ${{ secrets.DOCKER_PASSWORD }}
13-
if: github.event_name == 'push'
1417
- uses: stepchowfun/toast/.github/actions/toast@main
1518
with:
16-
tasks: build check test lint run
19+
tasks: build test lint release run
1720
repo: stephanmisc/toast
1821
write_remote_cache: ${{ github.event_name == 'push' }}
22+
- run: |
23+
# Make Bash not silently ignore errors.
24+
set -euo pipefail
25+
26+
# The artifact name will contain the target triple, so the file name doesn't need to.
27+
mv artifacts/paxos-x86_64-unknown-linux-gnu artifacts/paxos
28+
- uses: actions/upload-artifact@v2
29+
with:
30+
name: x86_64-unknown-linux-gnu
31+
path: artifacts/paxos
32+
if-no-files-found: error
33+
- run: |
34+
# Make Bash not silently ignore errors.
35+
set -euo pipefail
36+
37+
# The artifact name will contain the target triple, so the file name doesn't need to.
38+
mv artifacts/paxos-x86_64-unknown-linux-musl artifacts/paxos
39+
- uses: actions/upload-artifact@v2
40+
with:
41+
name: x86_64-unknown-linux-musl
42+
path: artifacts/paxos
43+
if-no-files-found: error
44+
ci-macos:
45+
name: Build and test on macOS
46+
runs-on: macos-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
- run: |
50+
# Make Bash not silently ignore errors.
51+
set -euo pipefail
52+
53+
rustup toolchain install 1.53.0 # [ref:rust_1_53_0]
54+
rustup default 1.53.0 # [ref:rust_1_53_0]
55+
- run: |
56+
# Make Bash not silently ignore errors.
57+
set -euo pipefail
58+
59+
# Build and test.
60+
cargo build --locked --release --target x86_64-apple-darwin
61+
NO_COLOR=true cargo test --locked # [ref:colorless_tests]
62+
- uses: actions/upload-artifact@v2
63+
with:
64+
name: x86_64-apple-darwin
65+
path: target/x86_64-apple-darwin/release/paxos
66+
if-no-files-found: error
67+
ci-windows:
68+
name: Build and test on Windows
69+
runs-on: windows-latest
70+
steps:
71+
- uses: actions/checkout@v2
72+
- run: |
73+
# Make Bash not silently ignore errors.
74+
set -euo pipefail
75+
76+
rustup toolchain install 1.53.0 # [ref:rust_1_53_0]
77+
rustup default 1.53.0 # [ref:rust_1_53_0]
78+
- run: |
79+
# Make Bash not silently ignore errors.
80+
set -euo pipefail
81+
82+
# Build and test.
83+
cargo build --locked --release --target x86_64-pc-windows-msvc
84+
NO_COLOR=true cargo test --locked # [ref:colorless_tests]
85+
- uses: actions/upload-artifact@v2
86+
with:
87+
name: x86_64-pc-windows-msvc
88+
path: target/x86_64-pc-windows-msvc/release/paxos.exe
89+
if-no-files-found: error
90+
install-macos:
91+
name: Run the installer script on macOS to validate it
92+
runs-on: macos-latest
93+
steps:
94+
- uses: actions/checkout@v2
95+
- run: |
96+
# Make Bash not silently ignore errors.
97+
set -euo pipefail
98+
99+
# Run the installer script.
100+
# PREFIX=/tmp ./install.sh
101+
102+
# Run the installed binary.
103+
# /tmp/paxos
104+
install-ubuntu:
105+
name: Run the installer script on Ubuntu to validate it
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v2
109+
- run: |
110+
# Make Bash not silently ignore errors.
111+
set -euo pipefail
112+
113+
# Run the installer script.
114+
# PREFIX=/tmp ./install.sh
115+
116+
# Run the installed binary.
117+
# /tmp/paxos
118+
create-release:
119+
name: Create a release on GitHub if applicable
120+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/windows' }}
121+
runs-on: ubuntu-latest
122+
needs: [ci-linux, ci-macos, ci-windows, install-macos, install-ubuntu]
123+
steps:
124+
- uses: actions/checkout@v2
125+
- uses: actions/download-artifact@v2
126+
with:
127+
path: artifacts/
128+
- env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
run: |
131+
# Make Bash not silently ignore errors.
132+
set -euo pipefail
133+
134+
# Fetch the program version.
135+
VERSION="$(cargo pkgid | cut -d# -f2 | cut -d: -f2)"
136+
137+
# If the release already exists, exit early.
138+
if hub release show "v$VERSION" &> /dev/null; then
139+
echo "Release v$VERSION already exists."
140+
exit
141+
fi
142+
143+
# Give the artifacts unique names.
144+
mv \
145+
artifacts/x86_64-unknown-linux-gnu/paxos \
146+
artifacts/paxos-x86_64-unknown-linux-gnu
147+
mv \
148+
artifacts/x86_64-unknown-linux-musl/paxos \
149+
artifacts/paxos-x86_64-unknown-linux-musl
150+
mv \
151+
artifacts/x86_64-apple-darwin/paxos \
152+
artifacts/paxos-x86_64-apple-darwin
153+
mv \
154+
artifacts/x86_64-pc-windows-msvc/paxos.exe \
155+
artifacts/paxos-x86_64-pc-windows-msvc.exe
156+
157+
# Create the release.
158+
hub release create \
159+
--commitish '${{ github.sha }}' \
160+
--message "v$VERSION" \
161+
--attach 'artifacts/paxos-x86_64-unknown-linux-gnu' \
162+
--attach 'artifacts/paxos-x86_64-unknown-linux-musl' \
163+
--attach 'artifacts/paxos-x86_64-apple-darwin' \
164+
--attach 'artifacts/paxos-x86_64-pc-windows-msvc.exe' \
165+
"v$VERSION"
166+
echo "Created release v$VERSION."

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Keep this file in sync with `.ignore`.
1+
/artifacts/
22
/target/

‎.ignore

-2
This file was deleted.

‎CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.0.1] - 2021-06-20
9+
10+
### Changed
11+
- The GitHub workflow now enforces that `Cargo.lock` is up-to-date.
12+
13+
## [0.0.0] - 2021-06-20
14+
15+
### Added
16+
- Initial release.

‎CONTRIBUTING.md

+42
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,45 @@
33
Thank you for your interest in contributing! You can contribute by filing [issues](https://github.com/stepchowfun/paxos/issues) and submitting [pull requests](https://github.com/stepchowfun/paxos/pulls). Please observe our [code of conduct](https://github.com/stepchowfun/paxos/blob/main/CODE_OF_CONDUCT.md).
44

55
If you submit a pull request, please ensure your change passes the [GitHub Actions](https://github.com/stepchowfun/paxos/actions) CI checks. This will be apparent from the required status check(s) in the pull request.
6+
7+
## Rust style guide
8+
9+
We are fortunate to have good tooling around enforcing a consistent style throughout the codebase. If you have [Toast](https://github.com/stepchowfun/toast), you can run the various lint checks by running `toast lint`. Otherwise, you can rely on our CI to do it for you. Here, we make note of a few conventions which are not yet enforced automatically. Please adhere to these conventions when possible, and provide appropriate justification for deviations from this guide. If you notice any style violations which appear unintentional, we invite you to bring them to our attention.
10+
11+
### Comments
12+
13+
**Rule:** Comments should be written in American English.
14+
15+
**Rule:** Comments should always be capitalized unless they start with a code-like expression (see below).
16+
17+
**Rule:** Comments which are sentences should be punctuated appropriately. For example:
18+
19+
```rust
20+
// The following logic implements beta reduction.
21+
```
22+
23+
**Rule:** Comments which are not sentences should not have a trailing period. For example:
24+
25+
```rust
26+
// Already normalized
27+
```
28+
29+
**Rule:** Code-like expressions, such as variable names, should be surrounded by backticks. For example:
30+
31+
```rust
32+
// `source_range` is a half-open interval, closed on the left and open on the right.
33+
```
34+
35+
### Trailing commas
36+
37+
The linter enforces that items in multi-line sequences (e.g., function arguments and macro arguments) have trailing commas.
38+
39+
**Rule:** Macros should be written to accept trailing commas as follows:
40+
41+
```rust
42+
macro_rules! my_macro {
43+
($foo:expr, $bar:expr, $baz:expr $(,)?) => {{
44+
...
45+
}};
46+
}
47+
```

‎MAINTAINERS.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Maintainers
2+
3+
This document describes some instructions for maintainers. Other contributors and users need not be concerned with this material.
4+
5+
### GitHub instructions
6+
7+
When setting up the repository on GitHub, configure the following settings:
8+
9+
- Under `Secrets`, add the following repository secrets with appropriate values:
10+
- `CRATES_IO_TOKEN`
11+
- `DOCKER_PASSWORD`
12+
- Under `Branches`, add a branch protection rule for the `main` branch.
13+
- Enable `Require status checks to pass before merging`.
14+
- Enable `Require branches to be up to date before merging`.
15+
- Add the following status checks:
16+
- `Build and test on Linux`
17+
- `Build and test on Windows`
18+
- `Build and test on macOS`
19+
- `Create a release on GitHub if applicable`
20+
- `Run the installer script on Ubuntu to validate it`
21+
- `Run the installer script on macOS to validate it`
22+
- Enable `Include administrators`.
23+
- Under `Options`, enable `Automatically delete head branches`.
24+
25+
The GitHub workflow will fail initially because the jobs which test the installer script will not find any release to download. You'll need to bootstrap a release by temporarily removing those jobs or changing them to no-ops. Be aware that the `create-release` job is configured to only run on the `main` branch, so you may also need to temporarily change that depending on which branch you're working on.
26+
27+
### Release instructions
28+
29+
Releasing a new version is a two-step process:
30+
31+
1. Bump the version in `Cargo.toml`, run `cargo build` to update `Cargo.lock`, and update `CHANGELOG.md` with information about the new version. Ship those changes as a single commit.
32+
2. Once the GitHub workflow has finished on the `main` branch, update the version in `install.sh` to point to the new release.

‎README.md

+35-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,46 @@
44

55
An implementation of single-decree Paxos.
66

7-
## Installation
7+
## Installation instructions
88

9-
You can build and install the program with [Cargo](https://doc.rust-lang.org/book/second-edition/ch14-04-installing-binaries.html):
9+
### Easy installation on macOS or Linux
10+
11+
If you are running macOS or Linux on an x86-64 CPU, you can install Paxos with this command:
12+
13+
```sh
14+
curl https://raw.githubusercontent.com/stepchowfun/paxos/main/install.sh -LSfs | sh
15+
```
16+
17+
The same command can be used again to update Paxos to the latest version.
18+
19+
**NOTE:** Piping `curl` to `sh` is considered dangerous by some since the server might be compromised. If you're concerned about this, you can download and inspect the installation script or choose one of the other installation methods.
20+
21+
#### Customizing the installation
22+
23+
The installation script supports the following environment variables:
24+
25+
- `VERSION=x.y.z` (defaults to the latest version)
26+
- `PREFIX=/path/to/install` (defaults to `/usr/local/bin`)
27+
28+
For example, the following will install Paxos into the working directory:
29+
30+
```sh
31+
curl https://raw.githubusercontent.com/stepchowfun/paxos/main/install.sh -LSfs | PREFIX=. sh
32+
```
33+
34+
### Manual installation for macOS, Linux, or Windows
35+
36+
The [releases page](https://github.com/stepchowfun/paxos/releases) has precompiled binaries for macOS, Linux, and Windows systems running on an x86-64 CPU. You can download one of them and place it in a directory listed in your [`PATH`](https://en.wikipedia.org/wiki/PATH_\(variable\)).
37+
38+
### Installation with Cargo
39+
40+
If you have [Cargo](https://doc.rust-lang.org/cargo/), you can install Paxos as follows:
1041

1142
```sh
12-
cargo install --path .
43+
cargo install paxos
1344
```
1445

15-
You can run that command again to update an existing installation.
46+
You can run that command with `--force` to update an existing installation.
1647

1748
## Configuration
1849

There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.