Skip to content

Commit 06185f6

Browse files
authored
Notices Generation Fix - update manifest parser (#9842)
* Notices Generation Fix - update manifest parser
1 parent 85e379d commit 06185f6

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

.github/workflows/notice_generation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Get all pod names
2323
run: |
2424
cd "${GITHUB_WORKSPACE}/ReleaseTooling/"
25-
swift run manifest --pod-name-output-file-path ./output.txt
25+
swift run manifest --output-file-path ./output.txt --for-notices-generation
2626
PODS=`cat ./output.txt`
2727
echo "PODS=${PODS}" >> $GITHUB_ENV
2828
echo "NOTICES_PATH=${GITHUB_WORKSPACE}/${NOTICES_PATH}" >> $GITHUB_ENV

.github/workflows/prerelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
id: generate_matrix
3636
run: |
3737
cd "${GITHUB_WORKSPACE}/ReleaseTooling"
38-
swift run manifest --sdk-repo-url "${GITHUB_WORKSPACE}" --spec-output-file-path ./output.json
38+
swift run manifest --sdk-repo-url "${GITHUB_WORKSPACE}" --output-file-path ./output.json --for-gha-matrix-generation
3939
echo "::set-output name=matrix::{\"include\":$( cat output.json )}"
4040
- name: Get token
4141
run: |

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
id: generate_matrix
3737
run: |
3838
cd "${GITHUB_WORKSPACE}/ReleaseTooling"
39-
swift run manifest --sdk-repo-url "${GITHUB_WORKSPACE}" --spec-output-file-path ./output.json
39+
swift run manifest --sdk-repo-url "${GITHUB_WORKSPACE}" --output-file-path ./output.json --for-gha-matrix-generation
4040
echo "::set-output name=matrix::{\"include\":$( cat output.json )}"
4141
- name: Get token
4242
run: |

ReleaseTooling/Sources/ManifestParser/main.swift

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ import FirebaseManifest
1919
import Foundation
2020
import Utils
2121

22+
enum ParsingMode: String, EnumerableFlag {
23+
case forNoticesGeneration
24+
case forGHAMatrixGeneration
25+
}
26+
2227
struct ManifestParser: ParsableCommand {
2328
@Option(help: "The path of the SDK repo.",
2429
transform: { str in
2530
if NSString(string: str).isAbsolutePath { return URL(fileURLWithPath: str) }
2631
let documentDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
2732
return documentDir.appendingPathComponent(str)
2833
})
29-
var SDKRepoURL: URL
34+
var SDKRepoURL: URL?
3035

3136
/// Path of a text file for Firebase Pods' names.
3237
@Option(help: "An output file with Podspecs",
@@ -35,32 +40,45 @@ struct ManifestParser: ParsableCommand {
3540
let documentDir = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
3641
return documentDir.appendingPathComponent(str)
3742
})
38-
var specOutputFilePath: URL
43+
var outputFilePath: URL
3944

4045
@Option(parsing: .upToNextOption, help: "Podspec files that will not be included.")
4146
var excludedSpecs: [String]
4247

48+
@Flag(help: "Parsing mode for manifest")
49+
var mode: ParsingMode
50+
4351
func parsePodNames(_ manifest: Manifest) throws {
4452
var output: [String] = []
4553
for pod in manifest.pods {
4654
output.append(pod.name)
4755
}
4856
do {
4957
try output.joined(separator: ",")
50-
.write(to: specOutputFilePath, atomically: true,
58+
.write(to: outputFilePath, atomically: true,
5159
encoding: String.Encoding.utf8)
52-
print("\(output) is written in \n \(specOutputFilePath).")
60+
print("\(output) is written in \n \(outputFilePath).")
5361
} catch {
5462
throw error
5563
}
5664
}
5765

5866
func run() throws {
59-
let specCollector = GHAMatrixSpecCollector(
60-
SDKRepoURL: SDKRepoURL,
61-
outputSpecFileURL: specOutputFilePath
62-
)
63-
try specCollector.generateMatrixJson(to: specOutputFilePath)
67+
switch mode {
68+
case .forNoticesGeneration:
69+
try parsePodNames(FirebaseManifest.shared)
70+
case .forGHAMatrixGeneration:
71+
guard let sdkRepoURL = SDKRepoURL else {
72+
throw fatalError(
73+
"--sdk-repo-url should be specified when --for-gha-matrix-generation is on."
74+
)
75+
}
76+
let specCollector = GHAMatrixSpecCollector(
77+
SDKRepoURL: sdkRepoURL,
78+
outputSpecFileURL: outputFilePath
79+
)
80+
try specCollector.generateMatrixJson(to: outputFilePath)
81+
}
6482
}
6583
}
6684

0 commit comments

Comments
 (0)