Skip to content

Commit 1f59851

Browse files
babu-chclaude
andcommitted
Add Docker-based test infrastructure
All three language suites now runnable without local toolchain installs. - docker-compose.yml: node/ruby/php services with repo bind-mounted - Makefile: test / test-node / test-ruby / test-php targets - .devcontainer/devcontainer.json: VS Code universal image with all runtimes - DEVELOPMENT.md: contributor guide Validated by running all three suites in containers: 9 PHPUnit + 9 rspec + node:test all green. Fixes phpcs-aaa bootstrap (needed explicit PHPCS autoload and Util\Tokens instantiation to define T_* polyfills). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6341f66 commit 1f59851

7 files changed

Lines changed: 125 additions & 0 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "aaa-lint",
3+
"image": "mcr.microsoft.com/devcontainers/universal:2-linux",
4+
"features": {
5+
"ghcr.io/devcontainers/features/node:1": { "version": "20" },
6+
"ghcr.io/devcontainers/features/ruby:1": { "version": "3.2" },
7+
"ghcr.io/devcontainers/features/php:1": { "version": "8.2" },
8+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9+
},
10+
"postCreateCommand": "npm install && (cd packages/rubocop-aaa && bundle config set --local path vendor/bundle && bundle install) && (cd packages/phpcs-aaa && composer install)",
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"dbaeumer.vscode-eslint",
15+
"misogi.ruby-rubocop",
16+
"bmewburn.vscode-intelephense-client"
17+
]
18+
}
19+
}
20+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
node_modules/
22
dist/
3+
composer.lock
4+
.phpunit.result.cache
35
.DS_Store
46
*.log
57
vendor/

DEVELOPMENT.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Development
2+
3+
This is a multi-language monorepo (JS / Ruby / PHP). To avoid requiring every contributor to install three toolchains locally, **all tests run inside Docker**.
4+
5+
## Prerequisites
6+
7+
- Docker + Docker Compose
8+
9+
That's it. No local Node, Ruby, PHP, or Composer needed.
10+
11+
## Running tests
12+
13+
```bash
14+
make test # all three languages
15+
make test-node # eslint-plugin-aaa
16+
make test-ruby # rubocop-aaa
17+
make test-php # phpcs-aaa
18+
```
19+
20+
Under the hood these run `docker compose run --rm <service>` against the services defined in `docker-compose.yml`:
21+
22+
| Service | Image | Workdir |
23+
|---|---|---|
24+
| `node` | `node:20-alpine` | repo root (npm workspaces) |
25+
| `ruby` | `ruby:3.2-alpine` | `packages/rubocop-aaa` |
26+
| `php` | `composer:2` | `packages/phpcs-aaa` |
27+
28+
The first run pulls images and installs dependencies into bind-mounted volumes (`node_modules`, `packages/rubocop-aaa/vendor/bundle`, `packages/phpcs-aaa/vendor`). Subsequent runs are fast.
29+
30+
## Dev Container (optional)
31+
32+
Opening the repo in VS Code with the Dev Containers extension will build a universal image pre-loaded with Node 20, Ruby 3.2, PHP 8.2, and Docker-in-Docker. See `.devcontainer/devcontainer.json`.
33+
34+
## Running locally (without Docker)
35+
36+
If you have the relevant toolchain installed you can also run tests directly:
37+
38+
```bash
39+
# JS
40+
npm test --workspace=eslint-plugin-aaa
41+
42+
# Ruby
43+
cd packages/rubocop-aaa && bundle install && bundle exec rspec
44+
45+
# PHP
46+
cd packages/phpcs-aaa && composer install && composer test
47+
```
48+
49+
## Cleaning up
50+
51+
```bash
52+
make clean # remove node_modules, vendor/, .bundle/
53+
```

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.PHONY: test test-node test-ruby test-php clean
2+
3+
test: test-node test-ruby test-php
4+
5+
test-node:
6+
docker compose run --rm node
7+
8+
test-ruby:
9+
docker compose run --rm ruby
10+
11+
test-php:
12+
docker compose run --rm php
13+
14+
clean:
15+
rm -rf node_modules packages/*/node_modules \
16+
packages/rubocop-aaa/vendor packages/rubocop-aaa/.bundle \
17+
packages/phpcs-aaa/vendor packages/phpcs-aaa/composer.lock

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ There is no built-in preset besides the English default. Use the `labels` option
4040
}
4141
```
4242

43+
## Development
44+
45+
All tests run inside Docker — no local Node/Ruby/PHP installs required. See [DEVELOPMENT.md](./DEVELOPMENT.md).
46+
47+
```bash
48+
make test # run all three language suites
49+
```
50+
4351
## License
4452

4553
MIT

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
node:
3+
image: node:20-alpine
4+
working_dir: /work
5+
volumes:
6+
- .:/work
7+
command: sh -c "npm install --silent && npm test --workspaces --if-present"
8+
9+
ruby:
10+
image: ruby:3.2-alpine
11+
working_dir: /work/packages/rubocop-aaa
12+
volumes:
13+
- .:/work
14+
command: sh -c "apk add --no-cache build-base git && bundle config set --local path vendor/bundle && bundle install --quiet && bundle exec rspec"
15+
16+
php:
17+
image: composer:2
18+
working_dir: /work/packages/phpcs-aaa
19+
volumes:
20+
- .:/work
21+
entrypoint: sh
22+
command: -c "composer install --no-interaction --quiet && vendor/bin/phpunit"

packages/phpcs-aaa/tests/bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
require __DIR__ . '/../vendor/autoload.php';
4+
require __DIR__ . '/../vendor/squizlabs/php_codesniffer/autoload.php';
5+
// PHPCS defines its T_* polyfill constants inside Util\Tokens; force-load it.
6+
new \PHP_CodeSniffer\Util\Tokens();
47

58
if (!defined('PHP_CODESNIFFER_CBF')) {
69
define('PHP_CODESNIFFER_CBF', false);

0 commit comments

Comments
 (0)