Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Failed to fetch local disk feature on Windows" #333

Merged
merged 8 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
62 changes: 62 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test (Windows)

defaults:
run:
shell: bash

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
jobs:
tests-matrix:
name: Tests Matrix (Windows)
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
mocha-args-windows: [
# "src/test/cli.build.test.ts",
# "src/test/cli.exec.buildKit.1.test.ts",
# "src/test/cli.exec.buildKit.2.test.ts",
# "src/test/cli.exec.nonBuildKit.1.test.ts",
# "src/test/cli.exec.nonBuildKit.2.test.ts",
# "src/test/cli.test.ts",
# "src/test/cli.up.test.ts",
"src/test/container-features/containerFeaturesOCI.test.ts",
# "src/test/container-features/containerFeaturesOCIPush.test.ts",
# "src/test/container-features/containerFeaturesOrder.test.ts",
# "src/test/container-features/e2e.test.ts",
# "src/test/container-features/featureHelpers.test.ts",
# "src/test/container-features/featuresCLICommands.test.ts",
"src/test/container-features/generateFeaturesConfig.test.ts",
# "src/test/container-templates/containerTemplatesOCI.test.ts",
# "src/test/container-templates/templatesCLICommands.test.ts",
# "src/test/dockerComposeUtils.test.ts",
# "src/test/dockerfileUtils.test.ts",
# "src/test/dockerUtils.test.ts",
# "src/test/imageMetadata.test.ts",
# "src/test/variableSubstitution.test.ts",
# # Run all except the above:
# "--exclude .....",
]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@microsoft'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Type-Check
run: yarn type-check
- name: Package
run: yarn package
- name: Run Tests
run: yarn test-matrix --forbid-only ${{ matrix.mocha-args-windows }}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@types/recursive-readdir": "^2.2.1",
"@types/semver": "^7.3.13",
"@types/shell-quote": "^1.7.1",
"@types/shelljs": "^0.8.11",
"@types/tar": "^6.1.3",
"@types/yargs": "^17.0.16",
"@typescript-eslint/eslint-plugin": "^5.45.1",
Expand All @@ -84,6 +85,7 @@
"npm-run-all": "^4.1.5",
"p-all": "^4.0.0",
"rimraf": "^3.0.2",
"shelljs": "^0.8.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"typescript-formatter": "^7.2.2",
Expand Down
24 changes: 20 additions & 4 deletions src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ export interface CollapsedFeaturesConfig {
allFeatures: Feature[];
}

export interface ContainerFeatureInternalParams {
extensionPath: string;
cwd: string;
output: Log;
env: NodeJS.ProcessEnv;
skipFeatureAutoMapping: boolean;
platform: string;
}

export const multiStageBuildExploration = false;

