Skip to content

Commit 685d474

Browse files
committed
Add contributing docs and expand flake dev environment
1 parent 77cdeb2 commit 685d474

File tree

5 files changed

+227
-0
lines changed

5 files changed

+227
-0
lines changed

.config/.cspell.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
"version": "0.2",
33
"language": "en",
44
"words": [
5+
"devcontainer",
6+
"direnv",
7+
"hadolint",
58
"Kickr",
69
"netbrain",
10+
"shellcheck",
711
"WQHD",
812
"zwift",
913
"zwifters"

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
Thanks for your interest in contributing to netbrain/zwift!
4+
5+
## Quick Start
6+
7+
### Using Nix (recommended)
8+
9+
```bash
10+
nix develop
11+
# Or with direnv: direnv allow
12+
```
13+
14+
### Using VS Code Devcontainer
15+
16+
Open the project in VS Code and select "Reopen in Container" when prompted.
17+
18+
## Documentation
19+
20+
For detailed setup instructions, available tools, and guidelines, see the
21+
[Contributing Guide](https://netbrain.github.io/zwift/contributing/).
22+
23+
## Issues and PRs
24+
25+
- Check [open issues](https://github.com/netbrain/zwift/issues) for something
26+
to work on
27+
- Feel free to open a PR - all contributions are welcome

docs/contributing/development.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: Development Environment
3+
parent: Contributing
4+
nav_order: 1
5+
---
6+
7+
This project provides two options for setting up a development environment with
8+
all the linting and development tools used in CI.
9+
10+
## Option 1: Nix Flakes (Recommended)
11+
12+
[Nix flakes](https://nixos.wiki/wiki/Flakes) provide a reproducible development
13+
environment that works on any Linux distribution.
14+
15+
### Prerequisites
16+
17+
- [Nix](https://nixos.org/download.html) with flakes enabled
18+
- Optionally [direnv](https://direnv.net/) for automatic shell activation
19+
20+
#### Enabling Flakes
21+
22+
If you haven't enabled flakes, add this to `~/.config/nix/nix.conf`:
23+
24+
```ini
25+
experimental-features = nix-command flakes
26+
```
27+
28+
### Entering the Development Shell
29+
30+
```bash
31+
# One-time use
32+
nix develop
33+
34+
# Or with direnv (recommended)
35+
direnv allow
36+
```
37+
38+
### Available Tools
39+
40+
The development shell includes all tools used in CI:
41+
42+
| Tool | Purpose |
43+
|------|---------|
44+
| `shellcheck` | Bash script linting |
45+
| `shfmt` | Bash script formatting |
46+
| `nil` | Nix language diagnostics |
47+
| `nixfmt-rfc-style` | Nix code formatting |
48+
| `hadolint` | Dockerfile linting |
49+
| `markdownlint-cli2` | Markdown linting |
50+
| `cspell` | Spell checking |
51+
| `actionlint` | GitHub Actions workflow linting |
52+
| `yamllint` | YAML linting |
53+
| `podman` | Container runtime |
54+
| `gh` | GitHub CLI |
55+
56+
## Option 2: VS Code Devcontainer
57+
58+
If you use VS Code and prefer containers over Nix, a
59+
[devcontainer](https://containers.dev/) configuration is included.
60+
61+
### Requirements
62+
63+
- [VS Code](https://code.visualstudio.com/)
64+
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
65+
- Docker or Podman
66+
67+
### Getting Started
68+
69+
1. Open the project in VS Code
70+
2. When prompted, click "Reopen in Container"
71+
3. Or use the command palette: `Dev Containers: Reopen in Container`
72+
73+
The devcontainer includes:
74+
75+
- Docker-in-docker for building images
76+
- Nix with `nil` language server
77+
- shellcheck and hadolint
78+
- VS Code extensions for real-time linting feedback
79+
80+
## Running Linters Locally
81+
82+
Run these before submitting a PR to catch issues early:
83+
84+
```bash
85+
# Bash scripts
86+
shellcheck *.sh bin/*.sh
87+
shfmt -d *.sh bin/*.sh
88+
89+
# Nix files
90+
nil diagnostics *.nix
91+
nixfmt-rfc-style --check *.nix
92+
93+
# Dockerfile
94+
hadolint Dockerfile
95+
96+
# Markdown
97+
markdownlint-cli2 "**/*.md"
98+
cspell "**/*.md"
99+
100+
# GitHub Actions
101+
actionlint
102+
103+
# YAML
104+
yamllint .github/workflows/
105+
```
106+
107+
## Building the Documentation Locally
108+
109+
The documentation uses Jekyll with the just-the-docs theme.
110+
111+
```bash
112+
cd docs
113+
bundle install
114+
bundle exec jekyll serve
115+
```
116+
117+
Then open <http://localhost:4000> in your browser.
118+
119+
## Building the Container Image
120+
121+
```bash
122+
# Build the image
123+
podman build -t zwift:dev .
124+
125+
# Or use the build script
126+
./bin/build-image.sh
127+
```
128+
129+
## Testing Changes
130+
131+
```bash
132+
# Dry run to see what would be executed
133+
DRYRUN=1 ./zwift.sh
134+
135+
# Run in foreground for debugging
136+
ZWIFT_FG=1 ./zwift.sh
137+
138+
# Interactive mode (drops into container shell)
139+
INTERACTIVE=1 ./zwift.sh
140+
```

docs/contributing/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Contributing
3+
nav_order: 6
4+
has_children: true
5+
description: "How to contribute to the project"
6+
---
7+
8+
Thanks for your interest in contributing! This project welcomes all
9+
contributions, whether it's bug fixes, new features, documentation
10+
improvements, or issue reports.
11+
12+
## Ways to Contribute
13+
14+
- **Report bugs** - Open an [issue](https://github.com/netbrain/zwift/issues)
15+
with details about the problem
16+
- **Suggest features** - Start a
17+
[discussion](https://github.com/netbrain/zwift/discussions) to propose new
18+
ideas
19+
- **Submit PRs** - Fix bugs or implement features
20+
- **Improve docs** - Help make the documentation clearer
21+
22+
## Getting Started
23+
24+
1. Fork the repository
25+
2. Set up the [development environment](development.html)
26+
3. Make your changes
27+
4. Run the linters locally to catch issues early
28+
5. Submit a pull request

flake.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,38 @@
256256

257257
devShells.x86_64-linux.default = pkgs.mkShell {
258258
packages = with pkgs; [
259+
# Bash
259260
shellcheck
260261
shfmt
262+
263+
# Nix
264+
nil
265+
nixfmt-rfc-style
266+
267+
# Docker
268+
hadolint
269+
270+
# Markdown
271+
nodePackages.markdownlint-cli2
272+
nodePackages.cspell
273+
274+
# Documentation (Jekyll)
261275
ruby
262276
bundler
277+
278+
# Container runtime
279+
podman
280+
281+
# GitHub
282+
gh
283+
actionlint
284+
285+
# YAML
286+
yamllint
287+
288+
# Utilities
289+
curl
290+
jq
263291
];
264292
};
265293

0 commit comments

Comments
 (0)