Skip to content

Commit 223f7f6

Browse files
authored
CSHARP-5788: Replace cake with dotnet cli scripts (#1821)
1 parent deb71af commit 223f7f6

File tree

12 files changed

+101
-116
lines changed

12 files changed

+101
-116
lines changed

build.cake

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -150,43 +150,6 @@ Task("TestSocks5Proxy")
150150
action: (BuildConfig buildConfig, Path testProject) =>
151151
RunTests(buildConfig, testProject, filter: "Category=\"Socks5Proxy\""));
152152

153-
Task("SmokeTests")
154-
.DoesForEach(
155-
GetFiles("./**/SmokeTests/**/*.SmokeTests*.csproj"),
156-
action: (BuildConfig buildConfig, Path testProject) =>
157-
{
158-
var environmentVariables = new Dictionary<string, string>
159-
{
160-
{ "SmokeTestsPackageSha", gitVersion.Sha }
161-
};
162-
163-
var toolSettings = new DotNetToolSettings { EnvironmentVariables = environmentVariables };
164-
165-
Information($"Updating MongoDB package: {buildConfig.PackageVersion} sha: {gitVersion.Sha}");
166-
167-
DotNetTool(
168-
testProject.FullPath,
169-
"add package MongoDB.Driver",
170-
$"--no-restore --version [{buildConfig.PackageVersion}]",
171-
toolSettings);
172-
173-
DotNetTool(
174-
testProject.FullPath,
175-
"add package MongoDB.Driver.Encryption",
176-
$"--no-restore --version [{buildConfig.PackageVersion}]",
177-
toolSettings);
178-
179-
RunTests(
180-
buildConfig,
181-
testProject,
182-
settings =>
183-
{
184-
settings.NoBuild = false;
185-
settings.NoRestore = false;
186-
settings.EnvironmentVariables = environmentVariables;
187-
});
188-
});
189-
190153
Setup<BuildConfig>(
191154
setupContext =>
192155
{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# add/adjust nuget.config pointing to myget so intermediate versions could be restored
4+
if [ -f "./nuget.config" ]; then
5+
echo "Adding myget into nuget.config"
6+
NUGET_SOURCES=$(dotnet nuget list source --format short)
7+
if [[ ${NUGET_SOURCES} != *"https://www.myget.org/F/mongodb/api/v3/index.json"* ]];then
8+
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
9+
fi
10+
else
11+
echo "Creating custom nuget.config"
12+
cat > "nuget.config" << EOL
13+
<?xml version="1.0" encoding="utf-8"?>
14+
<configuration>
15+
<packageSources>
16+
<clear />
17+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
18+
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
19+
</packageSources>
20+
</configuration>
21+
EOL
22+
fi

evergreen/compile-sources.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

4+
SOURCE_PROJECT=${1:-CSharpDriver.sln}
45
if [ -z "$PACKAGE_VERSION" ]; then
56
PACKAGE_VERSION=$(bash ./evergreen/get-version.sh)
67
echo Calculated PACKAGE_VERSION value: "$PACKAGE_VERSION"
@@ -13,7 +14,7 @@ for (( ATTEMPT=1; ATTEMPT<=RESTORE_MAX_RETRIES; ATTEMPT++ ))
1314
do
1415
echo "Attempt $ATTEMPT of $RESTORE_MAX_RETRIES to run dotnet restore..."
1516
exit_status=0
16-
dotnet restore || exit_status=$?
17+
dotnet restore "${SOURCE_PROJECT}" --verbosity normal || exit_status=$?
1718
if [[ "$exit_status" -eq 0 ]]; then
1819
echo "dotnet restore succeeded."
1920
break
@@ -29,4 +30,4 @@ do
2930
sleep $DELAY
3031
done
3132

32-
dotnet build -c Release --no-restore -p:Version="$PACKAGE_VERSION"
33+
dotnet build "${SOURCE_PROJECT}" -c Release --no-restore -p:Version="$PACKAGE_VERSION"

evergreen/evergreen.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -728,17 +728,9 @@ functions:
728728
script: |
729729
set +x
730730
${PREPARE_SHELL}
731-
AUTH=${AUTH} \
732-
SSL=${SSL} \
733731
MONGODB_URI="${MONGODB_URI}" \
734-
TOPOLOGY=${TOPOLOGY} \
735-
OS=${OS} \
736-
COMPRESSOR=${COMPRESSOR} \
737-
CLIENT_PEM=${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem \
738-
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
739-
TARGET="SmokeTests" \
740732
FRAMEWORK=${FRAMEWORK} \
741-
evergreen/run-tests.sh
733+
evergreen/run-smoke-tests.sh "${PACKAGE_VERSION}"
742734
743735
run-test-SK:
744736
- command: shell.exec

evergreen/run-external-script.sh

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,7 @@ echo "Cloning the remote repo..."
1111
git clone -b "${GIT_BRANCH:-main}" --single-branch "${GIT_REPO}" .
1212

1313
# add/adjust nuget.config pointing to myget so intermediate versions could be restored
14-
if [ -f "./nuget.config" ]; then
15-
echo "Adding myget into nuget.config"
16-
NUGET_SOURCES=$(dotnet nuget list source --format short)
17-
if [[ ${NUGET_SOURCES} != *"https://www.myget.org/F/mongodb/api/v3/index.json"* ]];then
18-
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
19-
fi
20-
else
21-
echo "Creating custom nuget.config"
22-
cat > "nuget.config" << EOL
23-
<?xml version="1.0" encoding="utf-8"?>
24-
<configuration>
25-
<packageSources>
26-
<clear />
27-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
28-
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
29-
</packageSources>
30-
</configuration>
31-
EOL
32-
fi
14+
. "${PROJECT_DIRECTORY}/evergreen/append-myget-package-source.sh"
3315

3416
# make files executable
3517
echo "Making files executable"

evergreen/run-smoke-tests.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
SMOKE_TESTS_PROJECT="./tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/MongoDB.Driver.SmokeTests.Sdk.csproj"
4+
5+
DRIVER_PACKAGE_VERSION="$1"
6+
if [ -z "$DRIVER_PACKAGE_VERSION" ]; then
7+
echo "Driver package version should be provided."
8+
exit 1
9+
fi
10+
11+
. ./evergreen/append-myget-package-source.sh
12+
13+
export DRIVER_PACKAGE_VERSION="${DRIVER_PACKAGE_VERSION}"
14+
. ./evergreen/compile-sources.sh "$SMOKE_TESTS_PROJECT"
15+
16+
dotnet test "$SMOKE_TESTS_PROJECT" -c Release --no-build -f "$FRAMEWORK" --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"

evergreen/run-tests.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,6 @@ if [ -f "$DRIVERS_TOOLS/.evergreen/csfle/secrets-export.sh" ]; then
141141
source $DRIVERS_TOOLS/.evergreen/csfle/secrets-export.sh
142142
fi
143143

144-
if [[ "$TARGET" =~ "SmokeTests" ]]; then
145-
# add/adjust nuget.config pointing to myget so intermediate versions could be restored
146-
if [ -f "./nuget.config" ]; then
147-
echo "Adding myget into nuget.config"
148-
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
149-
else
150-
echo "Creating custom nuget.config"
151-
cat > "nuget.config" << EOL
152-
<?xml version="1.0" encoding="utf-8"?>
153-
<configuration>
154-
<packageSources>
155-
<clear />
156-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
157-
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
158-
</packageSources>
159-
</configuration>
160-
EOL
161-
fi
162-
fi
163-
164144
. ./evergreen/compile-sources.sh
165145
if [[ "$OS" =~ Windows|windows ]]; then
166146
powershell.exe .\\build.ps1 --target=$TARGET

tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/InfrastructureUtilities.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
using System.Collections.Generic;
1818
using System.Diagnostics;
1919
using System.Linq;
20-
using FluentAssertions;
2120
using Microsoft.Extensions.Configuration;
2221
using Microsoft.Extensions.DependencyInjection;
2322
using Microsoft.Extensions.Logging;
24-
using MongoDB.Driver.Encryption;
2523

2624
namespace MongoDB.Driver.SmokeTests.Sdk
2725
{
@@ -31,23 +29,6 @@ internal static class InfrastructureUtilities
3129
Environment.GetEnvironmentVariable("MONGO_URI") ??
3230
"mongodb://localhost";
3331

34-
public static void ValidateMongoDBPackageVersion()
35-
{
36-
var packageShaExpected = Environment.GetEnvironmentVariable("SmokeTestsPackageSha");
37-
38-
if (!string.IsNullOrEmpty(packageShaExpected))
39-
{
40-
var driverFileVersionInfo = FileVersionInfo.GetVersionInfo(typeof(MongoClient).Assembly.Location);
41-
var libmongocryptFileVersionInfo = FileVersionInfo.GetVersionInfo(typeof(ClientEncryption).Assembly.Location);
42-
43-
driverFileVersionInfo.ProductVersion?.Contains(packageShaExpected)
44-
.Should().BeTrue("Expected package sha {0} in {1} for driver package version.", packageShaExpected, driverFileVersionInfo.ProductVersion);
45-
46-
libmongocryptFileVersionInfo.ProductVersion?.Contains(packageShaExpected)
47-
.Should().BeTrue("Expected package sha {0} in {1} for libmongocrypt package version.", packageShaExpected, libmongocryptFileVersionInfo.ProductVersion);
48-
}
49-
}
50-
5132
public static void AssertLogs(LogEntry[] expectedLogs, LogEntry[] actualLogs)
5233
{
5334
var actualLogIndex = 0;

tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LibmongocryptTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class LibmongocryptTests
3737

3838
public LibmongocryptTests(ITestOutputHelper output)
3939
{
40-
InfrastructureUtilities.ValidateMongoDBPackageVersion();
4140
MongoClientSettings.Extensions.AddAutoEncryption();
4241
_output = output;
4342
}

tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/LoggingTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public sealed class LoggingTests
3030

3131
public LoggingTests(ITestOutputHelper output)
3232
{
33-
InfrastructureUtilities.ValidateMongoDBPackageVersion();
3433
_output = output;
3534
}
3635

0 commit comments

Comments
 (0)