// Counter to ensure that no two folders are the same even if we are executing the same feature multiple times.
Expand Down Expand Up @@ -451,7 +460,7 @@ function updateFromOldProperties<T extends { features: (Feature & { extensions?:

// Generate a base featuresConfig object with the set of locally-cached features,
// as well as downloading and merging in remote feature definitions.
export async function generateFeaturesConfig(params: { extensionPath: string; cwd: string; output: Log; env: NodeJS.ProcessEnv; skipFeatureAutoMapping: boolean }, dstFolder: string, config: DevContainerConfig, getLocalFeaturesFolder: (d: string) => string, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>) {
export async function generateFeaturesConfig(params: ContainerFeatureInternalParams, dstFolder: string, config: DevContainerConfig, getLocalFeaturesFolder: (d: string) => string, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>) {
const { output } = params;

const workspaceRoot = params.cwd;
Expand Down Expand Up @@ -480,7 +489,7 @@ export async function generateFeaturesConfig(params: { extensionPath: string; cw

// Read features and get the type.
output.write('--- Processing User Features ----', LogLevel.Trace);
featuresConfig = await processUserFeatures(params.output, config, workspaceRoot, params.env, userFeatures, featuresConfig, params.skipFeatureAutoMapping);
featuresConfig = await processUserFeatures(params, config, workspaceRoot, userFeatures, featuresConfig);
output.write(JSON.stringify(featuresConfig, null, 4), LogLevel.Trace);

const ociCacheDir = await prepareOCICache(dstFolder);
Expand Down Expand Up @@ -547,9 +556,16 @@ function featuresToArray(config: DevContainerConfig, additionalFeatures: Record<

// Process features contained in devcontainer.json
// Creates one feature set per feature to aid in support of the previous structure.
async function processUserFeatures(output: Log, config: DevContainerConfig, workspaceRoot: string, env: NodeJS.ProcessEnv, userFeatures: DevContainerFeature[], featuresConfig: FeaturesConfig, skipFeatureAutoMapping: boolean): Promise<FeaturesConfig> {
async function processUserFeatures(params: ContainerFeatureInternalParams, config: DevContainerConfig, workspaceRoot: string, userFeatures: DevContainerFeature[], featuresConfig: FeaturesConfig): Promise<FeaturesConfig> {
const { platform, output, skipFeatureAutoMapping, env, } = params;

let configPath = config.configFilePath.path;
if (platform === 'win32' && configPath.startsWith('/')) {
configPath = configPath.substring(1);
}

for (const userFeature of userFeatures) {
const newFeatureSet = await processFeatureIdentifier(output, config.configFilePath.path, workspaceRoot, env, userFeature, skipFeatureAutoMapping);
const newFeatureSet = await processFeatureIdentifier(output, configPath, workspaceRoot, env, userFeature, skipFeatureAutoMapping);
if (!newFeatureSet) {
throw new Error(`Failed to process feature ${userFeature.id}`);
}
Expand Down
3 changes: 2 additions & 1 deletion src/spec-node/containerFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export async function getExtendImageBuildInfo(params: DockerResolverParameters,
await createLocalFeatures(params, dstFolder);

// Processes the user's configuration.
const featuresConfig = await generateFeaturesConfig(params.common, dstFolder, config.config, getContainerFeaturesFolder, additionalFeatures);
const platform = params.common.cliHost.platform;
const featuresConfig = await generateFeaturesConfig({ ...params.common, platform }, dstFolder, config.config, getContainerFeaturesFolder, additionalFeatures);
if (!featuresConfig) {
if (canAddLabelsToContainer && !imageBuildInfo.dockerfile) {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/spec-node/devContainersSpecCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,9 @@ async function readConfiguration({

async function readFeaturesConfig(params: DockerCLIParameters, pkg: PackageConfiguration, config: DevContainerConfig, extensionPath: string, skipFeatureAutoMapping: boolean, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>): Promise<FeaturesConfig | undefined> {
const { cliHost, output } = params;
const { cwd, env } = cliHost;
const { cwd, env, platform } = cliHost;
const featuresTmpFolder = await createFeaturesTempFolder({ cliHost, package: pkg });
return generateFeaturesConfig({ extensionPath, cwd, output, env, skipFeatureAutoMapping }, featuresTmpFolder, config, getContainerFeaturesFolder, additionalFeatures);
return generateFeaturesConfig({ extensionPath, cwd, output, env, skipFeatureAutoMapping, platform }, featuresTmpFolder, config, getContainerFeaturesFolder, additionalFeatures);
}

function execOptions(y: Argv) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { assert } from 'chai';
import { generateFeaturesConfig, getFeatureLayers, FeatureSet, getContainerFeaturesFolder } from '../../spec-configuration/containerFeaturesConfiguration';
import { createPlainLog, LogLevel, makeLog } from '../../spec-utils/log';
import * as path from 'path';
import * as process from 'process';
import { mkdirpLocal } from '../../spec-utils/pfs';
import { DevContainerConfig } from '../../spec-configuration/configuration';
import { URI } from 'vscode-uri';
Expand All @@ -15,7 +16,8 @@ describe('validate generateFeaturesConfig()', function () {

// Setup
const env = { 'SOME_KEY': 'SOME_VAL' };
const params = { extensionPath: '', cwd: '', output, env, persistedFolder: '', skipFeatureAutoMapping: false };
const platform = process.platform;
const params = { extensionPath: '', cwd: '', output, env, persistedFolder: '', skipFeatureAutoMapping: false, platform };

// Mocha executes with the root of the project as the cwd.
const localFeaturesFolder = (_: string) => {
Expand Down
46 changes: 44 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@
dependencies:
"@types/node" "*"

"@types/glob@*":
version "8.0.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-8.0.0.tgz#321607e9cbaec54f687a0792b2d1d370739455d2"
integrity sha512-l6NQsDDyQUVeoTynNpC9uRvCUint/gSUXQA2euwmTuWGvPY5LSDUu6tkCtJB2SvGQlJQzLaKqcGZP4//7EDveA==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"

"@types/js-yaml@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.5.tgz#738dd390a6ecc5442f35e7f03fa1431353f7e138"
Expand All @@ -267,6 +275,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==

"@types/minimatch@*":
version "5.1.2"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca"
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==

"@types/minimatch@^3.0.3":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
Expand Down Expand Up @@ -311,6 +324,14 @@
resolved "https://registry.yarnpkg.com/@types/shell-quote/-/shell-quote-1.7.1.tgz#2d059091214a02c29f003f591032172b2aff77e8"
integrity sha512-SWZ2Nom1pkyXCDohRSrkSKvDh8QOG9RfAsrt5/NsPQC4UQJ55eG0qClA40I+Gkez4KTQ0uDUT8ELRXThf3J5jw==

"@types/shelljs@^0.8.11":
version "0.8.11"
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.11.tgz#17a5696c825974e96828e96e89585d685646fcb8"
integrity sha512-x9yaMvEh5BEaZKeVQC4vp3l+QoFj3BXcd4aYfuKSzIIyihjdVARAadYy3SMNIz0WCCdS2vB9JL/U6GQk5PaxQw==
dependencies:
"@types/glob" "*"
"@types/node" "*"

"@types/tar@^6.1.3":
version "6.1.3"
resolved "https://registry.yarnpkg.com/@types/tar/-/tar-6.1.3.tgz#46a2ce7617950c4852dfd7e9cd41aa8161b9d750"
Expand Down Expand Up @@ -1622,7 +1643,7 @@ glob@7.2.0:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@^7.0.5, glob@^7.1.1, glob@^7.1.3:
glob@^7.0.0, glob@^7.0.5, glob@^7.1.1, glob@^7.1.3:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
Expand Down Expand Up @@ -1844,6 +1865,11 @@ internal-slot@^1.0.3:
has "^1.0.3"
side-channel "^1.0.4"

interpret@^1.0.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==

ip@^1.1.5:
version "1.1.8"
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48"
Expand Down Expand Up @@ -2832,6 +2858,13 @@ readdirp@~3.6.0:
dependencies:
picomatch "^2.2.1"

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
integrity sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==
dependencies:
resolve "^1.1.6"

recursive-readdir@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.3.tgz#e726f328c0d69153bcabd5c322d3195252379372"
Expand Down Expand Up @@ -2907,7 +2940,7 @@ resolve-options@^1.1.0:
dependencies:
value-or-function "^3.0.0"

resolve@^1.10.0:
resolve@^1.1.6, resolve@^1.10.0:
version "1.22.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==
Expand Down Expand Up @@ -3044,6 +3077,15 @@ shell-quote@^1.6.1, shell-quote@^1.7.4:
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.4.tgz#33fe15dee71ab2a81fcbd3a52106c5cfb9fb75d8"
integrity sha512-8o/QEhSSRb1a5i7TFR0iM4G16Z0vYB2OQVs4G3aAFXjn3T6yEx8AZxy1PgDF7I00LZHYA3WxaSYIf5e5sAX8Rw==

shelljs@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c"
integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

side-channel@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
Expand Down