Skip to content

Commit 8670c5a

Browse files
authored
Merge pull request #7010 from dotnet/dev/dibarbet/run_tests_docker
Test more versions of .NET using docker containers
2 parents b26af96 + a8506ac commit 8670c5a

File tree

8 files changed

+136
-75
lines changed

8 files changed

+136
-75
lines changed

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!--
4+
Defines the lowest supported target framework for the extension.
5+
Used by server download / integration tests to ensure they run when only this SDK is installed.
6+
-->
7+
<LowestSupportedTargetFramework>net6.0</LowestSupportedTargetFramework>
8+
</PropertyGroup>
9+
</Project>

azure-pipelines.yml

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,58 @@ stages:
1818
parameters:
1919
isOfficial: false
2020

21-
- stage: Test
22-
displayName: Test
21+
- stage: Test_Linux_Stage
22+
displayName: Test Linux
2323
dependsOn: []
2424
jobs:
25-
- template: azure-pipelines/test.yml
26-
parameters:
27-
jobName: Linux
28-
poolName: NetCore-Public
29-
demandsName: 1es-ubuntu-2004-open
25+
- job: Test_Linux_Job
26+
displayName: Test Linux
27+
strategy:
28+
matrix:
29+
DotNet6:
30+
containerName: mcr.microsoft.com/dotnet/sdk:6.0
31+
DotNet7:
32+
containerName: mcr.microsoft.com/dotnet/sdk:7.0
33+
DotNet8:
34+
containerName: mcr.microsoft.com/dotnet/sdk:8.0
35+
pool:
36+
name: NetCore-Public
37+
demands: ImageOverride -equals 1es-ubuntu-2004-open
38+
container: $[ variables['containerName'] ]
39+
steps:
40+
- template: azure-pipelines/test.yml
41+
parameters:
42+
# Prefer the dotnet from the container.
43+
installDotNet: false
44+
installAdditionalLinuxDependencies: true
3045

31-
- template: azure-pipelines/test.yml
32-
parameters:
33-
jobName: Windows
34-
poolName: NetCore-Public
35-
demandsName: 1es-windows-2022-open
46+
- stage: Test_Windows_Stage
47+
displayName: Test Windows
48+
dependsOn: []
49+
jobs:
50+
- job: Test_Windows_Job
51+
displayName: Test Windows
52+
pool:
53+
name: NetCore-Public
54+
demands: ImageOverride -equals 1es-windows-2022-open
55+
steps:
56+
- template: azure-pipelines/test.yml
57+
parameters:
58+
installDotNet: true
3659

37-
- template: azure-pipelines/test.yml
38-
parameters:
39-
jobName: MacOS
40-
poolName: Azure Pipelines
41-
vmImageName: macOS-13
60+
- stage: Test_MacOS_Stage
61+
displayName: Test MacOS
62+
dependsOn: []
63+
jobs:
64+
- job: Test_MacOS_Job
65+
displayName: Test MacOS
66+
pool:
67+
name: Azure Pipelines
68+
vmImage: macOS-13
69+
steps:
70+
- template: azure-pipelines/test.yml
71+
parameters:
72+
installDotNet: true
4273

4374
- stage: Test_OmniSharp
4475
displayName: Test OmniSharp

azure-pipelines/prereqs.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ parameters:
22
- name: versionNumberOverride
33
type: string
44
default: 'default'
5+
- name: installDotNet
6+
type: boolean
7+
default: true
58

69
steps:
710

@@ -13,13 +16,18 @@ steps:
1316
inputs:
1417
versionSpec: '18.x'
1518

16-
- task: UseDotNet@2
17-
displayName: 'Install .NET Core SDKs'
18-
inputs:
19-
version: '8.x'
19+
# Some tests use predefined docker images with a specific version of .NET installed.
20+
# So we avoid installing .NET in those cases.
21+
- ${{ if eq(parameters.installDotNet, true) }}:
22+
- task: UseDotNet@2
23+
displayName: 'Install .NET Core SDKs'
24+
inputs:
25+
version: '8.x'
2026

21-
- script: |
22-
dotnet tool install --tool-path $(Agent.BuildDirectory) nbgv
27+
- script: dotnet --info
28+
displayName: Display dotnet info
29+
30+
- script: dotnet tool install --tool-path $(Agent.BuildDirectory) nbgv
2331
displayName: Install nbgv
2432

2533
# If we want to override the version, update the version.json here - vsix packaging will see this value
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
steps:
2+
- script: echo "##vso[task.setvariable variable=containerId;]$(docker ps --latest --quiet)"
3+
displayName: Set containerId variable
4+
target: host
5+
condition: eq(variables['Agent.OS'], 'Linux')
6+
7+
- script: echo "containerId is $(containerId)"
8+
displayName: Read containerId variable
9+
target: host
10+
condition: eq(variables['Agent.OS'], 'Linux')
11+
12+
# The docker containers we use for linux require some additional dependencies to run VSCode.
13+
# Installing the dependencies requires root, but the docker image we're using doesn't have root permissions (nor sudo)
14+
# We can exec as root from outside the container from the host machine.
15+
# Really we should create our own image with these pre-installed, but we'll need to figure out how to publish the image.
16+
- script: docker exec --user root $(containerId) bash -c 'apt-get update -y && apt-get install -y libglib2.0-0 libnss3 libatk-bridge2.0-dev libdrm2 libgtk-3-0 libgbm-dev libasound2 xvfb'
17+
displayName: 'Install additional Linux dependencies'
18+
target: host
19+
condition: eq(variables['Agent.OS'], 'Linux')

