Skip to content

Commit

Permalink
CodeCov uploading sanity pass
Browse files Browse the repository at this point in the history
- Upgrade action to v4.
- Add ReleaseNotes check to fail job if it doesn't detect the `codecov/project` check on the run in 15 minutes.
- Mark Upload Codecov Job as flaky.
  • Loading branch information
Cyberboss committed Aug 18, 2024
1 parent d82b5b5 commit ec71b37
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ env:
TGS_TEST_GITHUB_TOKEN: ${{ secrets.LIVE_TESTS_TOKEN }}
TGS_RELEASE_NOTES_TOKEN: ${{ secrets.DEV_PUSH_TOKEN }}
PACKAGING_PRIVATE_KEY_PASSPHRASE: ${{ secrets.PACKAGING_PRIVATE_KEY_PASSPHRASE }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

concurrency:
group: "ci-${{ (github.event_name != 'push' && github.event_name != 'schedule' && github.event.inputs.pull_request_number) || github.run_id }}-${{ github.event_name }}"
Expand Down Expand Up @@ -967,7 +966,7 @@ jobs:

upload-code-coverage:
name: Upload Code Coverage
needs: [ linux-unit-tests, linux-integration-tests, windows-unit-tests, windows-integration-tests ]
needs: [ linux-unit-tests, linux-integration-tests, windows-unit-tests, windows-integration-tests, build-releasenotes ]
runs-on: ubuntu-latest
steps:
- name: Checkout (Branch)
Expand Down Expand Up @@ -1214,11 +1213,23 @@ jobs:
name: windows-integration-test-coverage-Release-Advanced-Sqlite
path: ./code_coverage/integration_tests/windows_integration_tests_release_system_sqlite

- name: Retrieve ReleaseNotes Binaries
uses: actions/download-artifact@v4
with:
name: release_notes_bins
path: release_notes_bins

- name: Upload Coverage to CodeCov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
directory: ./code_coverage
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
handle_no_reports_found: true

- name: Wait for CodeCov Status
run: dotnet release_notes_bins/Tgstation.Server.ReleaseNotes --wait-codecov ${{ github.run_id }}

build-deb:
name: Build .deb Package # Can't do i386 due to https://github.com/dotnet/core/issues/4595
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/rerunFlakyTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
const CONSIDERED_JOBS = [
"Windows Live Tests",
"Linux Live Tests",
"Build .deb Package"
"Build .deb Package",
"Upload Code Coverage"
];

async function getFailedJobsForRun(github, context, workflowRunId, runAttempt) {
Expand Down
25 changes: 24 additions & 1 deletion tools/Tgstation.Server.ReleaseNotes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ static async Task<int> Main(string[] args)
var fullNotes = versionString.Equals("--generate-full-notes", StringComparison.OrdinalIgnoreCase);
var nuget = versionString.Equals("--nuget", StringComparison.OrdinalIgnoreCase);
var genToken = versionString.Equals("--token-output-file", StringComparison.OrdinalIgnoreCase);
var waitCodecov = versionString.Equals("--wait-codecov", StringComparison.OrdinalIgnoreCase);

if ((!Version.TryParse(versionString, out var version) || version.Revision != -1)
&& !ensureRelease
&& !linkWinget
&& !shaCheck
&& !fullNotes
&& !nuget
&& !genToken)
&& !genToken
&& !waitCodecov)
{
Console.WriteLine("Invalid version: " + versionString);
return 2;
Expand Down Expand Up @@ -155,6 +157,11 @@ static async Task<int> Main(string[] args)
client.Credentials = new Credentials(githubToken);
}

if (waitCodecov)
{
return await CodecovCheck(client, Int64.Parse(args[1]));
}

if (linkWinget)
{
if (args.Length < 2 || !Uri.TryCreate(args[1], new UriCreationOptions(), out var actionsUrl))
Expand Down Expand Up @@ -1671,5 +1678,21 @@ static void DebugAssert(bool condition, string message = null)
else
Debug.Assert(condition);
}

static async ValueTask<int> CodecovCheck(IGitHubClient client, long runId)
{
var currentRun = await client.Actions.Workflows.Runs.Get(RepoOwner, RepoName, runId);

bool foundRun = false;
for(int i = 0; i < 15 && !foundRun; ++i)
{
var allRuns = await client.Check.Run.GetAllForReference(RepoOwner, RepoName, currentRun.HeadSha);
foundRun = allRuns.CheckRuns.Any(x => x.CheckSuite.Id == currentRun.Id && x.Name == "codecov/project");
if (!foundRun && i != 14)
await Task.Delay(TimeSpan.FromMinutes(1));
}

return foundRun ? 0 : 24398;
}
}
}

0 comments on commit ec71b37

Please sign in to comment.