Skip to content

Commit

Permalink
chore: fix circle-env for contributor PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed May 2, 2022
1 parent a47b45f commit 8702bd0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/circle-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ async function checkCanaries () {

const circleEnv = await readCircleEnv()

if (Object.keys(circleEnv).length === 0) {
return console.warn('CircleCI env empty, assuming this is a contributor PR. Not checking for canary variables.')
}

if (!circleEnv.MAIN_CANARY) throw new Error('Missing MAIN_CANARY.')

if (!circleEnv.CONTEXT_CANARY) throw new Error('Missing CONTEXT_CANARY. Does this job have the test-runner:env-canary context?')
Expand All @@ -36,7 +40,12 @@ async function readCircleEnv () {
// if this starts failing, try SSHing into a CircleCI job and see what changed in the $CIRCLE_INTERNAL_CONFIG file's schema
const circleEnv = taskData['Dispatched']['TaskInfo']['Environment']

if (!circleEnv || !Object.keys(circleEnv).length) throw new Error('An empty Environment object was found.')
if (!circleEnv) throw new Error('No Environment object was found.')

// last-ditch effort to check that an empty circle env is accurately reflecting process.env (external PRs)
if (process.env.CACHE_VERSION && Object.keys(circleEnv).length === 0) {
throw new Error('CACHE_VERSION is set, but circleEnv is empty')
}

return circleEnv
} catch (err) {
Expand Down

0 comments on commit 8702bd0

Please sign in to comment.