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
2 changes: 1 addition & 1 deletion features/dotnet/Install/Completions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class Completions
private static readonly (string Shell, string Path)[] Targets =
[
("bash", "/usr/share/bash-completion/completions/dotnet"),
("zsh", "/usr/share/zsh/site-functions/_dotnet"),
("zsh", "/usr/local/share/zsh/site-functions/_dotnet"),
("fish", "/usr/share/fish/vendor_completions.d/dotnet.fish"),
];

Expand Down
2 changes: 1 addition & 1 deletion features/dotnet/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"revision": 2,
"revision": 3,
"components": {
"sdk": {
"versions": {
Expand Down
25 changes: 25 additions & 0 deletions scripts/verify/dotnet/lifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createHash } from "node:crypto";
import { cp, mkdir, writeFile } from "node:fs/promises";
import path, { posix } from "node:path";

Expand Down Expand Up @@ -57,6 +58,17 @@ const workspaceAt = (root: string, name: string): Workspace => {
return { path: path.join(root, directory), containerPath: posix.join("/workspaces", directory) };
};

const workspaceImageName = (workspace: Workspace): string => {
const folderHash = createHash("sha256").update(workspace.path).digest("hex");
return `vsc-${path.basename(workspace.path)}-${folderHash}`;
};

const workspaceImages = async (workspace: Workspace): Promise<string[]> => {
const name = workspaceImageName(workspace);
const { stdout } = await $$docker`docker images ${["--format", "{{.Repository}}:{{.Tag}}"]}`;
return stdout.split("\n").filter((tag) => tag.startsWith(name));
};

export const imagesModes = ["build", "pull"] as const;
export type ImagesMode = (typeof imagesModes)[number];

Expand Down Expand Up @@ -151,6 +163,11 @@ const buildContainer = async (workspace: Workspace): Promise<void> => {

const startContainer = async (workspace: Workspace): Promise<void> => {
await project$$`devcontainer up ${["--remove-existing-container", ...["--workspace-folder", workspace.path]]}`;
if ((await workspaceImages(workspace)).length === 0) {
throw new Error(
`devcontainer up ${workspace.path}: no images matching ${workspaceImageName(workspace)}*; the devcontainer CLI folder image naming may have changed`,
);
}
};

const execInContainer = async (workspace: Workspace, command: Command): Promise<CommandResult> => {
Expand Down Expand Up @@ -205,6 +222,13 @@ const removeImage = async (tag: string): Promise<void> => {
await project$$`docker image rm ${tag}`;
};

const removeWorkspaceImages = async (workspace: Workspace): Promise<void> => {
const tags = await workspaceImages(workspace);
if (tags.length > 0) {
await project$$`docker image rm ${tags}`;
}
};

export const lifecycle = {
provision,
buildTestImage,
Expand All @@ -217,4 +241,5 @@ export const lifecycle = {
expectBuildFailure,
removeContainer,
removeImage,
removeWorkspaceImages,
} as const;
13 changes: 10 additions & 3 deletions scripts/verify/dotnet/scenarios.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// spell-checker:ignore compinit
import path from "node:path";

import type { Component } from "@/scripts/tasks/features/dotnet/generateConfig.js";
Expand Down Expand Up @@ -80,7 +81,7 @@ const definitions: Record<ScenarioName, ScenarioDefinition> = {

const completionFiles = [
"/usr/share/bash-completion/completions/dotnet",
"/usr/share/zsh/site-functions/_dotnet",
"/usr/local/share/zsh/site-functions/_dotnet",
"/usr/share/fish/vendor_completions.d/dotnet.fish",
];

Expand All @@ -94,7 +95,7 @@ const completionsAbsent: Exec = {
expect: { stdout: ["absent"] },
};

const completionRegistration: Exec = {
const bashCompletionRegistration: Exec = {
command: [
"bash",
"-lc",
Expand All @@ -103,6 +104,11 @@ const completionRegistration: Exec = {
expect: { stdout: ["complete -F _dotnet dotnet"] },
};

const zshCompletionRegistration: Exec = {
command: ["zsh", "-f", "-c", "autoload -Uz compinit; compinit -D; print -r -- ${_comps[dotnet]:-NONE}"],
expect: { stdout: ["_dotnet"] },
};

const installResidue: Exec = {
command: [
"sh",
Expand Down Expand Up @@ -193,7 +199,8 @@ const sdkBehavior = ({ selection, workspace }: ScenarioContext): ScenarioBehavio
},
},
completionsPresent,
completionRegistration,
bashCompletionRegistration,
zshCompletionRegistration,
installResidue,
tmpPreserved,
],
Expand Down
1 change: 1 addition & 0 deletions scripts/verify/dotnet/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export const verify = async (argv: string[]): Promise<void> => {
console.log(">>> verify dotnet: cleanup");
for (const workspace of workspaces) {
await lifecycle.removeContainer(workspace);
await lifecycle.removeWorkspaceImages(workspace);
}
if (values.rmi) {
for (const image of testImages.values()) {
Expand Down
Loading