From 748fb01484c6f6eca0203c9499c0751220f3e20c Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Thu, 19 Jan 2023 10:36:02 -0800 Subject: [PATCH 1/2] dont try to push pod if its a canary release --- scripts/after-shipit-pod-push.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/after-shipit-pod-push.js b/scripts/after-shipit-pod-push.js index 76f0a897e..b6ef20684 100644 --- a/scripts/after-shipit-pod-push.js +++ b/scripts/after-shipit-pod-push.js @@ -6,10 +6,17 @@ const { execSync } = require('child_process'); class AfterShipItPodPush { name = 'after-shipit-pod-push'; + wasCanary = false; + apply(auto) { + auto.hooks.canary.tap(this.name, () => { + this.wasCanary = true + }) auto.hooks.afterShipIt.tapPromise(this.name, async ({ dryRun, newVersion }) => { if (dryRun) { - auto.logger.log.info(`Dry run: would have pushed pod to trunk`); + auto.logger.log.info('Dry run: would have pushed pod to trunk'); + } else if (this.wasCanary) { + auto.logger.log.info('[AfterShipItPodPush]: Canary not yet supported, skipping pod push.') } else { let found = false let attempt = 0 From 5d6ce3dd7a89061aff3ff4b4a19e8eedc7075256 Mon Sep 17 00:00:00 2001 From: Harris Borawski Date: Thu, 19 Jan 2023 11:13:55 -0800 Subject: [PATCH 2/2] guard pod push on release being found, rather than assume it is by the end of the loop --- scripts/after-shipit-pod-push.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/scripts/after-shipit-pod-push.js b/scripts/after-shipit-pod-push.js index b6ef20684..fc819eb47 100644 --- a/scripts/after-shipit-pod-push.js +++ b/scripts/after-shipit-pod-push.js @@ -24,10 +24,13 @@ class AfterShipItPodPush { while (!found && attempt < 10) { const { data } = await auto.git.github.repos.listReleases({owner: auto.config.owner, repo: auto.config.repo}) const release = data.find(element => element.tag_name === newVersion) - const { data: releaseData } = await auto.git.github.repos.getRelease({owner: auto.config.owner, repo: auto.config.repo, release_id: release.id}) - const zip = releaseData.assets.find(element => element.name === 'PlayerUI_Pod.zip' && element.state === 'uploaded') + if (release) { + const { data: releaseData } = await auto.git.github.repos.getRelease({owner: auto.config.owner, repo: auto.config.repo, release_id: release.id}) + const zip = releaseData.assets.find(element => element.name === 'PlayerUI_Pod.zip' && element.state === 'uploaded') + + found = !!zip + } - found = !!zip if (!found) { attempt++ await new Promise((resolve) => { @@ -36,13 +39,17 @@ class AfterShipItPodPush { } } - auto.logger.log.info('Pushing Pod to trunk') - let process - try { - process = execSync('bundle exec pod trunk push --skip-tests ./bazel-bin/PlayerUI.podspec') - } catch(e) { - auto.logger.log.error('Pod push failed: ', process && process.stderr.toString(), e) - throw e + if (found) { + auto.logger.log.info('Pushing Pod to trunk') + let process + try { + process = execSync('bundle exec pod trunk push --skip-tests ./bazel-bin/PlayerUI.podspec') + } catch(e) { + auto.logger.log.error('Pod push failed: ', process && process.stderr.toString(), e) + throw e + } + } else { + auto.logger.log.error('[AfterShipItPodPush]: Release not found, skipping pod push') } } });