diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index f330b663cd5..1f74826315e 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -68,11 +68,50 @@ jobs: path: | ${{ env.local_sdk_repo_dir }}/*.podspec ${{ env.local_sdk_repo_dir }}/*.podspec.json - buildup_SpecsTesting_repo: + buildup_SpecsTesting_repo_FirebaseCore: needs: specs_checking # Don't run on private repo unless it is a PR. if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'workflow_dispatch' runs-on: macos-12 + env: + bot_token_secret: ${{ secrets.GHASecretsGPGPassphrase1 }} + local_repo: specstesting + local_sdk_repo_dir: /tmp/test/firebase-ios-sdk + targeted_pod: FirebaseCore + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v3 + with: + name: firebase-ios-sdk + path: ${{ env.local_sdk_repo_dir }} + - name: Get token + run: | + scripts/decrypt_gha_secret.sh scripts/gha-encrypted/bot-access.txt.gpg \ + bot-access.txt "$bot_token_secret" + - name: Update SpecsTesting repo + run: | + botaccess=`cat bot-access.txt` + cd scripts/create_spec_repo/ + swift build + pod repo add --silent "${local_repo}" https://"$botaccess"@github.com/Firebase/SpecsTesting.git + BOT_TOKEN="${botaccess}" ${GITHUB_WORKSPACE}/scripts/third_party/travis/retry.sh .build/debug/spec-repo-builder / + --sdk-repo "${local_sdk_repo_dir}" / + --local-spec-repo-name "${local_repo}" / + --sdk-repo-name SpecsTesting / + --github-account Firebase / + --pod-sources 'https://${BOT_TOKEN}@github.com/Firebase/SpecsTesting' "https://github.com/firebase/SpecsDev.git" "https://github.com/firebase/SpecsStaging.git" "https://github.com/CocoaPods/Specs.git" / + --include-pods "${targeted_pod}" --keep-repo + - name: Clean Artifacts + if: ${{ always() }} + run: | + pod repo remove "${local_repo}" + rm -rf bot-access.txt + + buildup_SpecsTesting_repo: + needs: [buildup_SpecsTesting_repo_FirebaseCore, specs_checking] + # Don't run on private repo unless it is a PR. + if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'workflow_dispatch' + runs-on: macos-12 strategy: fail-fast: false matrix: ${{fromJson(needs.specs_checking.outputs.matrix)}} @@ -89,17 +128,25 @@ jobs: path: ${{ env.local_sdk_repo_dir }} - name: Get token run: | - scripts/decrypt_gha_secret.sh scripts/gha-encrypted/oss-bot-access.txt.gpg \ - oss-bot-access.txt "$bot_token_secret" scripts/decrypt_gha_secret.sh scripts/gha-encrypted/bot-access.txt.gpg \ bot-access.txt "$bot_token_secret" - name: Update SpecsTesting repo run: | + [[ ${{ matrix.podspec }} == true ]] && ALLOWWARNINGS=true botaccess=`cat bot-access.txt` cd scripts/create_spec_repo/ swift build pod repo add --silent "${local_repo}" https://"$botaccess"@github.com/Firebase/SpecsTesting.git - BOT_TOKEN="${botaccess}" .build/debug/spec-repo-builder --sdk-repo "${local_sdk_repo_dir}" --local-spec-repo-name "${local_repo}" --sdk-repo-name SpecsTesting --github-account Firebase --pod-sources 'https://${BOT_TOKEN}@github.com/Firebase/SpecsTesting' "https://github.com/firebase/SpecsDev.git" "https://github.com/firebase/SpecsStaging.git" "https://github.com/CocoaPods/Specs.git" --include-pods "${targeted_pod}" --keep-repo + # ${ALLOWWARNINGS:+--allow-warnings} will add --allow-warnings to the + # command if ${ALLOWWARNINGS} is not null. + BOT_TOKEN="${botaccess}" ${GITHUB_WORKSPACE}/scripts/third_party/travis/retry.sh .build/debug/spec-repo-builder \ + --sdk-repo "${local_sdk_repo_dir}" \ + --local-spec-repo-name "${local_repo}" \ + --sdk-repo-name SpecsTesting \ + --github-account Firebase \ + --pod-sources 'https://${BOT_TOKEN}@github.com/Firebase/SpecsTesting' "https://github.com/firebase/SpecsDev.git" "https://github.com/firebase/SpecsStaging.git" "https://github.com/CocoaPods/Specs.git" \ + --include-pods "${targeted_pod}" \ + --keep-repo ${ALLOWWARNINGS:+--allow-warnings} - name: Clean Artifacts if: ${{ always() }} run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d608c5d517..865a6c45b19 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ concurrency: jobs: specs_checking: # Don't run on private repo unless it is a PR. - if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' + if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'workflow_dispatch' runs-on: macos-12 env: bot_token_secret: ${{ secrets.GHASecretsGPGPassphrase1 }} @@ -49,13 +49,13 @@ jobs: sdk_version_config="${GITHUB_WORKSPACE}/scripts/create_spec_repo/RC_firebase_sdk.textproto" \ local_sdk_repo_dir="${local_sdk_repo_dir}" \ podspec_repo_branch="${podspec_repo_branch}" \ - scripts/release_testing_setup.sh prerelease_testing + scripts/release_testing_setup.sh release_testing - name: Clean spec repo run: | botaccess=`cat bot-access.txt` git clone --quiet https://"$botaccess"@github.com/FirebasePrivate/SpecsTesting.git "${local_repo}" cd "${local_repo}" - # Remove all unhided dirs, i.e. all podspec dir from the spec repo. + # Remove all unhidden dirs, i.e. all podspec dir from the spec repo. rm -Rf -- */ git add . # commit without diff will throw an error. `git diff --exit-code` can avoid such error. @@ -71,10 +71,47 @@ jobs: path: | ${{ env.local_sdk_repo_dir }}/*.podspec ${{ env.local_sdk_repo_dir }}/*.podspec.json - buildup_SpecsTesting_repo: + buildup_SpecsTesting_repo_FirebaseCore: needs: specs_checking # Don't run on private repo unless it is a PR. - if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' + if: github.repository == 'Firebase/firebase-ios-sdk' + runs-on: macos-12 + env: + bot_token_secret: ${{ secrets.GHASecretsGPGPassphrase1 }} + local_repo: specstesting + local_sdk_repo_dir: /tmp/test/firebase-ios-sdk + targeted_pod: FirebaseCore + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v3 + with: + name: firebase-ios-sdk + path: ${{ env.local_sdk_repo_dir }} + - name: Get token + run: | + scripts/decrypt_gha_secret.sh scripts/gha-encrypted/bot-access.txt.gpg \ + bot-access.txt "$bot_token_secret" + - name: Update SpecsTesting repo + run: | + botaccess=`cat bot-access.txt` + cd scripts/create_spec_repo/ + swift build + pod repo add --silent "${local_repo}" https://"$botaccess"@github.com/FirebasePrivate/SpecsTesting.git + BOT_TOKEN="${botaccess}" ${GITHUB_WORKSPACE}/scripts/third_party/travis/retry.sh .build/debug/spec-repo-builder \ + --sdk-repo "${local_sdk_repo_dir}" \ + --local-spec-repo-name "${local_repo}" \ + --pod-sources 'https://${BOT_TOKEN}@github.com/FirebasePrivate/SpecsTesting' "https://github.com/firebase/SpecsStaging.git" "https://github.com/CocoaPods/Specs.git" \ + --include-pods "${targeted_pod}" --keep-repo + - name: Clean Artifacts + if: ${{ always() }} + run: | + pod repo remove "${local_repo}" + rm -rf bot-access.txt + + buildup_SpecsTesting_repo: + needs: [buildup_SpecsTesting_repo_FirebaseCore, specs_checking] + # Don't run on private repo unless it is a PR. + if: github.repository == 'Firebase/firebase-ios-sdk' runs-on: macos-12 strategy: fail-fast: false @@ -96,11 +133,19 @@ jobs: bot-access.txt "$bot_token_secret" - name: Update SpecsTesting repo run: | + [[ ${{ matrix.allowwarnings }} == true ]] && ALLOWWARNINGS=true botaccess=`cat bot-access.txt` cd scripts/create_spec_repo/ swift build pod repo add --silent "${local_repo}" https://"$botaccess"@github.com/FirebasePrivate/SpecsTesting.git - BOT_TOKEN="${botaccess}" .build/debug/spec-repo-builder --sdk-repo "${local_sdk_repo_dir}" --local-spec-repo-name "${local_repo}" --pod-sources 'https://${BOT_TOKEN}@github.com/FirebasePrivate/SpecsTesting' "https://github.com/firebase/SpecsStaging.git" "https://github.com/CocoaPods/Specs.git" --include-pods "${targeted_pod}" --keep-repo + # ${ALLOWWARNINGS:+--allow-warnings} will add --allow-warnings to the + # command if ${ALLOWWARNINGS} is not null. + BOT_TOKEN="${botaccess}" ${GITHUB_WORKSPACE}/scripts/third_party/travis/retry.sh .build/debug/spec-repo-builder \ + --sdk-repo "${local_sdk_repo_dir}" \ + --local-spec-repo-name "${local_repo}" \ + --pod-sources 'https://${BOT_TOKEN}@github.com/FirebasePrivate/SpecsTesting' "https://github.com/firebase/SpecsStaging.git" "https://github.com/CocoaPods/Specs.git" \ + --include-pods "${targeted_pod}" \ + --keep-repo ${ALLOWWARNINGS:+--allow-warnings} - name: Clean Artifacts if: ${{ always() }} run: | diff --git a/ReleaseTooling/Sources/ManifestParser/GHAMatrixSpecCollector.swift b/ReleaseTooling/Sources/ManifestParser/GHAMatrixSpecCollector.swift index 7f3bea8f96b..dcbbf31a140 100644 --- a/ReleaseTooling/Sources/ManifestParser/GHAMatrixSpecCollector.swift +++ b/ReleaseTooling/Sources/ManifestParser/GHAMatrixSpecCollector.swift @@ -25,6 +25,7 @@ import Utils /// ``` struct SDKPodspec: Codable { let podspec: String + let allowWarnings: Bool } struct GHAMatrixSpecCollector { @@ -32,18 +33,18 @@ struct GHAMatrixSpecCollector { var outputSpecFileURL: URL var excludedSDKs: [String] = [] - func getPodsInManifest(_ manifest: Manifest) -> [String] { - var podsList: [String] = [] + func getPodsInManifest(_ manifest: Manifest) -> [String: SDKPodspec] { + var podsMap: [String: SDKPodspec] = [:] for pod in manifest.pods { - podsList.append(pod.name) + podsMap[pod.name] = SDKPodspec(podspec: pod.name, allowWarnings: pod.allowWarnings) } - return podsList + return podsMap } - func getAllPodspecs() -> [String] { - var output: [String] = [] + func getAllPodspecs() -> [SDKPodspec] { + var output: [SDKPodspec] = [] let fileManager = FileManager.default - let podsSet = Set(getPodsInManifest(FirebaseManifest.shared)) + let podsMap = getPodsInManifest(FirebaseManifest.shared) do { let fileURLs = try fileManager.contentsOfDirectory( at: SDKRepoURL, @@ -53,8 +54,11 @@ struct GHAMatrixSpecCollector { let fileNameComponents = url.lastPathComponent.components(separatedBy: ".") if fileNameComponents.count > 1, fileNameComponents[1] == "podspec" { let specName = fileNameComponents[0] - podsSet.contains(specName) ? output - .append(specName) : print("\(specName) is not in manifiest") + if let spec = podsMap[specName] { + output.append(spec) + } else { + print("\(specName) is not in manifiest") + } } } } catch { @@ -64,11 +68,7 @@ struct GHAMatrixSpecCollector { } func generateMatrixJson(to filePath: URL) throws { - let testingSpecs = getAllPodspecs() - var sdkPodspecs: [SDKPodspec] = [] - for spec in testingSpecs { - sdkPodspecs.append(SDKPodspec(podspec: spec)) - } + let sdkPodspecs: [SDKPodspec] = getAllPodspecs() // Trim whitespaces so the GitHub Actions matrix can read. let str = try String( decoding: JSONEncoder().encode(sdkPodspecs), diff --git a/scripts/create_spec_repo/Sources/SpecRepoBuilder/main.swift b/scripts/create_spec_repo/Sources/SpecRepoBuilder/main.swift index 15d42de8e9c..3c512598212 100644 --- a/scripts/create_spec_repo/Sources/SpecRepoBuilder/main.swift +++ b/scripts/create_spec_repo/Sources/SpecRepoBuilder/main.swift @@ -26,6 +26,9 @@ extension Constants { static let podSources = [ "https://${BOT_TOKEN}@github.com/Firebase/SpecsTesting", "https://github.com/firebase/SpecsStaging.git", + // https://cdn.cocoapods.org is not used here since `--update-sources` + // will update spec repos before a spec is pushed, but cdn is not a spec + // repo. "https://github.com/CocoaPods/Specs.git", ] } @@ -34,7 +37,6 @@ extension Constants { extension Constants { static let flags = [ "--skip-tests", - "--allow-warnings", "--skip-import-validation", "--update-sources", ] @@ -155,6 +157,9 @@ struct SpecRepoBuilder: ParsableCommand { @Flag(help: "Raise error while circular dependency detected.") var raiseCircularDepError: Bool = false + @Flag(help: "Allow warnings when push a spec.") + var allowWarnings: Bool = false + // This will track down dependencies of pods and keep the sequence of // dependency installation in specFiles.depInstallOrder. func generateOrderOfInstallation(pods: [String], specFiles: SpecFiles, @@ -265,7 +270,8 @@ struct SpecRepoBuilder: ParsableCommand { func pushPodspec(forPod pod: URL, sdkRepo: String, sources: [String], flags: [String], shell: Shell = Shell.shared) throws -> Int32 { let sourcesArg = sources.joined(separator: ",") - let flagsArg = flags.joined(separator: " ") + let flagsArgArr = allowWarnings ?flags + ["--allow-warnings"] : flags + let flagsArg = flagsArgArr.joined(separator: " ") do { // Update the repo diff --git a/scripts/release_testing_setup.sh b/scripts/release_testing_setup.sh index ddb643be2c8..7fde6746917 100755 --- a/scripts/release_testing_setup.sh +++ b/scripts/release_testing_setup.sh @@ -37,12 +37,16 @@ test_version=$(git tag -l --sort=-version:refname CocoaPods-*[0-9] | head -n 1) git config --global user.email "google-oss-bot@example.com" git config --global user.name "google-oss-bot" git checkout "${podspec_repo_branch}" +# Ensure the tag version including pod version to avoid warnings. +# https://github.com/CocoaPods/Core/blob/e6451e172c33f3aa77a3f8baa7b6b5b8c3b5da14/lib/cocoapods-core/specification/linter.rb#L372-L374 +pod_testing_version=`echo "${test_version}" | sed "s/CocoaPods-//"` if [ "$TESTINGMODE" = "release_testing" ]; then git checkout "${test_version}" echo "Podspecs tags of Nightly release testing will be updated to ${test_version}." # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to # ":tag => 'CocoaPods-7.9.0'" - sed -i "" "s/\s*:tag.*/:tag => '${test_version}'/" *.podspec + sed -i "" "s/\s*:tag.*/:tag => '${test_version}'/" *.podspec + sed -i "" "s/s\.version[[:space:]]*=.*/s\.version='${pod_testing_version}'/" *.podspec elif [ "$TESTINGMODE" = "prerelease_testing" ]; then tag_version="${test_version}.nightly" echo "A new tag, ${tag_version},for prerelease testing will be created." @@ -55,5 +59,6 @@ elif [ "$TESTINGMODE" = "prerelease_testing" ]; then git push origin "${tag_version}" # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to # ":tag => ${test_version}.nightly" - sed -i "" "s/\s*:tag.*/:tag => '${tag_version}'/" *.podspec + sed -i "" "s/\s*:tag.*/:tag => '${tag_version}'/" *.podspec + sed -i "" "s/s\.version[[:space:]]*=.*/s\.version='${pod_testing_version}'/" *.podspec fi