Skip to content

Commit dcaaeb0

Browse files
authored
Merge pull request #45 from Quafadas/copilot/add-copilot-instructions-file
Add .github/copilot-instructions.md
2 parents 59883f4 + 9aa1630 commit dcaaeb0

2 files changed

Lines changed: 113 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Copilot Instructions
2+
3+
## Project Overview
4+
5+
`live-server-scala-cli-js` (published as `io.github.quafadas::sjsls`) is a Scala JS live development server that aims to replicates the Vite.js experience without Vite. It provides:
6+
- Live reload on file changes via Server-Sent Events (SSE)
7+
- Hot CSS/LESS application without page reload
8+
- HTTP proxy server support
9+
- Auto-open browser on startup
10+
- Support for Scala CLI, Mill, and no-build-tool modes
11+
12+
ToDo: Content hashing
13+
14+
## Build System: Mill
15+
16+
This project uses **Mill** (version 1.0.5) as its build tool. The Mill wrapper script (`./mill`) is checked in. JVM 21 is required.
17+
18+
CI will fail poorly formatted files. Make sure to run formatting before pushing.
19+
20+
### Mill Fundamentals
21+
22+
- `build.mill` is the root build file (header directives declare Mill version and JVM)
23+
- Module dependencies and versions are centralised in the `V` object in `build.mill`
24+
- Shared behaviour is expressed via traits: `FormatFix`, `FormatFixPublish`, `Testy`
25+
- Individual modules define their own `package.mill` files
26+
- Run `./mill resolve __` to list all available tasks
27+
- Run `./mill <module>.<task>` to invoke a specific task, e.g. `./mill sjsls.compile`
28+
- Use `./mill -w <task>` for watch mode (reruns on source change)
29+
30+
### Key Mill Commands
31+
32+
```bash
33+
# IDE / setup
34+
./mill mill.bsp.BSP/install # Install BSP for Metals/IntelliJ
35+
36+
# Compilation
37+
./mill __.compile # Compile all modules
38+
./mill sjsls.compile # Compile main module only
39+
40+
# Testing
41+
./mill __.test # Test all modules
42+
./mill sjsls.test.testOnly io.github.quafadas.sjsls.RoutesSuite
43+
./mill sjsls.test.testOnly io.github.quafadas.sjsls.SafariSuite
44+
./mill sjsls.test.testOnly io.github.quafadas.sjsls.UtilityFcs
45+
46+
# Formatting (Scalafmt)
47+
./mill mill.scalalib.scalafmt.ScalafmtModule/
48+
49+
# Linting (Scalafix)
50+
./mill __.fix
51+
52+
```
53+
54+
## Module Structure
55+
56+
```
57+
live-server-scala-cli-js/
58+
├── build.mill # Root Mill build; V object with all versions; shared traits
59+
├── playwrightVersion.mill # Playwright version constant (imported into build.mill)
60+
├── justfile # Task runner shortcuts
61+
├── mill # Mill wrapper script
62+
├── sjsls/ # Main application module
63+
│ ├── package.mill # Module definition (extends FormatFixPublish)
64+
│ ├── src/ # ~15 Scala source files
65+
│ └── test/src/ # Munit + Playwright integration tests
66+
├── routes/ # HTTP routing library (depended on by sjsls)
67+
│ ├── package.mill
68+
│ ├── src/
69+
│ └── test/src/
70+
├── plugin/ # Mill plugin for Scala JS live reload in user projects
71+
│ ├── package.mill
72+
│ └── src/refresh_plugin.scala
73+
└── site/ # Documentation site (Laika + SiteModule)
74+
├── package.mill
75+
└── docs/
76+
```
77+
78+
79+
## Technology Stack
80+
81+
The typelevel stack -
82+
83+
## Testing
84+
85+
Tests use **Munit** with **Cats Effect** and **Playwright** for browser integration tests.
86+
87+
Before running tests, you'll probably need to make sure that playwright is installed and ready. It should be installed as part of the `copilot-setup-steps` workflow.
88+
89+
```bash
90+
# Run individual suites
91+
./mill sjsls.test.testOnly io.github.quafadas.sjsls.SafariSuite
92+
./mill sjsls.test.testOnly io.github.quafadas.sjsls.RoutesSuite
93+
./mill sjsls.test.testOnly io.github.quafadas.sjsls.UtilityFcs
94+
95+
# Run all tests
96+
./mill __.test
97+
```
98+
99+
Tests that start a real server use `IOSuite` from munit-cats-effect and allocate an `http4s` client as a resource. Playwright tests launch a headless browser to verify live reload behaviour.
100+
101+
## CI/CD
102+
103+
The CI pipeline (`.github/workflows/ci.yml`) runs on PRs and pushes to main:
104+
105+
1. **Format check**: `./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources`
106+
2. **Compile**: `./mill __.compile`
107+
3. **Test**: `./mill __.test`
108+
109+
Publishing to Maven Central is triggered automatically when a `v*` tag is pushed. The Copilot agent setup workflow (`.github/workflows/copilot-setup-steps.yml`) pre-compiles semantic DB files for IDE support.

.github/workflows/copilot-setup-steps.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
- name: Verify Java version
4040
run: java --version
4141

42+
43+
- name: Install Playwright
44+
run: cs launch com.microsoft.playwright:playwright:1.51.0 -M "com.microsoft.playwright.CLI" -- install --with-deps
45+
4246
# This should resolve a JVM, download dependancies and leave mill ready for use.
4347
- name: setup mill
4448
run: ./mill sjsls.compiledClassesAndSemanticDbFiles

0 commit comments

Comments
 (0)