Skip to content

Commit b458f0f

Browse files
committed
#2254 CoverAlls step workaround
1 parent 042a31f commit b458f0f

File tree

4 files changed

+80
-17
lines changed

4 files changed

+80
-17
lines changed

Diff for: .github/workflows/develop.yml

+57
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,72 @@ jobs:
5656
build-cake:
5757
needs: build
5858
runs-on: ubuntu-latest
59+
environment: build.cake
60+
env:
61+
# https://github.com/actions/setup-dotnet/blob/main/README.md#environment-variables
62+
DOTNET_INSTALL_DIR: "/usr/lib/dotnet" # override /usr/share/dotnet
63+
# NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
5964
steps:
65+
- name: /usr/lib/dotnet
66+
run: |
67+
ls -ld /usr/lib/dotnet
68+
sudo chmod -R 775 /usr/lib/dotnet
69+
sudo chown -R $USER:$USER /usr/lib/dotnet
70+
ls -ld /usr/lib/dotnet
6071
- name: .NET Version
6172
run: dotnet --version
73+
- name: .NET Info
74+
run: dotnet --info
75+
76+
# Installation of .NET 6 is required by the tool "csmacnz.Coveralls"
77+
- name: Check .NET 6
78+
id: check-dotnet6
79+
run: |
80+
DOTNET6_VERSION=$(dotnet --version)
81+
if [[ "$DOTNET6_VERSION" =~ ^6\.0\.[0-9]+$ ]]; then
82+
echo "dotnet6_installed=true" >> $GITHUB_ENV
83+
else
84+
echo "dotnet6_installed=false" >> $GITHUB_ENV
85+
fi
86+
- name: Setup .NET 6
87+
if: env.dotnet6_installed == 'false'
88+
uses: actions/setup-dotnet@v3
89+
with:
90+
dotnet-version: 6.0.x
91+
- name: .NET Info
92+
run: dotnet --info
93+
# END of Installation of .NET 6 is required by the tool "csmacnz.Coveralls"
94+
95+
- name: Check .NET 8
96+
id: check-dotnet8
97+
run: |
98+
DOTNET8_VERSION=$(dotnet --version)
99+
if [[ "$DOTNET8_VERSION" =~ ^8\.0\.[0-9]+$ ]]; then
100+
echo "dotnet8_installed=true" >> $GITHUB_ENV
101+
else
102+
echo "dotnet8_installed=false" >> $GITHUB_ENV
103+
fi
62104
- name: Setup .NET 8
105+
if: env.dotnet8_installed == 'false'
63106
uses: actions/setup-dotnet@v3
64107
with:
65108
dotnet-version: 8.0.x
109+
- name: Check .NET 9
110+
id: check-dotnet9
111+
run: |
112+
DOTNET9_VERSION=$(dotnet --version)
113+
if [[ "$DOTNET9_VERSION" =~ ^9\.0\.[0-9]+$ ]]; then
114+
echo "dotnet9_installed=true" >> $GITHUB_ENV
115+
else
116+
echo "dotnet9_installed=false" >> $GITHUB_ENV
117+
fi
66118
- name: Setup .NET 9
119+
if: env.dotnet9_installed == 'false'
67120
uses: actions/setup-dotnet@v3
68121
with:
69122
dotnet-version: 9.0.x
123+
- name: .NET Info
124+
run: dotnet --info
70125
- name: Branch Name
71126
run: echo "Branch name is ${{ github.ref_name }}"
72127
- name: Checkout
@@ -77,3 +132,5 @@ jobs:
77132
uses: cake-build/cake-action@v3
78133
with:
79134
target: Build
135+
env:
136+
OCELOT_COVERALLS_TOKEN: ${{ secrets.OCELOT_COVERALLS_TOKEN }}

Diff for: .github/workflows/pr.yml

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
build-cake:
2727
needs: build
2828
runs-on: ubuntu-latest
29+
environment: build.cake
2930
steps:
3031
- name: Setup .NET 9
3132
uses: actions/setup-dotnet@v3
@@ -41,3 +42,6 @@ jobs:
4142
uses: cake-build/cake-action@v3
4243
with:
4344
target: PullRequest
45+
env:
46+
OCELOT_COVERALLS_TOKEN: ${{ secrets.OCELOT_COVERALLS_TOKEN }}
47+

