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
1 change: 1 addition & 0 deletions .fallout/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"PackVsix",
"PublishVsix",
"RestoreVsix",
"TestVsix",
"VerifyVsixCredentials"
]
},
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ jobs:
fetch-depth: 0
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.head_ref }}
- name: 'Cache: .fallout/temp, ~/.nuget/packages'
- name: 'Cache: .fallout/temp, ~/.nuget/packages, .vscode-test'
uses: actions/cache@v6
with:
path: |
.fallout/temp
~/.nuget/packages
.vscode-test
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Setup: .NET SDK'
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
- name: 'Restore: dotnet tools'
run: dotnet tool restore
- name: 'Run: PackVsix'
run: dotnet fallout PackVsix
- name: 'Run: TestVsix, PackVsix'
run: dotnet fallout TestVsix PackVsix
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ The repo holds three things, and they are easy to confuse:
- **Extension:** TypeScript 5.9 → `tsc` → `out/`. `strict: true`, CommonJS, ES2022. VS Code engine `^1.85.0`. One runtime dependency: `mermaid`.
- **Build:** .NET SDK pinned in `global.json` (`10.0.100`, `rollForward: latestMinor`); Fallout 10.4.0 as the `fallout.globaltool` (`.config/dotnet-tools.json`) and the `Fallout.Common` package reference.
- `nuget.config` clears sources and pins nuget.org only, so a machine-level feed can't shadow the pinned Fallout packages.
- **Tests are two layers** (`npm test` runs both; details in [CONTRIBUTING.md](CONTRIBUTING.md#tests)). **Unit** (`npm run test:unit`, `node:test`, plain Node, ~1s) covers `src/graph.ts`, the vscode-free logic that `src/model.ts` re-exports — keep new logic there, not behind a `vscode` import, so it stays testable. **Extension-host** (`npm run test:integration`, `@vscode/test-cli`) launches a real VS Code on `test/fixtures/workspace` and drives the registered commands; it downloads VS Code on first run and opens a window briefly. Neither runs in CI yet, and the graph webview has no test ([#37](https://github.com/Fallout-build/Fallout.Extensions.VSCode/issues/37)).
- **Tests are four layers** (`npm test` runs unit, webview and extension-host; details in [CONTRIBUTING.md](CONTRIBUTING.md#tests)). **Unit** (`npm run test:unit`, `node:test`, plain Node, ~1s) covers `src/graph.ts`, the vscode-free logic that `src/model.ts` re-exports — keep new logic there, not behind a `vscode` import, so it stays testable. **Webview** (`npm run test:webview`, `playwright-core`) loads the graph page from `src/graphPage.ts` in an installed Chrome or Edge (`PLAYWRIGHT_CHANNEL` overrides) with `acquireVsCodeApi` stubbed — keep the page HTML in that vscode-free file. **Extension-host** (`npm run test:integration`, `@vscode/test-cli`) launches a real VS Code on `test/fixtures/workspace` and drives the registered commands; it downloads VS Code on first run and opens a window briefly. **Contract** (`npm run test:contract`, needs .NET) regenerates the graph with this repo's own build (`dotnet fallout --plan`) and checks the extension's reading of it; `FALLOUT_GRAPH=<path>` points it at another framework version's graph. It is not part of `npm test`. **The PR gate runs all four** (`dotnet fallout TestVsix PackVsix`; the contract check there reuses the graph the run itself emitted, so it skips the regeneration).

## Common commands

```bash
./build.sh # default target: PackVsix (./build.ps1 on Windows)
./build.sh PackVsix # what the PR gate runs -> fallout.vsix
./build.sh TestVsix PackVsix # what the PR gate runs: all test suites, then -> fallout.vsix
./build.sh --plan # what would run, without running it
./build.sh --help # list all targets and parameters

Expand Down Expand Up @@ -87,7 +87,7 @@ Mermaid edge semantics **match the framework's `--plan` HTML** — solid = execu

## Useful pointers

- **`build/Build.cs` is small on purpose.** Reusable target logic belongs in the plugin's components (`IHasVsix` / `IPackVsix` / `IPublishVsix`), which mirror `Fallout.Components`' `IRestore` / `IPack` / `IPublish` — registries declared as data, narrowed per run by a CLI selector, validated up front.
- **`build/Build.cs` is small on purpose.** Reusable target logic belongs in the plugin's components (`IHasVsix` / `IPackVsix` / `ITestVsix` / `IPublishVsix`), which mirror `Fallout.Components`' `IRestore` / `IPack` / `IPublish` — registries declared as data, narrowed per run by a CLI selector, validated up front.
- **`ovsx` ignores `--pre-release` for a prepackaged `.vsix`** (it reads the manifest), and `vsce publish --pre-release` on a `--packagePath` is only an *assertion* against the package. The bit set at package time is what decides.
- **Tool resolution prefers `node_modules/.bin` over `PATH`**, since both CLIs are conventionally dev dependencies. On Windows it must pick the `.cmd` shim — invoking the extensionless script there starts a shell, not the tool.
- **Installing is out of scope by design.** The build packages and publishes; it never touches your editor. A manually installed `.vsix` doesn't auto-update anyway — VS Code only tracks versions for extensions it obtained from a gallery (see [#6](https://github.com/Fallout-build/Fallout.Extensions.VSCode/issues/6)).
Expand Down
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Contributions are welcome. As a community, we want to help each other, provide c

- Branch from `develop`. Name it `feature/<slug>`, `bugfix/<slug>`, `chore/<slug>`, or `docs/<slug>`.
- Make sure your employer allows the contribution.
- Build it the way CI does: `./build.sh PackVsix` (or `./build.ps1 PackVsix` on Windows). The bootstrappers are thin — they provision .NET if needed, run `dotnet tool restore`, then `dotnet fallout "$@"`. The `fallout.globaltool` version is pinned in `.config/dotnet-tools.json`.
- Build it the way CI does: `./build.sh TestVsix PackVsix` (or `./build.ps1 TestVsix PackVsix` on Windows). The bootstrappers are thin — they provision .NET if needed, run `dotnet tool restore`, then `dotnet fallout "$@"`. The `fallout.globaltool` version is pinned in `.config/dotnet-tools.json`.
- **Not running `npm test`** — it must pass, and new logic should come with a test (see [Tests](#tests)). Anything the tests can't reach (the graph webview, terminal runs) still needs F5 in an Extension Development Host or a sideloaded `.vsix`; say in the PR how you verified.

### When writing the PR
Expand Down Expand Up @@ -72,15 +72,19 @@ GitHub can't enforce a method per branch, so this is discipline rather than conf
## Tests

```bash
npm test # unit + extension-host
npm test # unit + webview + extension-host
npm run test:unit # node:test, plain Node, ~1s
npm run test:webview # graph page in Chrome/Edge via Playwright, no VS Code
npm run test:integration # real VS Code (downloaded to .vscode-test/ on first run)
npm run test:contract # needs .NET: regenerates the graph with the real build, then checks it
```

- **Unit** (`test/unit`) covers `src/graph.ts`: graph parsing, discovery, compatibility checks, Mermaid output. Code that must be unit-testable cannot import `vscode` — put it in `graph.ts`; `model.ts` re-exports it.
- **Webview** (`test/webview`) loads the graph page (`src/graphPage.ts`) in an installed Chrome or Edge with `acquireVsCodeApi` stubbed, and checks rendering, edge styles and the `ready` / `graph` / `run` messages. Set `PLAYWRIGHT_CHANNEL` to pick another browser channel.
- **Extension-host** (`test/integration`) activates the extension on `test/fixtures/workspace` and runs the commands for real. It briefly opens a VS Code window.
- **Contract** (`test/contract`) runs `dotnet fallout --plan` so Fallout emits a real `build-graph.json`, then checks the extension's types and assumptions against it. Set `FALLOUT_GRAPH=<path>` to check a graph from another framework version. Not part of `npm test`.
- Fixtures live in `test/fixtures/`. They are not compiled and not shipped (`.vscodeignore`).
- Not covered yet: the graph webview ([#37](https://github.com/Fallout-build/Fallout.Extensions.VSCode/issues/37)). CI does not run the tests yet.
- Not covered: the Run Configuration webview, and terminal runs. The PR gate runs all four suites before packaging, so `./build.sh TestVsix` is the local equivalent.

## Releases

Expand Down
5 changes: 4 additions & 1 deletion build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
// more clever here (negations, directory carve-outs) makes the two sets drift, and a
// gap between them means a PR blocked forever on a required check that never fires.
OnPullRequestExcludePaths = ["**/*.md"],
InvokedTargets = [nameof(IPackVsix.PackVsix)],
// Tests first: a red suite should stop the gate before anything is packaged.
InvokedTargets = [nameof(ITestVsix.TestVsix), nameof(IPackVsix.PackVsix)],
// VS Code (~150 MB) is downloaded once by the extension-host tests; keep it between runs.
CacheIncludePatterns = [".fallout/temp", "~/.nuget/packages", ".vscode-test"],
PublishArtifacts = false)]
partial class Build
{
Expand Down
2 changes: 1 addition & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
// Registry tokens are read from the environment by the CLIs themselves (VSCE_PAT / OVSX_PAT);
// this build never handles them, so they stay out of process argument lists and logs.
partial class Build : FalloutBuild, IPublishVsix
partial class Build : FalloutBuild, IPublishVsix, ITestVsix
{
public static int Main() => Execute<Build>(x => ((IPackVsix)x).PackVsix);

Expand Down
7 changes: 4 additions & 3 deletions docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ The governing principle: **the build is defined in C#, not in YAML.** Every work

| File | Trigger | Does | Generated? |
|---|---|---|---|
| `build.yml` | PR to `develop`, `main`, `support/*` | `PackVsix` — the required check | **Yes**, from `[GitHubActions]` |
| `build.yml` | PR to `develop`, `main`, `support/*` | `TestVsix` then `PackVsix` — the required check | **Yes**, from `[GitHubActions]` |
| `build-skip.yml` | PR touching only `**/*.md` | Nothing; reports the same check | No |
| `nightly.yml` | push to `develop` | Packs, publishes the rolling `nightly` release | No |
| `publish.yml` | `v*` tag push, or dispatch | Packs, releases, optionally promotes to marketplaces | No |

```mermaid
flowchart LR
PR["Pull request"] --> G{"Only<br/>*.md?"}
G -->|No| B["build.yml<br/>PackVsix"]
G -->|No| B["build.yml<br/>TestVsix + PackVsix"]
G -->|Yes| S["build-skip.yml<br/>no-op"]
B --> C(["ubuntu-latest ✓"])
S --> C
Expand Down Expand Up @@ -96,7 +96,7 @@ The promotion jobs publish the exact artifact `pack` produced (`--skip PackVsix`
There is no separate CI script. The runner invokes the same targets you do:

```bash
./build.ps1 PackVsix # what the PR gate runs
./build.ps1 TestVsix PackVsix # what the PR gate runs
dotnet fallout --plan # what would run, without running it
dotnet fallout VerifyVsixCredentials # proves marketplace tokens, publishes nothing
```
Expand All @@ -108,4 +108,5 @@ To run the extension itself rather than the build, see [developing.md](developin
- **`PublicRelease: true`** is set on any job that checks out a tag. A detached HEAD matches none of `version.json`'s branch refspecs, so without it Nerdbank.GitVersioning appends a git-height suffix and the marketplace version stops being a clean triple.
- **`fetch-depth: 0`** is required wherever the version is computed — NB.GV needs full history.
- **Boolean workflow inputs arrive as strings** from the REST API, and therefore from `gh workflow run`. Conditions compare against both `true` and `'true'`; a bare `== true` silently skips while reporting success.
- **The gate runs the tests on the runner's own tools.** `ITestVsix` runs the npm test scripts: unit, webview (the preinstalled Chrome), extension-host (a real VS Code, under `xvfb-run` when there is no display, cached in `.vscode-test`), and the contract check against the graph that run emitted. `test/run-node-tests.js` lists test files explicitly because `node --test <dir|glob>` differs between Node versions and the generated workflow installs none.
- **`--skip PackVsix` prunes the whole upstream chain**, `RestoreVsix` included — nothing else needs it, so Fallout skips it too. The promotion jobs therefore install the Node toolchain themselves: `vsce` and `ovsx` are dev dependencies, and `IHasVsix.ResolveNodeTool` looks in `node_modules/.bin` before `PATH`. Without that step `PublishVsix` fails resolving its tools before it reaches a registry — which is exactly how the first promotion of v10.4.31 failed.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"compile:test": "tsc -p tsconfig.test.json",
"test:unit": "npm run compile:test && node --test \"out-test/test/unit/**/*.test.js\"",
"test:unit": "npm run compile:test && node test/run-node-tests.js out-test/test/unit",
"test:integration": "npm run compile && npm run compile:test && vscode-test",
"test": "npm run test:unit && npm run test:integration"
"test": "npm run test:unit && npm run test:webview && npm run test:integration",
"test:contract": "npm run compile:test && dotnet fallout --plan && node test/run-node-tests.js out-test/test/contract",
"test:webview": "npm run compile:test && node test/run-node-tests.js out-test/test/webview",
"test:contract:check": "npm run compile:test && node test/run-node-tests.js out-test/test/contract"
},
"dependencies": {
"mermaid": "^11.4.1"
Expand All @@ -213,6 +216,7 @@
"@vscode/vsce": "^3.2.0",
"mocha": "^12.0.3",
"ovsx": "^0.10.0",
"playwright-core": "^1.65.1",
"typescript": "^5.9.3"
}
}
54 changes: 54 additions & 0 deletions plugins/Fallout.Vsce/ITestVsix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Collections.Generic;
using System.Linq;
using Fallout.Common;
using Fallout.Common.Tooling;
using Fallout.Common.Utilities;
using static Fallout.Common.Tools.Npm.NpmTasks;

namespace Fallout.Vsce;

/// <summary>
/// Runs a VS Code extension's test suites through its own npm scripts.
/// <para/>
/// As with compilation, the suites stay described in <c>package.json</c>; this component only
/// decides which scripts the build runs, and in what environment. Each script compiles what it
/// needs, so the only prerequisite is the restored toolchain.
/// </summary>
public interface ITestVsix : IPackVsix
{
/// <summary>
/// npm scripts to run, in order. Defaults to the suites that need nothing beyond Node and a
/// browser: unit, webview, extension-host, and the contract check against the graph this
/// very build has just emitted.
/// </summary>
IReadOnlyCollection<string> VsixTestScripts =>
["test:unit", "test:webview", "test:integration", "test:contract:check"];

/// <summary>
/// Scripts that launch a real VS Code and so need a display. On Linux without one, they run
/// under <c>xvfb-run</c>; elsewhere they run as is.
/// </summary>
IReadOnlyCollection<string> VsixDisplayScripts => ["test:integration"];

/// <summary>Runs every script in <see cref="VsixTestScripts"/>, stopping at the first failure.</summary>
Target TestVsix => _ => _
.DependsOn(RestoreVsix)
.Executes(() =>
{
foreach (var script in VsixTestScripts)
{
Serilog.Log.Information("Running npm script {Script}", script);
if (VsixDisplayScripts.Contains(script)
&& EnvironmentInfo.IsLinux
&& EnvironmentInfo.GetVariable("DISPLAY").IsNullOrEmpty())
{
ProcessTasks.StartProcess("xvfb-run", $"-a npm run {script}", VsixDirectory)
.AssertZeroExitCode();
}
else
{
Npm($"run {script}", workingDirectory: VsixDirectory);
}
}
});
}
2 changes: 1 addition & 1 deletion plugins/Fallout.Vsce/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ VsceTasks.VscePackage(_ => _
.EnablePreRelease());
```

**Components** — `IHasVsix`, `IPackVsix`, `IPublishVsix`, mirroring `Fallout.Components`' `IRestore` / `IPack` / `IPublish`. Registries are declared as data and narrowed per run, exactly as `IPublish` does for NuGet feeds:
**Components** — `IHasVsix`, `IPackVsix`, `ITestVsix`, `IPublishVsix`, mirroring `Fallout.Components`' `IRestore` / `IPack` / `IPublish`. Registries are declared as data and narrowed per run, exactly as `IPublish` does for NuGet feeds:

```csharp
class Build : FalloutBuild, IPublishVsix
Expand Down
20 changes: 5 additions & 15 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import { BuildGraph, GraphSource, Relation, Target, checkCompatibility, findGraphFile, loadGraph } from './model';
import { BuildGraph, GraphSource, RELATIONS, Relation, Target, checkCompatibility, findGraphFile, hasRelations, loadGraph, relatedTargets, sortTargets } from './model';
import { GraphPanel } from './graphPanel';
import { goToTarget } from './goToTarget';
import { RunConfigStore, RunConfigViewProvider } from './runConfig';
Expand Down Expand Up @@ -42,7 +42,7 @@ class TargetItem extends vscode.TreeItem {
const lines = [
`**${target.name}**${target.default ? ' _(default target)_' : ''}${target.listed ? '' : ' _(unlisted)_'}`,
target.description ?? undefined,
...(['dependsOn', 'after', 'triggeredBy', 'triggers'] as Relation[])
...RELATIONS
.filter(r => target[r].length > 0)
.map(r => `${RELATION_LABELS[r]}: ${target[r].join(', ')}`),
];
Expand Down Expand Up @@ -73,11 +73,8 @@ class FalloutTargetsProvider implements vscode.TreeDataProvider<TargetItem> {
return this.loadRoots();
}
// Children: one entry per related target, recursively expandable.
return (['dependsOn', 'after', 'triggeredBy', 'triggers'] as Relation[]).flatMap(relation =>
element.target[relation]
.map(name => this.byName.get(name))
.filter((t): t is Target => t !== undefined)
.map(t => new TargetItem(t, relation, this.hasRelations(t))));
return relatedTargets(element.target, this.byName)
.map(({ relation, target }) => new TargetItem(target, relation, hasRelations(target)));
}

private loadRoots(): TargetItem[] {
Expand All @@ -95,14 +92,7 @@ class FalloutTargetsProvider implements vscode.TreeDataProvider<TargetItem> {
}
checkCompatibility(this.graph, this.extensionVersion);
this.byName = new Map(this.graph.targets.map(t => [t.name, t]));
return this.graph.targets
.slice()
.sort((a, b) => Number(b.listed) - Number(a.listed) || a.name.localeCompare(b.name))
.map(t => new TargetItem(t, undefined, this.hasRelations(t)));
}

private hasRelations(target: Target): boolean {
return target.dependsOn.length + target.after.length + target.triggeredBy.length + target.triggers.length > 0;
return sortTargets(this.graph.targets).map(t => new TargetItem(t, undefined, hasRelations(t)));
}
}

Expand Down
Loading
Loading