mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-24 07:59:12 -05:00
fix: use unique install cache folders for betas (#20296)
This commit is contained in:
@@ -114,6 +114,7 @@ export async function buildCypressApp (options: BuildCypressAppOpts) {
|
||||
meta.distDir('**', 'esprima', 'test'),
|
||||
meta.distDir('**', 'bmp-js', 'test'),
|
||||
meta.distDir('**', 'exif-parser', 'test'),
|
||||
meta.distDir('**', 'app-module-path', 'test'),
|
||||
], { force: true })
|
||||
|
||||
console.log('Deleted excess directories')
|
||||
|
||||
@@ -23,9 +23,9 @@ const getUploadDirForPlatform = function (options) {
|
||||
// the artifact will be uploaded for every platform and uploaded into under a unique folder
|
||||
// https://cdn.cypress.io/beta/(binary|npm)/<version>/<platform>/<some unique version info>/cypress.zip
|
||||
// For binary:
|
||||
// beta/binary/9.4.2/win32-x64/circle-develop-219138ca4e952edc4af831f2ae16ce659ebdb50b/cypress.zip
|
||||
// beta/binary/9.4.2/win32-x64/develop-219138ca4e952edc4af831f2ae16ce659ebdb50b/cypress.zip
|
||||
// For NPM package:
|
||||
// beta/npm/9.4.2/circle-develop-219138ca4e952edc4af831f2ae16ce659ebdb50b/cypress.tgz
|
||||
// beta/npm/9.4.2/develop-219138ca4e952edc4af831f2ae16ce659ebdb50b/cypress.tgz
|
||||
const getUploadPath = function (options) {
|
||||
const { hash, uploadFileName } = options
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const formHashFromEnvironment = function () {
|
||||
} = process
|
||||
|
||||
if (env.CIRCLECI) {
|
||||
return `circle-${env.CIRCLE_BRANCH}-${env.CIRCLE_SHA1}`
|
||||
return `${env.CIRCLE_BRANCH}-${env.CIRCLE_SHA1}`
|
||||
}
|
||||
|
||||
throw new Error('Do not know how to form unique build hash on this CI')
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
set -e # exit on error
|
||||
|
||||
PLATFORM=$(node -p 'process.platform')
|
||||
if [[ $PLATFORM != "linux" && $PLATFORM != "darwin" ]]; then
|
||||
echo "Currently, create-stable-npm-package is only supported on Linux and MacOS."
|
||||
echo "See https://github.com/cypress-io/cypress/pull/20296#discussion_r817115583"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! $1 ]]; then
|
||||
echo "publish-npm-package takes the .tgz URL as the first argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $1 != *"linux-x64"* ]]; then
|
||||
echo "Only publish the 'linux-x64' .tgz. A non-linux-x64 .tgz was passed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x # log commands
|
||||
|
||||
TGZ_URL=$1
|
||||
PREPROD_TGZ_PATH=/tmp/cypress-preprod.tgz
|
||||
UNPACKED_PATH=/tmp/unpacked-cypress
|
||||
PROD_TGZ_PATH=/tmp/cypress-prod.tgz
|
||||
|
||||
echo "Downloading tgz from TGZ_URL=$TGZ_URL"
|
||||
curl $TGZ_URL -o $PREPROD_TGZ_PATH
|
||||
|
||||
echo "Untarring PREPROD_TGZ_PATH=$PREPROD_TGZ_PATH"
|
||||
rm -rf $UNPACKED_PATH || true
|
||||
mkdir $UNPACKED_PATH
|
||||
tar -xzvf $PREPROD_TGZ_PATH -C $UNPACKED_PATH
|
||||
|
||||
export PKG_JSON_PATH=$UNPACKED_PATH/package/package.json
|
||||
|
||||
echo "Patching stable: true to package.json"
|
||||
node <<EOF
|
||||
const fs = require('fs')
|
||||
const pkg = require("$PKG_JSON_PATH")
|
||||
pkg.buildInfo.stable = true
|
||||
const json = JSON.stringify(pkg, null, 2)
|
||||
fs.writeFileSync("$PKG_JSON_PATH", json)
|
||||
EOF
|
||||
|
||||
echo "New package.json:"
|
||||
cat $UNPACKED_PATH/package/package.json
|
||||
|
||||
echo "Tarring..."
|
||||
cd $UNPACKED_PATH
|
||||
tar -czvf $PROD_TGZ_PATH *
|
||||
|
||||
set +x
|
||||
|
||||
echo "Prod NPM package built at:"
|
||||
echo " $PROD_TGZ_PATH"
|
||||
@@ -0,0 +1,27 @@
|
||||
const minimist = require('minimist')
|
||||
const shelljs = require('shelljs')
|
||||
|
||||
const args = minimist(process.argv.slice(2))
|
||||
|
||||
if (!/^[a-z0-9]{40}$/.test(args.sha)) {
|
||||
throw new Error('A valid (40 character) commit SHA must be passed in `--sha`.')
|
||||
}
|
||||
|
||||
if (!/^\d+\.\d+\.\d+$/.test(args.version)) {
|
||||
throw new Error('A valid semantic version (X.Y.Z) must be passed in `--version`.')
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const log = (...args) => console.log('🏗', ...args)
|
||||
|
||||
const exec = args['dry-run'] ?
|
||||
(...args) => log('Dry run, not executing:', ...args)
|
||||
: (...args) => shelljs.exec(...args)
|
||||
|
||||
log('Running `move-binaries`...')
|
||||
exec(`node ./scripts/binary.js move-binaries --sha ${args.sha} --version ${args.version}`)
|
||||
|
||||
const prereleaseNpmUrl = `https://cdn.cypress.io/beta/npm/${args.version}/linux-x64/develop-${args.sha}/cypress.tgz`
|
||||
|
||||
log('Running `create-stable-npm-package`...')
|
||||
exec(`./scripts/create-stable-npm-package.sh ${prereleaseNpmUrl}`)
|
||||
@@ -0,0 +1,10 @@
|
||||
const shelljs = require('shelljs')
|
||||
const snapshot = require('snap-shot-it')
|
||||
|
||||
describe('prepare-release-artifacts', () => {
|
||||
it('runs expected commands', () => {
|
||||
const stdout = shelljs.exec('yarn prepare-release-artifacts --dry-run --sha 57d0a85108fad6f77b39db88b8a7d8a3bfdb51a2 --version 1.2.3')
|
||||
|
||||
snapshot(stdout)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user