Diff for: .github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,4 @@ jobs:
176176
TEMP_KEY: ${{ secrets.TEMP_KEY }}
177177
OCELOT_GITHUB_API_KEY: ${{ secrets.OCELOT_GITHUB_API_KEY }}
178178
OCELOT_NUGET_API_KEY_2025: ${{ secrets.OCELOT_NUGET_API_KEY_2025 }}
179+
OCELOT_COVERALLS_TOKEN: ${{ secrets.OCELOT_COVERALLS_TOKEN }}

Diff for: build.cake

+18-17
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ var artifactsDir = Directory("artifacts"); // build artifacts
2727
var artifactsForUnitTestsDir = artifactsDir + Directory("UnitTests");
2828
var unitTestAssemblies = @"./test/Ocelot.UnitTests/Ocelot.UnitTests.csproj";
2929
var minCodeCoverage = 0.80d;
30-
var coverallsRepoToken = "OCELOT_COVERALLS_TOKEN";
3130
var coverallsRepo = "https://coveralls.io/github/ThreeMammals/Ocelot";
3231

3332
// acceptance testing
@@ -515,27 +514,30 @@ Task("UnitTests")
515514
Information("#=============================");
516515
if (IsRunningInCICD() && IsMainOrDevelop())
517516
{
518-
var repoToken = EnvironmentVariable(coverallsRepoToken);
517+
var repoToken = EnvironmentVariable("OCELOT_COVERALLS_TOKEN");
519518
if (string.IsNullOrEmpty(repoToken))
520519
{
521-
var err = $"# Coveralls repo token not found. Set environment variable: {coverallsRepoToken} !!!";
520+
var err = "# Coveralls repo token was not found! Set environment variable: OCELOT_COVERALLS_TOKEN !";
522521
Warning(err);
523522
throw new Exception(err);
524523
}
525-
else
524+
Information($"# Uploading test coverage to {coverallsRepo}");
525+
var gitHEAD = string.Join(string.Empty, GitHelper("rev-parse HEAD")); // git rev-parse HEAD
526+
Information($"# HEAD commit is {gitHEAD}");
527+
// git log -1 --pretty=format:'%an <%ae>'
528+
var gitAuthor = string.Join(string.Empty, GitHelper("log -1 --pretty=format:%an"));
529+
var gitEmail = string.Join(string.Empty, GitHelper("log -1 --pretty=format:%ae"));
530+
var gitBranch = GetGitBranch();
531+
var gitMessage = string.Join(string.Empty, GitHelper("log -1 --pretty=format:%s"));
532+
CoverallsNet(coverageSummaryFile, CoverallsNetReportType.OpenCover, new CoverallsNetSettings()
526533
{
527-
Information($"# Uploading test coverage to {coverallsRepo}");
528-
// CoverallsNet(coverageSummaryFile, CoverallsNetReportType.OpenCover, new CoverallsNetSettings()
529-
// {
530-
// RepoToken = repoToken
531-
// });
532-
Warning($@"# Uploading is disabled due to the following reasons:
533-
# - App: /root/project/tools/csmacnz.Coveralls
534-
# - Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
535-
# Upgrading csmacnz.Coveralls package to .NET 8-9 is required!!!
536-
# Repo: https://github.com/csmacnz/coveralls.net
537-
# Coveralls Language Integrations > .Net : https://docs.coveralls.io/dot-net");
538-
}
534+
RepoToken = repoToken,
535+
CommitAuthor = gitAuthor,
536+
CommitBranch = gitBranch,
537+
CommitEmail = gitEmail,
538+
CommitId = gitHEAD,
539+
CommitMessage = gitMessage,
540+
});
539541
}
540542
else
541543
{
@@ -545,7 +547,6 @@ Task("UnitTests")
545547
var sequenceCoverage = XmlPeek(coverageSummaryFile, "//coverage/@line-rate");
546548
var branchCoverage = XmlPeek(coverageSummaryFile, "//coverage/@line-rate");
547549
Information("# Sequence Coverage: " + sequenceCoverage);
548-
549550
if (double.Parse(sequenceCoverage) < minCodeCoverage)
550551
{
551552
var whereToCheck = !IsRunningInCICD() ? coverallsRepo : artifactsForUnitTestsDir;

0 commit comments

Comments
 (0)