Skip to content

Commit 7070eff

Browse files
authored
Merge branch 'main' into brianaj/external-pr-1450
2 parents 5656bfb + 314e9ea commit 7070eff

File tree

19 files changed

+363
-29
lines changed

19 files changed

+363
-29
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ jobs:
365365
$TAG_NAME | Out-File ./LATEST-VERSION.txt
366366
367367
- name: Commit Release Notes and Version
368-
uses: stefanzweifel/git-auto-commit-action@v7
368+
uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3
369369
with:
370370
commit_message: Automated commit of archived release notes and version file [skip ci]
371371
file_pattern: RELEASENOTES.md releasenotes/*.md LATEST-VERSION.txt

.github/workflows/publish-test-results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
eventjson=`cat 'artifacts/Event File/event.json'`
3939
prnumber=`echo $(jq -r '.pull_request.number' <<< "$eventjson")`
40-
echo "PR_NUMBER=$(echo $prnumber | tr -cd '[0-9]')" >> $GITHUB_ENV
40+
echo "PR_NUMBER=$(echo $prnumber | tr -cd '0-9')" >> $GITHUB_ENV
4141
4242
- name: Publish Unit Test Results
4343
uses: EnricoMi/publish-unit-test-result-action@v2

LATEST-VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.20.0
1+
v1.22.0

RELEASENOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- bbs2gh : Added validation for `--archive-path` and `--bbs-shared-home` options to fail fast with clear error messages if the provided paths do not exist or are not accessible. Archive path is now logged before upload operations to help with troubleshooting

releasenotes/v1.21.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- **ado2gh**: Added support for GitHub Enterprise cloud with data residency app service connections when using `--rewire-pipelines`. The tool now recognizes both `GitHub` and `GitHubProximaPipelines` service connection types.

releasenotes/v1.22.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added `--migration-id` option to `download-logs` command to allow downloading logs directly by migration ID without requiring org/repo lookup

src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandArgs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public class DownloadLogsCommandArgs : CommandArgs
55
{
66
public string GithubOrg { get; set; }
77
public string GithubRepo { get; set; }
8+
public string MigrationId { get; set; }
89
public string GithubApiUrl { get; set; }
910
[Secret]
1011
public string GithubPat { get; set; }

src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandBase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ public class DownloadLogsCommandBase : CommandBase<DownloadLogsCommandArgs, Down
1818

1919
public virtual Option<string> GithubOrg { get; } = new("--github-org")
2020
{
21-
IsRequired = true,
2221
Description = "GitHub organization to download logs from."
2322
};
2423

2524
public virtual Option<string> GithubRepo { get; } = new("--github-repo")
2625
{
27-
IsRequired = true,
2826
Description = "Target repository to download latest log for."
2927
};
3028

29+
public virtual Option<string> MigrationId { get; } = new("--migration-id")
30+
{
31+
Description = "Migration ID to download logs for. If specified, --github-org and --github-repo are not required."
32+
};
33+
3134
public virtual Option<string> GithubApiUrl { get; } = new("--github-api-url")
3235
{
3336
Description = "Target GitHub API URL if not targeting github.com (default: https://api.github.com)."
@@ -79,6 +82,7 @@ protected void AddOptions()
7982
{
8083
AddOption(GithubOrg);
8184
AddOption(GithubRepo);
85+
AddOption(MigrationId);
8286
AddOption(GithubApiUrl);
8387
AddOption(GithubPat);
8488
AddOption(MigrationLogFile);

src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ public async Task Handle(DownloadLogsCommandArgs args)
3838
throw new ArgumentNullException(nameof(args));
3939
}
4040

41+
if (args.MigrationId.HasValue())
42+
{
43+
if (args.GithubOrg.HasValue() || args.GithubRepo.HasValue())
44+
{
45+
_log.LogWarning("--github-org and --github-repo are ignored when --migration-id is specified.");
46+
}
47+
}
48+
else
49+
{
50+
if (!args.GithubOrg.HasValue() || !args.GithubRepo.HasValue())
51+
{
52+
throw new OctoshiftCliException("Either --migration-id (GraphQL migration ID) or both --github-org and --github-repo must be specified.");
53+
}
54+
}
55+
4156
_log.LogWarning("Migration logs are only available for 24 hours after a migration finishes!");
4257

4358
_log.LogInformation("Downloading migration logs...");
@@ -49,22 +64,52 @@ public async Task Handle(DownloadLogsCommandArgs args)
4964
throw new OctoshiftCliException($"File {args.MigrationLogFile} already exists! Use --overwrite to overwrite this file.");
5065
}
5166

52-
var result = await _retryPolicy.RetryOnResult(async () => await _githubApi.GetMigrationLogUrl(args.GithubOrg, args.GithubRepo), r => r?.MigrationLogUrl.IsNullOrWhiteSpace() ?? false,
53-
"Waiting for migration log to populate...");
67+
string logUrl;
68+
string migrationId;
69+
string repositoryName;
5470

55-
if (result.Outcome == OutcomeType.Successful && result.Result is null)
71+
if (args.MigrationId.HasValue())
5672
{
57-
throw new OctoshiftCliException($"Migration for repository {args.GithubRepo} not found!");
58-
}
73+
// Use migration ID directly
74+
migrationId = args.MigrationId;
75+
var migrationResult = await _retryPolicy.RetryOnResult(
76+
async () => await _githubApi.GetMigration(migrationId),
77+
r => string.IsNullOrWhiteSpace(r.MigrationLogUrl),
78+
"Waiting for migration log to populate...");
79+
80+
if (migrationResult.Outcome == OutcomeType.Failure)
81+
{
82+
throw new OctoshiftCliException($"Migration log for migration {migrationId} is currently unavailable. Migration logs are only available for 24 hours after a migration finishes. Please ensure the migration ID is correct and the migration has completed recently.");
83+
}
5984

60-
if (result.Outcome == OutcomeType.Failure)
61-
{
62-
throw new OctoshiftCliException($"Migration log for repository {args.GithubRepo} unavailable!");
85+
var (_, RepositoryName, _, _, MigrationLogUrl) = migrationResult.Result;
86+
logUrl = MigrationLogUrl;
87+
repositoryName = RepositoryName;
6388
}
89+
else
90+
{
91+
// Use org/repo to find migration
92+
var result = await _retryPolicy.RetryOnResult(async () => await _githubApi.GetMigrationLogUrl(args.GithubOrg, args.GithubRepo), r => r?.MigrationLogUrl.IsNullOrWhiteSpace() ?? false,
93+
"Waiting for migration log to populate...");
94+
95+
if (result.Outcome == OutcomeType.Successful && result.Result is null)
96+
{
97+
throw new OctoshiftCliException($"Migration for repository {args.GithubRepo} not found!");
98+
}
6499

65-
var (logUrl, migrationId) = result.Result.Value;
100+
if (result.Outcome == OutcomeType.Failure)
101+
{
102+
throw new OctoshiftCliException($"Migration log for repository {args.GithubRepo} unavailable!");
103+
}
104+
105+
(logUrl, migrationId) = result.Result.Value;
106+
repositoryName = args.GithubRepo;
107+
}
66108

67-
args.MigrationLogFile ??= $"migration-log-{args.GithubOrg}-{args.GithubRepo}-{migrationId}.log";
109+
var defaultFileName = args.MigrationId.HasValue()
110+
? $"migration-log-{repositoryName}-{migrationId}.log"
111+
: $"migration-log-{args.GithubOrg}-{repositoryName}-{migrationId}.log";
112+
args.MigrationLogFile ??= defaultFileName;
68113

69114
if (FileExists(args.MigrationLogFile))
70115
{
@@ -76,9 +121,9 @@ public async Task Handle(DownloadLogsCommandArgs args)
76121
_log.LogWarning($"Overwriting {args.MigrationLogFile} due to --overwrite option.");
77122
}
78123

79-
_log.LogInformation($"Downloading log for repository {args.GithubRepo} to {args.MigrationLogFile}...");
124+
_log.LogInformation($"Downloading log for repository {repositoryName} to {args.MigrationLogFile}...");
80125
await _httpDownloadService.DownloadToFile(logUrl, args.MigrationLogFile);
81126

82-
_log.LogSuccess($"Downloaded {args.GithubRepo} log to {args.MigrationLogFile}.");
127+
_log.LogSuccess($"Downloaded {repositoryName} log to {args.MigrationLogFile}.");
83128
}
84129
}

src/Octoshift/Services/AdoApi.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ private async Task<string> GetTeamProjectGithubAppId(string org, string githubOr
202202
var url = $"{_adoBaseUrl}/{org.EscapeDataString()}/{teamProject.EscapeDataString()}/_apis/serviceendpoint/endpoints?api-version=6.0-preview.4";
203203
var response = await _client.GetWithPagingAsync(url);
204204

205-
var endpoint = response.FirstOrDefault(x => ((string)x["type"]).Equals("GitHub", StringComparison.OrdinalIgnoreCase) && ((string)x["name"]).Equals(githubOrg, StringComparison.OrdinalIgnoreCase));
205+
var endpoint = response.FirstOrDefault(x =>
206+
(((string)x["type"]).Equals("GitHub", StringComparison.OrdinalIgnoreCase) ||
207+
((string)x["type"]).Equals("GitHubProximaPipelines", StringComparison.OrdinalIgnoreCase)) &&
208+
((string)x["name"]).Equals(githubOrg, StringComparison.OrdinalIgnoreCase));
206209

207210
return endpoint != null ? (string)endpoint["id"] : null;
208211
}

0 commit comments

Comments
 (0)