Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Question or idea
url: https://github.com/vidya381/devcheck/discussions
about: Ask a question or talk through an idea before opening an issue.
13 changes: 9 additions & 4 deletions .github/ISSUE_TEMPLATE/new_check.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ labels: checker, good first issue
## What does it check?

## When should it run?
<!-- e.g. when MYSQL_URL is set, or when pom.xml exists -->
<!-- The detection condition, e.g. when MYSQL_URL is set, or when pom.xml exists -->

## What does passing look like?
## Pass message

## What does failing look like?
<!-- include a suggested fix message if you have one -->
## Warn or fail message
<!-- Warn if it will not stop you working, fail if it will -->

## Fix text
<!-- What --fix should print under the failure -->

## Anything else
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## What this changes

<!-- One or two lines. -->

Closes #

## Checklist

- [ ] `go build ./...` passes
- [ ] `go test ./...` passes
- [ ] `go vet ./...` passes
- [ ] Tests cover the pass case and the fail case
- [ ] The issue is linked above
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ jobs:

- name: Vet
run: go vet ./...
- name: Format
run: test -z "$(gofmt -l .)"
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -23,6 +26,12 @@ jobs:
GOOS=darwin GOARCH=arm64 go build -ldflags="-X main.version=${{ github.ref_name }}" -o dist/devcheck-darwin-arm64 ./cmd/devcheck
GOOS=windows GOARCH=amd64 go build -ldflags="-X main.version=${{ github.ref_name }}" -o dist/devcheck-windows-amd64.exe ./cmd/devcheck

- name: Generate checksums
run: |
cd dist
sha256sum devcheck-* > checksums.txt
cat checksums.txt

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- id: devcheck
name: devcheck
description: Check the dev environment has everything this project needs
entry: devcheck --ci
language: golang
pass_filenames: false
always_run: true
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

## Unreleased

## v0.1.0

First release.

- Detects Go, Node, Python, Ruby, Rust, Java, Docker and Docker Compose from project files, and Postgres, MySQL, MongoDB and Redis from environment variables.
- Checks binaries are on PATH: go, golangci-lint, node, npm/pnpm/yarn, python3, pip, ruby, bundler, rustc, cargo, java, mvn, gradle, docker.
- Version checks for Go (`go.mod`), Node (`.nvmrc` or `engines.node`) and Rust (`rust-toolchain.toml`).
- Dependency checks for Go, Node, Python and Ruby.
- Checks every path under `use` in `go.work` exists and has a `go.mod`.
- Checks `.env` has every key from `.env.example`, and warns on empty values. Handles quoted and multi-line values.
- Checks `.gitignore` covers `.env`, `*.log`, and `node_modules` or `__pycache__`.
- Checks for configured git hooks: `.husky` for Node, `pre-commit` for Python.
- Checks the Docker daemon responds, Compose services are running and Compose images are pulled.
- Port and ping checks for Postgres, MySQL, MongoDB and Redis.
- `devcheck.yml` with `require` for extra binaries and `skip` to drop checks by name.
- Flags: `--fix`, `--json`, `--ci`, `--verbose`, `--version`.
- Release binaries for linux, darwin and windows with `checksums.txt`, an install script, and a GitHub Action.
71 changes: 43 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,69 @@
# Contributing

All contributions are welcome — new checks, bug fixes, docs, whatever.
New checks, bug fixes and docs are all welcome. I reply to issues and pull requests within a day or two.

## Setup

Fork the repo first, then clone your fork:
## Build and test

```bash
git clone https://github.com/YOUR_USERNAME/devcheck
cd devcheck
go build ./cmd/devcheck
go build ./...
go test ./...
go vet ./...
```

## Adding a new check
`go build -o devcheck ./cmd/devcheck` gives you a binary to try in another directory. The repo gitignores `/devcheck` so it will not show up in your diff.

## Adding a check

Most contributions are new checks. Here's how:
Every check is a struct with two methods, in `internal/check/`. Read [`internal/check/binary.go`](internal/check/binary.go) first, it is the smallest one. [`internal/check/gowork.go`](internal/check/gowork.go) is a good second example: it parses a file and reports which entries are missing.

1. Create `internal/checks/yourcheck.go`
2. Implement the `Check` interface:
1. Add `internal/check/yourcheck.go` in package `check`:

