Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move from doit to just #160

Merged
merged 9 commits into from Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .devcontainer/Dockerfile
@@ -1,7 +1,11 @@
FROM mcr.microsoft.com/vscode/devcontainers/rust:1

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends graphviz pandoc python3-doit python3-dev python3-venv python3-pip
&& apt-get -y install --no-install-recommends graphviz pandoc python3-dev python3-venv python3-pip

RUN python3 -m pip install --disable-pip-version-check --quiet scriv \
&& rm -rf ~/.local/pip

USER vscode

RUN cargo install just
17 changes: 8 additions & 9 deletions .devcontainer/devcontainer.json
Expand Up @@ -2,10 +2,13 @@
// https://github.com/microsoft/vscode-dev-containers/blob/main/containers/rust/.devcontainer/devcontainer.json
"name": "Rust",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],

"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
Expand All @@ -15,21 +18,17 @@
},
"rust-analyzer.checkOnSave.command": "clippy"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"matklad.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
}
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Expand Up @@ -41,11 +41,11 @@ jobs:
- name: Install distro packages
run: sudo apt-get install -qq pandoc graphviz

- name: Install doit
run: python -m pip install --upgrade pip doit
- name: Install `just`
uses: extractions/setup-just@v1

- name: Run `doit`
run: doit
- name: Run `just`
run: just

coverage:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -4,5 +4,4 @@
__pycache__
.venv
.pytest_cache
.doit.db
*.tar.xz
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Expand Up @@ -7,11 +7,13 @@
The Python Launcher is _mostly_ run as a typical Rust project. The only
potential differences is the automation tool used (for convenience).

## Using doit for automation
## Using `just` for automation

We use [doit](https://pydoit.org/) as an automation tool. It's
[available on PyPI](https://pypi.org/project/doit/) and may be available in your
preferred package manager (e.g. `apt`).
We use [just](https://github.com/casey/just) as an automation tool. It is similar to [make](https://www.gnu.org/software/make/)
but with a few nice features and fewer quirks.

It is available from a variety of package managers and other sources, see the [install](https://github.com/casey/just#installation) docs
for how to get it for your system.

## Changelog

Expand All @@ -20,7 +22,6 @@ The tool used to maintain the changelog is
[`changelog.d` directory](https://github.com/brettcannon/python-launcher/tree/main/changelog.d)
for details.


## Releasing

1. Adjust the version number in [`Cargo.toml`](https://github.com/brettcannon/python-launcher/blob/main/Cargo.toml) (previous [releases](https://github.com/brettcannon/python-launcher/releases)).
Expand Down
41 changes: 41 additions & 0 deletions changelog.d/20211026_081619_tomfleet2018_use_just.md
@@ -0,0 +1,41 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Removed

- A bullet item for the Removed category.

-->
<!--
### Added

- A bullet item for the Added category.

-->

### Changed

- Replace doit with [just](https://github.com/casey/just) as a command runner.

<!--
### Deprecated

- A bullet item for the Deprecated category.

-->
<!--
### Fixed

- A bullet item for the Fixed category.

-->
<!--
### Security

- A bullet item for the Security category.

-->
97 changes: 0 additions & 97 deletions dodo.py

This file was deleted.

80 changes: 80 additions & 0 deletions justfile
@@ -0,0 +1,80 @@
#!/usr/bin/env just --justfile
# Written for https://github.com/casey/just/tree/0.10.2 .

ROOT := justfile_directory()
DOCS := join(ROOT, "docs")
MAN_DIR := join(DOCS, "man-page")
MAN_MD := join(MAN_DIR, "py.1.md")
MAN_FILE := join(MAN_DIR, "py.1")
CARGO_TOML := join(ROOT, "Cargo.toml")
DOT_DIR := join(DOCS, "control-flow")
DOT_FILE := join(DOT_DIR, "control_flow.dot")
DOT_FILE_NO_STEM := without_extension(DOT_FILE)
DOT_SVG := DOT_FILE_NO_STEM + ".svg"
DOT_PNG := DOT_FILE_NO_STEM + ".png"

# TODO: `just` release after 0.10.2 will make `join` accept variadic parameters;
# would clean up the variables quite a bit.

# Set default recipes
_default: lint test man dot

# Run the unit tests
test:
cargo --quiet test

# Run linting on source files
lint:
cargo fmt --quiet --all -- --check
cargo clippy --quiet --all-targets --all-features -- -D warnings

# Install from source
install:
cargo install --quiet --path .

# Convert the markdown-formatted man page to the man file format
_man-md:
pandoc {{ MAN_MD }} --standalone -t man -o {{ MAN_FILE }}

# Build the man page
man: _man-md
#!/usr/bin/env python3

import datetime
import pathlib
import re

FollowTheProcess marked this conversation as resolved.
Show resolved Hide resolved
VERSION_REGEX = re.compile(r'version\s*=\s*"(?P<version>[\d.]+)"')

with open("{{ CARGO_TOML }}", "r", encoding="utf-8") as file:
cargo_lines = file.readlines()

for line in cargo_lines:
version_match = VERSION_REGEX.match(line)
if version_match:
version = version_match.group("version")
break
else:
raise ValueError("'version' not found in {{ CARGO_TOML }}")

with open("{{ MAN_FILE }}", "r", encoding="utf-8") as file:
man_text = file.read()

man_text_with_version = man_text.replace("LAUNCHER_VERSION", version)
new_man_text = man_text_with_version.replace(
"CURRENT_DATE", datetime.date.today().isoformat()
)

with open("{{ MAN_FILE }}", "w", encoding="utf-8") as file:
file.write(new_man_text)

# Build the control flow diagram as a SVG
dot_svg:
dot -T "svg" -o {{ DOT_SVG }} {{ DOT_FILE }}

# Build the control flow diagram as a PNG
dot_png:
dot -T "png" -o {{ DOT_PNG }} {{ DOT_FILE }}

# Build the control flow diagram
dot: dot_svg dot_png