Skip to content

Commit d45d8d7

Browse files
dhensbyCopilot
andcommitted
chore: add copilot instructions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 476fae3 commit d45d8d7

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

‎.github/copilot-instructions.md‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copilot Instructions
2+
3+
## Project Overview
4+
5+
This is a GitHub Action (`tediousjs/setup-sqlserver`) that installs SQL Server on Windows-based GitHub Action runners. It's built with TypeScript, compiled with `@vercel/ncc`, and runs on Node.js 24.
6+
7+
## Build, Test & Lint
8+
9+
```sh
10+
npm run build # ncc build + auto-generates README usage section from action.yml
11+
npm run test # mocha + ts-node (runs all tests)
12+
npm run test:coverage # tests with nyc coverage
13+
npm run lint # eslint across src/, misc/, test/
14+
npm run lint:fix # eslint with auto-fix
15+
```
16+
17+
Run a single test file:
18+
19+
```sh
20+
npx mocha -r ts-node/register './test/utils.ts'
21+
```
22+
23+
Run a single test by name:
24+
25+
```sh
26+
npx mocha -r ts-node/register './test/**/**.ts' --grep 'correctly returns for windows-2019'
27+
```
28+
29+
The build step (`npm run build`) also runs `npm run docs`, which regenerates the usage section in `README.md` from `action.yml` via `misc/generate-docs.ts`. If you change `action.yml` inputs, rebuild to keep the README in sync.
30+
31+
## Architecture
32+
33+
**Entry point:** `src/main.ts` → calls `install()` from `src/install.ts`, which orchestrates the full flow:
34+
35+
1. Reads action inputs via `gatherInputs()` from `src/utils.ts`
36+
2. Validates OS compatibility using version config from `src/versions.ts`
37+
3. Optionally installs SQL Native Client (`src/install-native-client.ts`) and ODBC driver (`src/install-odbc.ts`)
38+
4. Downloads or cache-hits the SQL Server installer (box+exe or standalone exe)
39+
5. Optionally downloads cumulative updates
40+
6. Runs the installer via `@actions/exec`
41+
7. Waits for the database to be ready (exponential backoff)
42+
43+
**Installer abstraction:** `src/installers/` contains a base `Installer` class and `MsiInstaller` subclass used by the native client and ODBC installations. SQL Server itself uses direct exe/box download logic in `src/utils.ts`.
44+
45+
**Version registry:** `src/versions.ts` defines a `Map<string, VersionConfig>` with download URLs, optional box URLs, update URLs, and OS compatibility constraints for each supported SQL Server version (2008–2022).
46+
47+
**Build output:** `@vercel/ncc` bundles everything into `lib/main/index.js`, which is what `action.yml` references. The `lib/` directory is committed to the repository. **Every commit must include up-to-date build output** — CI checks this by rebuilding and running `git diff-files --quiet`. Always run `npm run build` and commit the resulting changes to `lib/` and `README.md` before pushing.
48+
49+
## Conventions
50+
51+
- **Testing:** Mocha + Chai + Sinon. Tests heavily stub `@actions/*` packages and module-level dependencies using `sinon.stub()`. Each test file mirrors its source file (e.g., `test/install.ts` tests `src/install.ts`).
52+
- **Commit messages:** Follow [Conventional Commits](https://www.conventionalcommits.org/) enforced by commitlint. Semantic-release uses these to generate automated releases and changelogs, so correct commit types are critical.
53+
- `fix` — Bug fixes or behavioural corrections that don't change public interfaces. Triggers a **patch** release.
54+
- `feat` — New backwards-compatible functionality (e.g., adding a new input, method, or option without removing anything). Triggers a **minor** release.
55+
- `feat!` (or any type with `!`) — Breaking changes where consumers would need to update their code (removed/renamed inputs, changed default behaviour). Triggers a **major** release.
56+
- `chore` — Dependency updates, tooling changes, or housekeeping that doesn't affect project code. **Does not trigger a release.**
57+
- `ci` — Changes to CI pipelines or workflow configuration. **Does not trigger a release.**
58+
- `style` — Refactoring or stylistic changes that do not change functionality. **Does not trigger a release.**
59+
- `test` — Changes that only touch test files. **Does not trigger a release.**
60+
- Only `fix` and `feat` trigger releases. If a change doesn't neatly fit `fix` or `feat` but still needs to be released, use whichever is most appropriate to ensure a release is created.
61+
- **Commits and merges:**
62+
- Commits should be atomic and ideally deployable in isolation — all tests, linting, and commitlinting should pass on each individual commit.
63+
- PRs are merged using a **merge commit** (no squash-merge or rebase-merge). Each commit in the PR history is preserved.
64+
- To keep branches up to date with the base branch, **rebase** onto it rather than merging it in.
65+
- All changes must go through a **pull request** — no direct commits to master.
66+
- **Node version:** Pinned to 24 via `.nvmrc`. The action runs using `node24` (set in `action.yml`).
67+
- **Imports:** Use the `type` keyword for type-only imports (e.g., `import type { Foo } from './bar'`). Imports are ordered alphabetically by module path, grouped as: `node:` built-ins first, then external packages, then local file imports.
68+
- **ESLint rules:** Trailing commas required on multiline, semicolons required, no variable shadowing. `@typescript-eslint/no-explicit-any` is disabled in test files.
69+
- **README updates:** The usage block in `README.md` between `<!-- start usage -->` and `<!-- end usage -->` is auto-generated. Edit `action.yml` inputs, not the README directly.
70+
- **Keeping this file up to date:** If a change affects the architecture, conventions, build process, or any other information documented here, update this file as part of the same PR.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This action installs a version of SQL Server on Windows based GitHub Action Runn
77
See [action.yml](./action.yml):
88
<!-- start usage -->
99
```yaml
10-
- uses: tediousjs/setup-sqlserver@v2
10+
- uses: tediousjs/setup-sqlserver@v3
1111
with:
1212
# Skip OS checks that will stop installation attempts preemptively.
1313
# Default: false

0 commit comments

Comments
 (0)