```go
type YourCheck struct{}
type YourCheck struct {
Dir string
}

func (c *YourCheck) Name() string { return "your check name" }

func (c *YourCheck) Run(ctx context.Context) check.Result {
return check.Result{
Name: c.Name(),
Status: check.StatusPass,
Message: "looks good",
Fix: "", // shown with --fix if this fails
}
func (c *YourCheck) Run(_ context.Context) Result {
return Result{
Name: c.Name(),
Status: StatusPass,
Message: "what is true right now",
Fix: "", // printed under the failure when --fix is passed
}
}
```

3. Register it in `internal/check/registry.go` under the right stack condition
4. Add a test in `internal/checks/yourcheck_test.go` — cover both pass and fail
5. Run `go test ./...` and make sure everything passes
6. Open a PR referencing the issue (e.g. "Closes #5")
2. Register it in [`internal/check/registry.go`](internal/check/registry.go), inside the `if` for the stack it belongs to. If it needs a file that may not exist, guard it with `fileExists`.
3. If the check needs to detect something new, add the field to `DetectedStack` in [`internal/detector/detector.go`](internal/detector/detector.go) and set it in `Detect`.
4. Add `internal/check/yourcheck_test.go`.

Statuses: `StatusPass`, `StatusWarn` for something worth mentioning that will not stop you working, `StatusFail` for something that will, and `StatusSkipped` when the check could not run at all. Skipped results are hidden unless `--verbose` is passed.

Messages are lowercase and say what is true, not what to do. The `Fix` field is where the instruction goes.

## Tests

Cover at least the pass case and the fail case. Use `t.TempDir()` for anything that reads files.

Do not make a test depend on a running service. Checks that talk to something take an injectable function so you can stub it: see `dialer` in `port.go` and `pinger` in `redis.go`. For a real connection failure without a server, dial a closed port on localhost.

## Pull requests

Before you start on something, leave a comment on the issue so nobody duplicates work.
Fill in the checklist in the template. Link the issue in the description, for example "Closes #31". Comment on an issue before you start so two people do not write the same check.

## PR checklist
## Labels

- `go build ./...` passes
- `go test ./...` passes
- `go vet ./...` passes
- Test covers pass and fail cases
- `good first issue` — self-contained, nothing to ask me first
- `checker` — adds or changes a check
- `help wanted` — needs a judgement call or a service to test against
- `enhancement` — a feature that is not a check
- `bug` — something is broken
- `documentation` — docs only

## Questions

Open a GitHub Discussion or leave a comment on the issue.
Open a Discussion or comment on the issue.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BIN := devcheck

.PHONY: build test vet install

build:
go build -o $(BIN) ./cmd/devcheck

test:
go test ./...

vet:
go vet ./...

install:
go install ./cmd/devcheck
128 changes: 85 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,123 @@
# devcheck

