diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 495d4ca8a0..18c67de3e9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -38,6 +38,7 @@ "ms-toolsai.jupyter", "ms-toolsai.jupyter-keymap", "ms-toolsai.jupyter-renderers", + "ms-vscode.powershell", "ionide.ionide-fsharp" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. @@ -49,7 +50,7 @@ // dotnet dev-certs https --trust; dotnet dev-certs https -ep "$env:USERPROFILE/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere" // * macOS/Linux terminal: // dotnet dev-certs https --trust; dotnet dev-certs https -ep "${HOME}/.aspnet/https/aspnetapp.pfx" -p "SecurePwdGoesHere" - // + // // 2. Uncomment these 'remoteEnv' lines: // "remoteEnv": { // "ASPNETCORE_Kestrel__Certificates__Default__Password": "SecurePwdGoesHere", diff --git a/.devcontainer/workspace.code-workspace b/.devcontainer/workspace.code-workspace index ec36468a84..35a0723b06 100644 --- a/.devcontainer/workspace.code-workspace +++ b/.devcontainer/workspace.code-workspace @@ -1,23 +1,30 @@ { "folders": [ { - "name": "Repo Root", "path": ".." }, { - "name": "NPM Package", - "path": "..\\src\\dotnet-interactive-npm" + "path": "../src/dotnet-interactive-npm" }, { "name": "VS Code - Stable", - "path": "..\\src\\dotnet-interactive-vscode\\stable" + "path": "../src/dotnet-interactive-vscode/stable" }, { "name": "VS Code - Insiders", - "path": "..\\src\\dotnet-interactive-vscode\\insiders" + "path": "../src/dotnet-interactive-vscode/insiders" }, { - "path": "..\\src\\Microsoft.DotNet.Interactive.Js" + "path": "../src/Microsoft.DotNet.Interactive.Js" + }, + { + "path": "../src/Microsoft.DotNet.Interactive.Mermaid.js" + }, + { + "path": "../src/Microsoft.DotNet.Interactive.nteract.js" + }, + { + "path": "../src/Microsoft.DotNet.Interactive.SandDance.js" } ], "settings": {} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4a70812f50..d36602c16b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,8 +24,6 @@ variables: value: $(Build.SourcesDirectory)/artifacts/.trydotnet/packages - name: NodeJSVersion value: '16.13.0' - - name: _TestArgs - value: '' stages: - stage: build @@ -78,10 +76,6 @@ stages: value: Test - name: _BuildArgs value: /p:SignType=$(_SignType) - # SkipTests - # - ${{ if ne(variables['SkipTests'], 'true') }}: - # - name: _TestArgs - # value: -test steps: - script: git config --global core.longpaths true displayName: Enable `git clean` to handle long paths @@ -114,12 +108,17 @@ stages: exit /b 1 displayName: Prevent test directory crawling + - pwsh: | + $testArg = if ($env:SKIPTESTS -ne "true") { "-test" } else { "" } + Write-Host "##vso[task.setvariable variable=_TestArgs]$testArg" + displayName: Promote variables + - script: eng\CIBuild.cmd -configuration $(_BuildConfig) -prepareMachine -sign - $(_TestArgs) $(_BuildArgs) + $(_TestArgs) displayName: Build env: POCKETLOGGER_LOG_PATH: $(PocketLoggerLogPath) @@ -143,40 +142,6 @@ stages: artifactType: container condition: failed() - - script: npm run ciTest - displayName: NPM tests - workingDirectory: "$(Build.SourcesDirectory)/src/Microsoft.DotNet.Interactive.Js" - condition: ne(variables['SkipTests'], 'true') - - # build and test VS Code extension - - script: npm install - displayName: npm install (VS Code stable) - workingDirectory: "$(Build.SourcesDirectory)/src/dotnet-interactive-vscode/stable" - - - script: npm run ciTest - displayName: npm test (VS Code stable) - workingDirectory: "$(Build.SourcesDirectory)/src/dotnet-interactive-vscode/stable" - condition: ne(variables['SkipTests'], 'true') - - - script: npm install - displayName: npm install (VS Code insiders) - workingDirectory: "$(Build.SourcesDirectory)/src/dotnet-interactive-vscode/insiders" - - - script: npm run ciTest - displayName: npm test (VS Code insiders) - workingDirectory: "$(Build.SourcesDirectory)/src/dotnet-interactive-vscode/insiders" - condition: ne(variables['SkipTests'], 'true') - - # build and test npm package - - script: npm install - displayName: npm install (npm package) - workingDirectory: "$(Build.SourcesDirectory)/src/dotnet-interactive-npm" - - - script: npm run ciTest - displayName: npm test (npm package) - workingDirectory: "$(Build.SourcesDirectory)/src/dotnet-interactive-npm" - condition: ne(variables['SkipTests'], 'true') - # publish VS Code and npm test results - task: PublishTestResults@2 displayName: Publish VS Code extension and npm test results @@ -262,10 +227,6 @@ stages: value: Test - name: _BuildArgs value: /p:SignType=$(_SignType) - # SkipTests - # - ${{ if ne(variables['SkipTests'], 'true') }}: - # - name: _TestArgs - # value: --test steps: - script: git config --global core.longpaths true displayName: Enable `git clean` to handle long paths @@ -292,6 +253,11 @@ stages: cp eng/resources/* "$(Build.SourcesDirectory)/artifacts" displayName: Prevent test directory crawling + - pwsh: | + $testArg = if ($env:SKIPTESTS -ne "true") { "--test" } else { "" } + Write-Host "##vso[task.setvariable variable=_TestArgs]$testArg" + displayName: Promote variables + - script: ./eng/cibuild.sh --configuration $(_BuildConfig) --prepareMachine @@ -319,10 +285,14 @@ stages: artifactType: container condition: failed() - - script: npm run ciTest - displayName: NPM tests - workingDirectory: "$(Build.SourcesDirectory)/src/Microsoft.DotNet.Interactive.Js" - condition: ne(variables['SkipTests'], 'true') + # publish VS Code and npm test results + - task: PublishTestResults@2 + displayName: Publish VS Code extension and npm test results + inputs: + testResultsFormat: VSTest + testResultsFiles: '**/*.trx' + searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults' + condition: always() - template: /eng/common/templates/jobs/jobs.yml parameters: diff --git a/build-js.cmd b/build-js.cmd new file mode 100644 index 0000000000..8442a57d8f --- /dev/null +++ b/build-js.cmd @@ -0,0 +1,2 @@ +@echo off +powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0eng\build.ps1" -noDotnet %* diff --git a/build-js.sh b/build-js.sh new file mode 100755 index 0000000000..b0b717d3e8 --- /dev/null +++ b/build-js.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +source="${BASH_SOURCE[0]}" + +# resolve $SOURCE until the file is no longer a symlink +while [[ -h $source ]]; do + scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" + source="$(readlink "$source")" + + # if $source was a relative symlink, we need to resolve it relative to the path where + # the symlink file was located + [[ $source != /* ]] && source="$scriptroot/$source" +done +scriptroot="$( cd -P "$( dirname "$source" )" && pwd)" + +. "$scriptroot/eng/build.sh" --no-dotnet "$@" diff --git a/build.cmd b/build.cmd index 3848dc97c0..4f83f6aede 100644 --- a/build.cmd +++ b/build.cmd @@ -1,2 +1,2 @@ -@echo off +@echo off powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0eng\build.ps1" -build -restore -binaryLog %* diff --git a/eng/build.ps1 b/eng/build.ps1 index 9f7b1de63d..0ef7d9bdb6 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -1,41 +1,15 @@ +[CmdletBinding(PositionalBinding = $false)] +param ( + [switch]$ci, + [switch]$noDotnet, + [switch]$test, + [Parameter(ValueFromRemainingArguments = $true)][String[]]$arguments +) + Set-StrictMode -version 2.0 $ErrorActionPreference = "Stop" -function TestUsingNPM([string] $testPath) { - Write-Host "Installing packages" - Start-Process -PassThru -WindowStyle Hidden -WorkingDirectory $testPath -Wait npm "i" - Write-Host "Testing" - $test = Start-Process -PassThru -WindowStyle Hidden -WorkingDirectory $testPath -Wait npm "run ciTest" - Write-Host "Done with code $($test.ExitCode)" - return $test.ExitCode -} - -$arguments = $args -function isCi { - $isCi = $arguments | Select-String -Pattern '-ci' -CaseSensitive -SimpleMatch - return ($isCi -ne "") -} -$isCi = isCi - -function buildConfiguration { - $release = $arguments | Select-String -Pattern ('release', 'debug') -SimpleMatch -CaseSensitive - if ([System.String]::IsNullOrWhitespace($release) -eq $true) { - return "Debug" - } - else { - return "$release" - } -} -$buildConfiguration = buildConfiguration - try { - # if (isCi -eq $true) { - # . (Join-Path $PSScriptRoot "..\buildSqlTools.cmd") $buildConfiguration - # if ($LASTEXITCODE -ne 0) { - # exit $LASTEXITCODE - # } - # } - $repoRoot = Resolve-Path "$PSScriptRoot\.." $symlinkDirectories = @( "$repoRoot\src\dotnet-interactive-vscode\stable\src\common", @@ -55,10 +29,49 @@ try { } } - # invoke regular build/test script - . (Join-Path $PSScriptRoot "common\build.ps1") -projects "$PSScriptRoot\..\dotnet-interactive.sln" @args - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE + # build and test NPM + $npmDirs = @( + "src\dotnet-interactive-npm", + "src\dotnet-interactive-vscode\stable", + "src\dotnet-interactive-vscode\insiders", + "src\Microsoft.DotNet.Interactive.Js", + "src\Microsoft.DotNet.Interactive.Mermaid.js", + "src\Microsoft.DotNet.Interactive.nteract.js", + "src\Microsoft.DotNet.Interactive.SandDance.js" + ) + foreach ($npmDir in $npmDirs) { + Push-Location "$repoRoot\$npmDir" + Write-Host "Building NPM in directory $npmDir" + npm ci + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + npm run compile + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + if ($test) { + Write-Host "Testing NPM in directory $npmDir" + npm run ciTest + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + } + + Pop-Location + } + + if (-Not $noDotnet) { + # promote switches to arguments + if ($ci) { + $arguments += "-ci" + } + if ($test -And -Not($ci)) { + # CI runs unit tests elsewhere, so only promote the `-test` switch if we're not running CI + $arguments += '-test' + } + + # invoke regular build/test script + $buildScript = (Join-Path $PSScriptRoot "common\build.ps1") + Invoke-Expression "$buildScript -projects ""$PSScriptRoot\..\dotnet-interactive.sln"" $arguments" + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } } } catch { @@ -66,4 +79,4 @@ catch { Write-Host $_.Exception Write-Host $_.ScriptStackTrace exit 1 -} \ No newline at end of file +} diff --git a/eng/build.sh b/eng/build.sh index de38c180b2..6740cf12b5 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e + source="${BASH_SOURCE[0]}" # resolve $source until the file is no longer a symlink @@ -12,28 +14,61 @@ while [[ -h "$source" ]]; do done scriptroot="$( cd -P "$( dirname "$source" )" && pwd )" +# parse args args="" +is_ci=false +no_dotnet=false run_tests=false -# scan for `--test` or `-t` +# scan for `--test` or `--ci` switches while [[ $# > 0 ]]; do opt="$(echo "$1" | awk '{print tolower($0)}')" case "$opt" in + --ci) + is_ci=true + args="$args --ci" + ;; + --no-dotnet) + no_dotnet=true + ;; --test|-t) run_tests=true ;; + *) + args="$args $1" + ;; esac - args="$args $1" shift done -function TestUsingNPM() { - test_path=$1 - pushd "$test_path" - npm i +# build and test NPM +npmDirs='src/dotnet-interactive-npm + src/dotnet-interactive-vscode/stable + src/dotnet-interactive-vscode/insiders + src/Microsoft.DotNet.Interactive.Js + src/Microsoft.DotNet.Interactive.Mermaid.js + src/Microsoft.DotNet.Interactive.nteract.js + src/Microsoft.DotNet.Interactive.SandDance.js' +for npmDir in $npmDirs; +do + echo "Building NPM in directory $npmDir" + pushd $npmDir + npm ci + npm run compile + if [[ "$run_tests" == true ]]; then + echo "Testing NPM in directory $npmDir" npm run ciTest - popd -} + fi + popd +done + +if [[ "$no_dotnet" != true ]]; then + # promote switches to arguments + if [[ "$run_tests" == true ]] && [[ "$is_ci" != true ]]; then + # CI runs unit tests elsewhere, so only promote the `--test` switch if we're not running CI + args="$args --test" + fi -# invoke regular build/test script -. "$scriptroot/common/build.sh" "/p:Projects=$scriptroot/../dotnet-interactive.sln" $args \ No newline at end of file + # invoke regular build/test script + . "$scriptroot/common/build.sh" "/p:Projects=$scriptroot/../dotnet-interactive.sln" $args +fi diff --git a/eng/cibuild.sh b/eng/cibuild.sh index 290f7ebaa5..b90eb50ed3 100755 --- a/eng/cibuild.sh +++ b/eng/cibuild.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -e + source="${BASH_SOURCE[0]}" # resolve $SOURCE until the file is no longer a symlink diff --git a/eng/common/build.sh b/eng/common/build.sh old mode 100644 new mode 100755 diff --git a/src/Microsoft.DotNet.Interactive.ExtensionLab/Microsoft.DotNet.Interactive.ExtensionLab.csproj b/src/Microsoft.DotNet.Interactive.ExtensionLab/Microsoft.DotNet.Interactive.ExtensionLab.csproj index b2746116e7..3cf8d907d5 100644 --- a/src/Microsoft.DotNet.Interactive.ExtensionLab/Microsoft.DotNet.Interactive.ExtensionLab.csproj +++ b/src/Microsoft.DotNet.Interactive.ExtensionLab/Microsoft.DotNet.Interactive.ExtensionLab.csproj @@ -15,8 +15,6 @@ true - - @@ -28,13 +26,8 @@ $(MSBuildThisFileDirectory)/../Microsoft.DotNet.Interactive.nteract.js/ - + - - - - - @@ -50,16 +43,9 @@ - - - - - - - @@ -69,18 +55,12 @@ - - - - - - @@ -107,22 +87,4 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/Microsoft.DotNet.Interactive.Js/package.json b/src/Microsoft.DotNet.Interactive.Js/package.json index 19e6b923d4..a8275d37c0 100644 --- a/src/Microsoft.DotNet.Interactive.Js/package.json +++ b/src/Microsoft.DotNet.Interactive.Js/package.json @@ -6,12 +6,12 @@ "dist" ], "scripts": { - "build": "npm run rollup-dotnet-interactive && npm run rollup-dotnet-interactive-vscode", - "build-ci": "rollup -c rollup.config.js", + "compile": "npm run rollup-dotnet-interactive && npm run rollup-dotnet-interactive-vscode", + "compile-ci": "rollup -c rollup.config.js", "test": "mocha tests/**/*.test.ts", "ciTest": "npm test -- --reporter mocha-multi-reporters --reporter-options configFile=testConfig.json", - "rollup-dotnet-interactive": "npm run build-ci -- -i src/dotnet-interactive.ts -o dist/dotnet-interactive.js", - "rollup-dotnet-interactive-vscode": "npm run build-ci -- -i src/dotnet-interactive-vscode.ts -o dist/dotnet-interactive-vscode.js", + "rollup-dotnet-interactive": "npm run compile-ci -- -i src/dotnet-interactive.ts -o dist/dotnet-interactive.js", + "rollup-dotnet-interactive-vscode": "npm run compile-ci -- -i src/dotnet-interactive-vscode.ts -o dist/dotnet-interactive-vscode.js", "watch": "tsc -watch -p ./" }, "repository": { @@ -71,4 +71,4 @@ "tests/**/*.test.ts" ] } -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Interactive.Mermaid.js/package.json b/src/Microsoft.DotNet.Interactive.Mermaid.js/package.json index 9036e90f9f..2b8149cd32 100644 --- a/src/Microsoft.DotNet.Interactive.Mermaid.js/package.json +++ b/src/Microsoft.DotNet.Interactive.Mermaid.js/package.json @@ -17,6 +17,7 @@ "webpack-cli": "4.6.0" }, "scripts": { - "build": "webpack-cli --mode=production" + "compile": "webpack-cli --mode=production", + "ciTest": "echo \"nothing to do\" && exit 0" } -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Interactive.SandDance.js/package.json b/src/Microsoft.DotNet.Interactive.SandDance.js/package.json index 8a30ba78aa..3450d88d2b 100644 --- a/src/Microsoft.DotNet.Interactive.SandDance.js/package.json +++ b/src/Microsoft.DotNet.Interactive.SandDance.js/package.json @@ -10,11 +10,12 @@ "css/*.css" ], "scripts": { - "build:lib": "tsc", - "build:extension": "webpack", - "build": "npm run build:extension", + "compile:lib": "tsc", + "compile:extension": "webpack", + "compile": "npm run compile:extension", "clean:lib": "rimraf lib", - "prepack": "npm run build:lib" + "prepack": "npm run compile:lib", + "ciTest": "echo \"nothing to do\" && exit 0" }, "repository": { "type": "git", @@ -77,4 +78,4 @@ "tests/**/*.spec.ts" ] } -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Interactive.nteract.js/package.json b/src/Microsoft.DotNet.Interactive.nteract.js/package.json index c3a0d72077..88dd4b4794 100644 --- a/src/Microsoft.DotNet.Interactive.nteract.js/package.json +++ b/src/Microsoft.DotNet.Interactive.nteract.js/package.json @@ -10,12 +10,13 @@ "css/*.css" ], "scripts": { - "build:lib": "tsc", - "build:extension": "webpack-cli --mode=production", - "build": "npm run build:extension", + "compile:lib": "tsc", + "compile:extension": "webpack-cli --mode=production", + "compile": "npm run compile:extension", "clean:lib": "rimraf lib", - "prepack": "npm run build:lib", - "test": "echo \"Error: no test specified\" && exit 1" + "prepack": "npm run compile:lib", + "test": "echo \"Error: no test specified\" && exit 1", + "ciTest": "echo \"nothing to do\" && exit 0" }, "repository": { "type": "git", @@ -53,4 +54,4 @@ "webpack": "5.62.1", "webpack-cli": "4.9.1" } -} +} \ No newline at end of file diff --git a/src/dotnet-interactive/dotnet-interactive.csproj b/src/dotnet-interactive/dotnet-interactive.csproj index 6f59b8c713..307ab148e8 100644 --- a/src/dotnet-interactive/dotnet-interactive.csproj +++ b/src/dotnet-interactive/dotnet-interactive.csproj @@ -119,11 +119,6 @@ - - - - - @@ -146,14 +141,6 @@ - - - - - - - -