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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

run nuget unit tests separately and report results #9606

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 34 additions & 20 deletions .github/workflows/ci.yml
Expand Up @@ -14,31 +14,35 @@
jobs:
ci:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
checks: write
strategy:
fail-fast: false
matrix:
suite:
- { path: bundler, name: bundler1, ecosystem: bundler }
- { path: bundler, name: bundler2, ecosystem: bundler }
- { path: cargo, name: cargo, ecosystem: cargo }
- { path: common, name: common, ecosystem: common}
- { path: composer, name: composer, ecosystem: composer }
- { path: docker, name: docker, ecosystem: docker }
- { path: elm, name: elm, ecosystem: elm }
- { path: git_submodules, name: git_submodules, ecosystem: gitsubmodule }
- { path: github_actions, name: github_actions, ecosystem: github-actions }
- { path: go_modules, name: go_module, ecosystem: gomod }
- { path: gradle, name: gradle, ecosystem: gradle }
- { path: hex, name: hex, ecosystem: mix }
- { path: maven, name: maven, ecosystem: maven }
- { path: npm_and_yarn, name: npm_and_yarn, ecosystem: npm }
# - { path: bundler, name: bundler1, ecosystem: bundler }
# - { path: bundler, name: bundler2, ecosystem: bundler }
# - { path: cargo, name: cargo, ecosystem: cargo }
# - { path: common, name: common, ecosystem: common}
# - { path: composer, name: composer, ecosystem: composer }
# - { path: docker, name: docker, ecosystem: docker }
# - { path: elm, name: elm, ecosystem: elm }
# - { path: git_submodules, name: git_submodules, ecosystem: gitsubmodule }
# - { path: github_actions, name: github_actions, ecosystem: github-actions }
# - { path: go_modules, name: go_module, ecosystem: gomod }
# - { path: gradle, name: gradle, ecosystem: gradle }
# - { path: hex, name: hex, ecosystem: mix }
# - { path: maven, name: maven, ecosystem: maven }
# - { path: npm_and_yarn, name: npm_and_yarn, ecosystem: npm }
- { path: nuget, name: nuget, ecosystem: nuget }
- { path: pub, name: pub, ecosystem: pub }
- { path: python, name: python, ecosystem: pip }
- { path: python, name: python_slow, ecosystem: pip }
- { path: swift, name: swift, ecosystem: swift }
- { path: devcontainers, name: devcontainers, ecosystem: devcontainers }
- { path: terraform, name: terraform, ecosystem: terraform }
# - { path: pub, name: pub, ecosystem: pub }
# - { path: python, name: python, ecosystem: pip }
# - { path: python, name: python_slow, ecosystem: pip }
# - { path: swift, name: swift, ecosystem: swift }
# - { path: devcontainers, name: devcontainers, ecosystem: devcontainers }
# - { path: terraform, name: terraform, ecosystem: terraform }

steps:
- name: Checkout code
Expand Down Expand Up @@ -67,6 +71,16 @@
--rm ghcr.io/dependabot/dependabot-updater-${{ matrix.suite.ecosystem }} bash -c \
"cd /home/dependabot/${{ matrix.suite.path }} && ./script/ci-test"

- name: Report test results
#if: ${{ matrix.suite.name == "nuget" && (success() || failure()) }}

Check warning on line 75 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / Lint

75:10 [comments] missing starting space in comment
# /home/dependabot/nuget/helpers/lib/NuGetUpdater/artifacts/test-results/NuGetUpdater.Cli.Test.csproj.trx
# /home/dependabot/nuget/helpers/lib/NuGetUpdater/artifacts/test-results/*.trx
uses: dorny/test-reporter@v1
with:
name: NuGet Test Results
path: '**/*.trx'
reporter: dotnet-trx

updater:
env:
DOCKER_BUILDKIT: 1
Expand Down
Expand Up @@ -20,7 +20,7 @@ public Task Compatible(string projectTfms, string packageTfms)
[Theory]
[InlineData("net5.0", "net7.0")]
[InlineData("net5.0 net461", "net7.0 net472")]
[InlineData("net5.0 net45", "netstandard2.0")]
[InlineData("net5.0 net45", "netstandard2.0_brettfo")]
public Task Incompatible(string projectTfms, string packageTfms)
=> Run(projectTfms, packageTfms, expectedExitCode: 1);

Expand Down
30 changes: 27 additions & 3 deletions nuget/script/ci-test
@@ -1,6 +1,30 @@
#!/usr/bin/env bash

set -e
# allow all tests to run, even if some fail
test_status=0

bundle install
bundle exec turbo_tests --verbose
# run Ruby tests
bundle install || test_status=$?
#bundle exec turbo_tests --verbose || test_status=$?

#
# all things dotnet
#
native_updater_dir=~/nuget/helpers/lib/NuGetUpdater

# check dotnet formatting
dotnet format $native_updater_dir --exclude helpers/lib/NuGet.Client --verify-no-changes -v diag || test_status=$?

# run dotnet tests
test_results_dir=$native_updater_dir/artifacts/test-results
mkdir -p $test_results_dir

#dotnet_test_projects='$native_updater_dir/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj
# $native_updater_dir/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj'
dotnet_test_projects=$native_updater_dir/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj
for dotnet_test_project in $dotnet_test_projects; do
test_result_file=$test_results_dir/$(basename $dotnet_test_project).trx
dotnet test --configuration Release --logger "trx;logfilename=$test_result_file" $dotnet_test_project || test_status=$?
done

exit $test_status
69 changes: 0 additions & 69 deletions nuget/spec/dependabot/nuget/native_helpers_spec.rb
Expand Up @@ -55,73 +55,4 @@
end
end
end

describe "#native_csharp_tests" do
let(:command) do
[
"dotnet",
"test",
"--configuration",
"Release",
project_path
].join(" ")
end

subject(:dotnet_test) do
Dependabot::SharedHelpers.run_shell_command(command)
end

context "`dotnet test NuGetUpdater.Core.Test` output" do
let(:project_path) do
File.join(dependabot_home, "nuget", "helpers", "lib", "NuGetUpdater",
"NuGetUpdater.Core.Test", "NuGetUpdater.Core.Test.csproj")
end

it "contains the expected output" do
expect(dotnet_test).to include("Passed!")
end
end

context "`dotnet test NuGetUpdater.Cli.Test` output" do
let(:project_path) do
File.join(dependabot_home, "nuget", "helpers", "lib", "NuGetUpdater",
"NuGetUpdater.Cli.Test", "NuGetUpdater.Cli.Test.csproj")
end

it "contains the expected output" do
expect(dotnet_test).to include("Passed!")
end
end
end

describe "#native_csharp_format" do
let(:command) do
[
"dotnet",
"format",
lib_path,
"--exclude",
except_path,
"--verify-no-changes",
"-v",
"diag"
].join(" ")
end

subject(:dotnet_test) do
Dependabot::SharedHelpers.run_shell_command(command)
end

context "`dotnet format NuGetUpdater` output" do
let(:lib_path) do
File.absolute_path(File.join("helpers", "lib", "NuGetUpdater"))
end

let(:except_path) { "helpers/lib/NuGet.Client" }

it "contains the expected output" do
expect(dotnet_test).to include("Format complete")
end
end
end
end