azure-pipelines/test.yml

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
11
parameters:
2-
- name: jobName
3-
type: string
4-
- name: poolName
5-
type: string
6-
- name: demandsName
7-
type: string
8-
default: ''
9-
- name: vmImageName
10-
type: string
11-
default: ''
2+
- name: installDotNet
3+
type: boolean
4+
- name: installAdditionalLinuxDependencies
5+
type: boolean
6+
default: false
127

13-
jobs:
14-
- job: Test_${{ parameters.jobName }}
15-
displayName: 'Test ${{ parameters.jobName }}'
16-
pool:
17-
${{ if ne(parameters.poolName, '') }}:
18-
name: ${{ parameters.poolName }}
19-
${{ if ne(parameters.demandsName, '') }}:
20-
demands: ImageOverride -equals ${{ parameters.demandsName }}
21-
${{ if ne(parameters.vmImageName, '') }}:
22-
vmImage: ${{ parameters.vmImageName }}
23-
steps:
24-
- checkout: self
25-
clean: true
26-
submodules: true
27-
fetchTags: false
28-
fetchDepth: 1
8+
steps:
9+
- checkout: self
10+
clean: true
11+
submodules: true
12+
fetchTags: false
13+
fetchDepth: 1
2914

30-
- template: prereqs.yml
15+
- template: prereqs.yml
16+
parameters:
17+
installDotNet: ${{ parameters.installDotNet }}
3118

32-
- template: test-prereqs.yml
19+
- ${{ if eq(parameters.installAdditionalLinuxDependencies, true) }}:
20+
- template: test-linux-docker-prereqs.yml
3321

34-
- script: npm run test
35-
displayName: 🧪 Run unit and integration tests
36-
env:
37-
DISPLAY: :99.0
22+
- template: test-prereqs.yml
23+
parameters:
24+
installAdditionalLinuxDependencies: ${{ parameters.installAdditionalLinuxDependencies }}
3825

39-
- task: PublishTestResults@2
40-
condition: succeededOrFailed()
41-
displayName: 'Publish Test Results'
42-
inputs:
43-
testResultsFormat: 'JUnit'
44-
testResultsFiles: '*junit.xml'
45-
searchFolder: '$(Build.SourcesDirectory)/out'
46-
publishRunAttachments: true
47-
mergeTestResults: true
48-
testRunTitle: $(Agent.JobName) (Attempt $(System.JobAttempt))
26+
- script: npm run test
27+
displayName: 🧪 Run unit and integration tests
28+
env:
29+
DISPLAY: :99.0
4930

50-
- task: PublishPipelineArtifact@1
51-
condition: failed()
52-
displayName: 'Upload integration test logs'
53-
inputs:
54-
targetPath: '$(Build.SourcesDirectory)/.vscode-test/user-data/logs'
55-
artifactName: 'VSCode Test Logs ($(Agent.JobName)-$(System.JobAttempt))'
31+
- task: PublishTestResults@2
32+
condition: succeededOrFailed()
33+
displayName: 'Publish Test Results'
34+
inputs:
35+
testResultsFormat: 'JUnit'
36+
testResultsFiles: '*junit.xml'
37+
searchFolder: '$(Build.SourcesDirectory)/out'
38+
publishRunAttachments: true
39+
mergeTestResults: true
40+
testRunTitle: $(Agent.JobName) (Attempt $(System.JobAttempt))
41+
42+
- task: PublishPipelineArtifact@1
43+
condition: failed()
44+
displayName: 'Upload integration test logs'
45+
inputs:
46+
targetPath: '$(Build.SourcesDirectory)/.vscode-test/user-data/logs'
47+
artifactName: 'VSCode Test Logs ($(Agent.JobName)-$(System.JobAttempt))'

server/ServerDownload.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<RestorePackagesPath>../out/.nuget/</RestorePackagesPath>
1212
<!-- It's still PackageReference, so project intermediates are still created. -->
1313
<MSBuildProjectExtensionsPath>$(RestorePackagesPath)obj/</MSBuildProjectExtensionsPath>
14-
<!-- This is not super relevant, as long as your SDK version supports it. -->
15-
<TargetFramework>net8.0</TargetFramework>
14+
<!-- We use the lowest supported target framework so we can build and run integration tests against the lowest supported target framework -->
15+
<TargetFramework>$(LowestSupportedTargetFramework)</TargetFramework>
1616
<!-- If a package is resolved to a fallback folder, it may not be downloaded.-->
1717
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
1818
<!-- We don't want to build this project, so we do not need the reference assemblies for the framework we chose.-->

test/integrationTests/testAssets/slnWithCsproj/src/app/app.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</ItemGroup>
55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
7-
<TargetFramework>net5.0</TargetFramework>
7+
<TargetFramework>$(LowestSupportedTargetFramework)</TargetFramework>
88
</PropertyGroup>
99

1010
</Project>

test/integrationTests/testAssets/slnWithCsproj/test/test.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>$(LowestSupportedTargetFramework)</TargetFramework>
55
<Nullable>enable</Nullable>
66

77
<IsPackable>false</IsPackable>
88
<IsTestProject>true</IsTestProject>
9+
<!-- Allow tests to execute against higher runtimes in integration tests -->
10+
<RollForward>Major</RollForward>
911
</PropertyGroup>
1012

1113
<ItemGroup>

0 commit comments

Comments
 (0)