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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Test runable in VS and runable by any one #45

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/dotnet.main.status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ jobs:
--collect:"XPlat Code Coverage"
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
env:
GitHubActor: ${{ github.repository_owner }}
GitHubAccessToken: ${{ secrets.GITHUBACCESSTOKEN }}

#GitHubTestRepoAddress: "github.com/${{ github.repository }}.Tests.git"
- name: Codecov
# You may pin to the exact commit or the version.
# uses: codecov/codecov-action@fcebab03f26c7530a22baa63f06b3e0515f0c7cd
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ jobs:
--collect:"XPlat Code Coverage"
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
env:
GitHubActor: ${{ github.repository_owner }}
GitHubAccessToken: ${{ secrets.GITHUBACCESSTOKEN }}
#GitHubTestRepoAddress: "github.com/${{ github.repository }}.Tests.git"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,4 @@ MigrationBackup/

# Azure Functions local settings file
local.settings.json
/tst/Integration.Tests/Setup/Local.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public void Handle_WorksAsExpected()
using var repo = new Repository(TestRepoDirectory);
repo.Network.Remotes.Update("origin", updater =>
{
var token = Environment.GetEnvironmentVariable("GitHubAccessToken");
var url = $"https://cbcrouse:{token}@github.com/cbcrouse/Versioning.NET.Tests.git";
var actor = Environment.GetEnvironmentVariable("GitHubActor") ?? EnvironmentVariable.local.GitHubActor;
var token = Environment.GetEnvironmentVariable("GitHubAccessToken") ?? EnvironmentVariable.local.GitHubAccessToken;
var testRepo = Environment.GetEnvironmentVariable("GitHubTestRepoAddress") ?? EnvironmentVariable.local.GitHubTestRepoAddress ?? $"github.com/{actor}/Versioning.NET.Tests.git";
var url = $"https://{actor}:{token}@{testRepo}";
updater.Url = url;
updater.PushUrl = url;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Domain.Entities;
using Infrastructure.Services;
using Integration.Tests.Setup;
using LibGit2Sharp;
using System;
using System.IO;
Expand Down Expand Up @@ -150,8 +151,10 @@ public void CanPushRemoteBranch()
using var repo = new Repository(TestRepoDirectory);
repo.Network.Remotes.Update("origin", updater =>
{
var token = Environment.GetEnvironmentVariable("GitHubAccessToken");
var url = $"https://cbcrouse:{token}@github.com/cbcrouse/Versioning.NET.Tests.git";
var actor = Environment.GetEnvironmentVariable("GitHubActor") ?? EnvironmentVariable.local.GitHubActor;
var token = Environment.GetEnvironmentVariable("GitHubAccessToken") ?? EnvironmentVariable.local.GitHubAccessToken;
var testRepo = Environment.GetEnvironmentVariable("GitHubTestRepoAddress") ?? EnvironmentVariable.local.GitHubTestRepoAddress ?? $"github.com/{actor}/Versioning.NET.Tests.git";
var url = $"https://{actor}:{token}@{testRepo}";
updater.Url = url;
updater.PushUrl = url;
});
Expand Down Expand Up @@ -183,8 +186,10 @@ public void CanPushRemoteTag()
using var repo = new Repository(TestRepoDirectory);
repo.Network.Remotes.Update("origin", updater =>
{
var token = Environment.GetEnvironmentVariable("GitHubAccessToken");
var url = $"https://cbcrouse:{token}@github.com/cbcrouse/Versioning.NET.Tests.git";
var actor = Environment.GetEnvironmentVariable("GitHubActor") ?? EnvironmentVariable.local.GitHubActor;
var token = Environment.GetEnvironmentVariable("GitHubAccessToken") ?? EnvironmentVariable.local.GitHubAccessToken;
var testRepo = Environment.GetEnvironmentVariable("GitHubTestRepoAddress") ?? EnvironmentVariable.local.GitHubTestRepoAddress ?? $"github.com/{actor}/Versioning.NET.Tests.git";
var url = $"https://{actor}:{token}@{testRepo}";
updater.Url = url;
updater.PushUrl = url;
});
Expand Down
17 changes: 17 additions & 0 deletions tst/Integration.Tests/Setup/EnvironmentVariable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Integration.Tests.Setup
{
partial class EnvironmentVariable
{
public static EnvironmentVariable local = new EnvironmentVariable();

public string GitHubActor = null;
public string GitHubAccessToken = null;
public string GitHubTestRepoAddress = null;
}
}
4 changes: 3 additions & 1 deletion tst/Integration.Tests/Setup/GitSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public GitSetup()

private void CloneTestRepository()
{
var actor = Environment.GetEnvironmentVariable("GitHubActor") ?? EnvironmentVariable.local.GitHubActor;
var testRepo = Environment.GetEnvironmentVariable("GitHubTestRepoAddress") ?? EnvironmentVariable.local.GitHubTestRepoAddress ?? $"github.com/{actor}/Versioning.NET.Tests.git";
CreateTempDirectory();
var gitPath = Repository.Clone("https://github.com/cbcrouse/Versioning.NET.Tests", _testRepoParentDirectory);
var gitPath = Repository.Clone($"https://{testRepo}", _testRepoParentDirectory);
TestRepoDirectory = Directory.GetParent(gitPath)!.Parent!.FullName;
}

Expand Down