Check if your local dev environment is ready to run a project.
[![CI](https://github.com/vidya381/devcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/vidya381/devcheck/actions/workflows/ci.yml) [![Release](https://img.shields.io/github/v/release/vidya381/devcheck)](https://github.com/vidya381/devcheck/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/vidya381/devcheck)](https://goreportcard.com/report/github.com/vidya381/devcheck) [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

```
$ devcheck
devcheck looks at the files in a project, works out what stack it uses, and tells you what is missing or not running before you try to start it.

Detected: Go, Docker
## Output

✅ go installed
✅ Docker daemon running
❌ .env missing keys: DB_PASSWORD, API_KEY
Run it in a project directory with no arguments.

```
$ devcheck
✅ node is installed
✅ npm is installed
✅ Node 22.23.2 installed (need 20.11.0)
❌ node_modules directory not found
⚠️ .husky directory not found; git hooks for Node are not configured
✅ docker is installed
❌ Docker daemon is not running
❌ missing keys: API_KEY
⚠️ Missing 1 sensitive file pattern
────────────────────────────────────────
2 passed 0 warnings 1 failed
Run devcheck --fix for suggestions
4 passed 2 warnings 3 failed
Run `devcheck --fix` for suggestions
```

Run it in any project directory. devcheck looks at your project files, figures out what stack you're using, and checks that everything is actually running and configured before you waste time debugging.

---

## Install

**One-liner:**
```bash
curl -fsSL https://raw.githubusercontent.com/vidya381/devcheck/main/scripts/install.sh | bash
```

**Go install:**
Or with Go:

```bash
go install github.com/vidya381/devcheck/cmd/devcheck@latest
```

Or grab a binary from [releases](https://github.com/vidya381/devcheck/releases) — linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64.

---
Binaries for linux/amd64, linux/arm64, darwin/amd64, darwin/arm64 and windows/amd64 are on the [releases page](https://github.com/vidya381/devcheck/releases).

## Usage

```bash
devcheck # run all checks
devcheck --fix # show a suggested fix for each failure
devcheck --json # output results as JSON
devcheck --ci # exit code 1 on any failure (for CI pipelines)
devcheck --verbose # show skipped checks too
```

---
devcheck run every check that applies to this project
devcheck --fix print a suggested fix under each failure
devcheck --json print results as JSON
devcheck --ci exit 1 if any check failed
devcheck --verbose also print checks that were skipped
devcheck --version print the version
```

## What it checks

devcheck detects your stack from project files and runs the relevant checks automatically — no config needed.
Nothing is configured. devcheck picks checks based on what it finds in the directory.

| Detected from | Checks |
|---------------|--------|
| `go.mod` | go binary, go version |
| `package.json` | node, npm, node version |
| `requirements.txt` / `pyproject.toml` | python3, pip |
| `pom.xml` / `build.gradle` | java, mvn or gradle |
| `Dockerfile` / `docker-compose.yml` | docker binary, daemon running |
| `DATABASE_URL` in env | PostgreSQL reachable |
| `REDIS_URL` in env | Redis reachable |
| `.env.example` present | all keys exist in .env |
|---|---|
| `go.mod` | `go` on PATH, version against the `go` directive, module cache populated or `vendor/` present |
| `.golangci.yml` | `golangci-lint` on PATH |
| `go.work` | every path under `use` exists and has a `go.mod` |
| `package.json` | `node` and the right package manager on PATH, version against `.nvmrc` or `engines.node`, `node_modules` present, `.husky` present |
| `requirements.txt` / `pyproject.toml` | `python3` and `pip` on PATH, `venv`/`.venv` present, `pip check` clean, every requirement installed, `.pre-commit-config.yaml` and `pre-commit` present |
| `Gemfile` | `ruby` and `bundler` on PATH, `Gemfile.lock` or `vendor/bundle` present |
| `Cargo.toml` | `rustc` and `cargo` on PATH, version against `rust-toolchain.toml` |
| `pom.xml` / `build.gradle` | `java` on PATH, plus `mvn` or `gradle` |
| `Dockerfile` | `docker` on PATH, daemon responding |
| `docker-compose.yml` / `compose.yml` | every service running, every image pulled |
| `DATABASE_URL` containing `postgres` | port open, server answers a ping |
| `DATABASE_URL` containing `mysql`, or `MYSQL_URL` | port open, server answers a ping |
| `MONGODB_URI` / `MONGO_URL` | port open, server answers a ping |
| `REDIS_URL` / `REDIS_URI` | port open, server answers a ping |
| `.env.example` | every key also exists in `.env`, warn on empty values |
| `.gitignore` | covers `.env`, `*.log`, and `node_modules` or `__pycache__` for those stacks |

The package manager comes from the lockfile: `pnpm-lock.yaml`, `yarn.lock`, or npm otherwise.

### devcheck.yml

Optional. Put it in the project root.

```yaml
require:
- terraform
- kubectl
skip:
- "Git hooks configured for Node"
```

`require` adds a PATH check for each binary. `skip` drops checks by the name they report.

## Use in CI

```yaml
- uses: vidya381/devcheck@v0.1.0
```

Or with inputs:

---
```yaml
- uses: vidya381/devcheck@v0.1.0
with:
version: v0.1.0
args: --fix
```

## CI usage
The action downloads the release binary for the runner and runs `devcheck --ci`, so the job fails if any check fails. If you would rather install it yourself:

```yaml
- name: Check dev environment
run: devcheck --ci
- run: go install github.com/vidya381/devcheck/cmd/devcheck@latest
- run: devcheck --ci
```

Exits with code 1 if any check fails, so your pipeline stops early.
## Why I made it

---
Every time I set up a project I had not touched in a while, I lost half an hour to something small. Postgres not running, a key missing from `.env`, the wrong Node version. The error you get is never the error you have. I wanted one command that tells me all of it at once, before I run anything.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). Adding a new check is straightforward — each check is a small self-contained struct. Issues labeled `good first issue` are a good place to start.
See [CONTRIBUTING.md](CONTRIBUTING.md). Issues labeled `good first issue` are the easiest place to start, and most of them are a single new check with a test.

## License

MIT. See [LICENSE](LICENSE).
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Security

If you find a security problem in devcheck, please do not open a public issue.

Use GitHub's [private vulnerability reporting](https://github.com/vidya381/devcheck/security/advisories/new).

I will reply within a few days and let you know when a fix is out.
Loading
Loading