Skip to content

Commit

Permalink
run nuget unit tests separately and report results
Browse files Browse the repository at this point in the history
  • Loading branch information
brettfo committed Apr 24, 2024
1 parent 7fa81c6 commit eb3aa45
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 93 deletions.
52 changes: 32 additions & 20 deletions .github/workflows/ci.yml
Expand Up @@ -14,31 +14,35 @@ concurrency:
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,14 @@ jobs:
--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
uses: dorny/test-reporter@v1
with:
name: NuGet Test Results
path: /home/dependabot/${{ matrix.suite.path }}/helpers/lib/NuGetUpdater/artifacts/test-results/*.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

0 comments on commit eb3aa45

Please sign in to comment.