Skip to content

Commit

Permalink
ci(publish): fix url for svg badge for e2e test workflow check (#3203)
Browse files Browse the repository at this point in the history
Co-authored-by: prisma-bot <prismabots@gmail.com>
  • Loading branch information
Jolg42 and prisma-bot committed Aug 5, 2020
1 parent 02a4532 commit e987c3e
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/scripts/ci/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,13 @@ async function publish() {
prisma2Version = await getNewDevVersion(packages)
}

const tag =
patchBranch && !process.env.BUILDKITE_TAG
? 'patch-dev'
: prisma2Version.includes('dev')
? 'dev'
: 'latest'

const packagesWithVersions = await getNewPackageVersions(
packages,
prisma2Version,
Expand Down Expand Up @@ -620,10 +627,10 @@ async function publish() {
}

if (args['--release']) {
const passing = await areEndToEndTestsPassing()
const passing = await areEndToEndTestsPassing(tag)
if (!passing) {
throw new Error(`We can't release, as the e2e tests are not passing!
Check them out at https://github.com/prisma/e2e-tests/actions?query=workflow%3Atest+branch%3Amaster`)
throw new Error(`We can't release, as the e2e tests are not passing for the ${tag} npm tag!
Check them out at https://github.com/prisma/e2e-tests/actions?query=workflow%3Atest+branch%3A${tag}`)
}
}

Expand All @@ -635,6 +642,7 @@ Check them out at https://github.com/prisma/e2e-tests/actions?query=workflow%3At
getPublishOrder(packages),
true,
prisma2Version,
tag,
args['--release'],
patchBranch,
)
Expand All @@ -648,6 +656,7 @@ Check them out at https://github.com/prisma/e2e-tests/actions?query=workflow%3At
getPublishOrder(packages),
dryRun,
prisma2Version,
tag,
args['--release'],
patchBranch,
)
Expand Down Expand Up @@ -804,11 +813,12 @@ async function publishPackages(
publishOrder: string[][],
dryRun: boolean,
prisma2Version: string,
tag: string,
releaseVersion?: string,
patchBranch?: string,
): Promise<void> {
// we need to release a new @prisma/cli in all cases.
// if there is a change in photon, photon will also use this new version
// if there is a change in prisma-client-js, it will also use this new version

const publishStr = dryRun
? `${chalk.bold('Dry publish')} `
Expand Down Expand Up @@ -875,12 +885,6 @@ async function publishPackages(
for (const pkgName of currentBatch) {
const pkg = packages[pkgName]
const pkgDir = path.dirname(pkg.path)
const tag =
patchBranch && !process.env.BUILDKITE_TAG
? 'patch-dev'
: prisma2Version.includes('dev')
? 'dev'
: 'latest'

let newVersion = prisma2Version
if (
Expand Down Expand Up @@ -1062,10 +1066,14 @@ async function getBranch(dir: string) {
return runResult(dir, 'git rev-parse --symbolic-full-name --abbrev-ref HEAD')
}

async function areEndToEndTestsPassing(): Promise<boolean> {
const res = await fetch(
'https://github.com/prisma/e2e-tests/workflows/test/badge.svg',
).then((r) => r.text())
async function areEndToEndTestsPassing(tag: string): Promise<boolean> {
let svgUrl = 'https://github.com/prisma/e2e-tests/workflows/test/badge.svg'

if (tag === 'patch-dev' || tag === 'dev') {
svgUrl += `?branch=${tag}`
}

const res = await fetch(svgUrl).then((r) => r.text())
return res.includes('passing')
}

Expand Down

0 comments on commit e987c3e

Please sign in to comment.