mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-22 23:20:24 -05:00
chore: Migrate Windows Tests from Appveyor to CircleCI (#19037)
Co-authored-by: Zach Bloomquist <git@chary.us> Co-authored-by: ElevateBart <ledouxb@gmail.com>
This commit is contained in:
@@ -81,12 +81,13 @@ export async function buildCypressApp (options: BuildCypressAppOpts) {
|
||||
// Copy the yarn.lock file so we have a consistent install
|
||||
fs.copySync(path.join(CY_ROOT_DIR, 'yarn.lock'), meta.distDir('yarn.lock'))
|
||||
|
||||
// replaceLocalNpmVersions
|
||||
log('#replace local npm versions')
|
||||
const dirsSeen = await packages.replaceLocalNpmVersions(DIST_DIR)
|
||||
|
||||
// remove local npm dirs that aren't needed
|
||||
log('#remove local npm dirs that are not needed')
|
||||
await packages.removeLocalNpmDirs(DIST_DIR, dirsSeen)
|
||||
|
||||
log('#install production dependencies')
|
||||
execSync('yarn --production', {
|
||||
cwd: DIST_DIR,
|
||||
stdio: 'inherit',
|
||||
|
||||
+4
-23
@@ -13,14 +13,6 @@ let car = null
|
||||
|
||||
// all the projects to trigger / run / change environment variables for
|
||||
const _PROVIDERS = {
|
||||
appVeyor: {
|
||||
main: 'cypress-io/cypress',
|
||||
win32: [
|
||||
'cypress-io/cypress-test-tiny',
|
||||
'cypress-io/cypress-test-example-repos',
|
||||
],
|
||||
},
|
||||
|
||||
circle: {
|
||||
main: 'cypress-io/cypress',
|
||||
linux: [
|
||||
@@ -35,6 +27,10 @@ const _PROVIDERS = {
|
||||
'cypress-io/cypress-test-tiny',
|
||||
'cypress-io/cypress-test-example-repos',
|
||||
],
|
||||
win32: [
|
||||
'cypress-io/cypress-test-tiny',
|
||||
'cypress-io/cypress-test-example-repos',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
@@ -105,12 +101,6 @@ const awaitEachProjectAndProvider = function (projects, fn, filter = (val) => va
|
||||
}
|
||||
}
|
||||
|
||||
if (check.unemptyString(creds.appVeyorToken)) {
|
||||
providers.appVeyor = {
|
||||
appVeyorToken: creds.appVeyorToken,
|
||||
}
|
||||
}
|
||||
|
||||
const providerNames = Object.keys(providers)
|
||||
|
||||
console.log('configured providers', providerNames)
|
||||
@@ -133,7 +123,6 @@ const awaitEachProjectAndProvider = function (projects, fn, filter = (val) => va
|
||||
}
|
||||
|
||||
// do not trigger all projects if there is specific provider
|
||||
// for example appVeyor should be used for Windows testing
|
||||
const getFilterByProvider = function (providerName, platformName) {
|
||||
return (val) => {
|
||||
if (providerName && val.provider !== providerName) {
|
||||
@@ -226,14 +215,6 @@ Testing new Cypress version ${version}
|
||||
message += '\n'
|
||||
message += `Circle CI build url ${process.env.CIRCLE_BUILD_URL}`
|
||||
}
|
||||
|
||||
if (process.env.APPVEYOR) {
|
||||
const slug = process.env.APPVEYOR_PROJECT_SLUG
|
||||
const build = process.env.APPVEYOR_BUILD_ID
|
||||
|
||||
message += '\n'
|
||||
message += `AppVeyor CI ${slug} ${build}`
|
||||
}
|
||||
}
|
||||
|
||||
const defaultOptions = {
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// but globby supports multiple wildcard search patterns 👏
|
||||
const globby = require('globby')
|
||||
|
||||
module.exports = {
|
||||
globby,
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
import _ from 'lodash'
|
||||
import fs from 'fs-extra'
|
||||
import util from 'util'
|
||||
import path from 'path'
|
||||
// we wrap glob to handle EMFILE error
|
||||
import glob from 'glob'
|
||||
import la from 'lazy-ass'
|
||||
import check from 'check-more-types'
|
||||
import execa from 'execa'
|
||||
import debugLib from 'debug'
|
||||
|
||||
import externalUtils, { globby } from './3rd-party'
|
||||
|
||||
const debug = debugLib('cypress:binary')
|
||||
|
||||
const globAsync = util.promisify(glob)
|
||||
|
||||
const pathToPackageJson = function (packageFolder) {
|
||||
la(check.unemptyString(packageFolder), 'expected package path', packageFolder)
|
||||
|
||||
@@ -41,17 +42,13 @@ const createCLIExecutable = (command) => {
|
||||
|
||||
const yarn = createCLIExecutable('yarn')
|
||||
|
||||
export const runAllBuild = _.partial(yarn, ['lerna', 'run', 'build-prod', '--ignore', 'cli'])
|
||||
|
||||
export const runAllCleanJs = _.partial(yarn, ['lerna', 'run', 'clean-js', '--ignore', 'cli'])
|
||||
|
||||
export async function copyAllToDist (distDir: string) {
|
||||
await fs.ensureDir(distDir)
|
||||
|
||||
const started = new Date().valueOf()
|
||||
const globbed = await externalUtils.globby(['./packages/*', './npm/*'], {
|
||||
onlyFiles: false,
|
||||
})
|
||||
const globbed = await globAsync('./{packages,npm}/*')
|
||||
|
||||
for (const pkg of globbed) {
|
||||
// copies the package to dist
|
||||
@@ -74,11 +71,17 @@ export async function copyAllToDist (distDir: string) {
|
||||
const pkgFileMasks = [].concat(json.files || []).concat(json.main || [])
|
||||
|
||||
debug('for pkg %s have the following file masks %o', pkg, pkgFileMasks)
|
||||
const foundFileRelativeToPackageFolder = await externalUtils.globby(pkgFileMasks, {
|
||||
cwd: pkg, // search in the package folder
|
||||
absolute: false, // and return relative file paths
|
||||
followSymbolicLinks: false, // do not follow symlinks
|
||||
})
|
||||
let foundFileRelativeToPackageFolder = []
|
||||
|
||||
if (pkgFileMasks.length > 0) {
|
||||
const pattern = pkgFileMasks.length > 1 ? `{${pkgFileMasks.join(',')}}` : pkgFileMasks[0]
|
||||
|
||||
foundFileRelativeToPackageFolder = await globAsync(pattern, {
|
||||
cwd: pkg, // search in the package folder
|
||||
absolute: false, // and return relative file paths
|
||||
follow: false, // do not follow symlinks
|
||||
})
|
||||
}
|
||||
|
||||
console.log(`Copying ${pkg} to ${path.join(distDir, pkg)}`)
|
||||
|
||||
@@ -123,12 +126,13 @@ export async function copyAllToDist (distDir: string) {
|
||||
export const replaceLocalNpmVersions = async function (basePath: string) {
|
||||
const visited = new Set<string>()
|
||||
|
||||
const pkgPaths = await globby('./packages/*/package.json', { cwd: basePath })
|
||||
const pkgPaths = await globAsync('./packages/*/', { cwd: basePath })
|
||||
|
||||
async function updatePackageJson (pkg: string) {
|
||||
const pkgJsonPath = path.join(basePath, pkg)
|
||||
const pkgPath = path.join(basePath, pkg)
|
||||
const pkgJsonPath = path.join(basePath, pkg, 'package.json')
|
||||
|
||||
visited.add(pkgJsonPath)
|
||||
visited.add(pkgPath)
|
||||
const json = await fs.readJson(pkgJsonPath)
|
||||
|
||||
const { dependencies } = json
|
||||
@@ -143,15 +147,16 @@ export const replaceLocalNpmVersions = async function (basePath: string) {
|
||||
|
||||
const [, localPkg] = depName.split('/')
|
||||
|
||||
const localPkgJsonPath = path.join(basePath, 'npm', localPkg)
|
||||
const localPkgPath = path.join(basePath, 'npm', localPkg)
|
||||
|
||||
dependencies[`@cypress/${localPkg}`] = `file:${localPkgJsonPath}`
|
||||
if (!visited.has(localPkgJsonPath)) {
|
||||
await updatePackageJson(`./npm/${localPkg}/package.json`)
|
||||
dependencies[`@cypress/${localPkg}`] = `file:${localPkgPath}`
|
||||
if (!visited.has(localPkgPath)) {
|
||||
await updatePackageJson(`./npm/${localPkg}`)
|
||||
}
|
||||
|
||||
shouldWriteFile = true
|
||||
}
|
||||
|
||||
if (shouldWriteFile) {
|
||||
await fs.writeJson(pkgJsonPath, json, { spaces: 2 })
|
||||
}
|
||||
@@ -164,9 +169,8 @@ export const replaceLocalNpmVersions = async function (basePath: string) {
|
||||
}
|
||||
|
||||
export async function removeLocalNpmDirs (distPath: string, except: string[]) {
|
||||
const toRemove = await globby(`${distPath}/npm/*`, {
|
||||
ignore: except.map((e) => e.replace('/package.json', '')),
|
||||
onlyDirectories: true,
|
||||
const toRemove = await globAsync(`${distPath}/npm/*/`, {
|
||||
ignore: except,
|
||||
})
|
||||
|
||||
for (const dir of toRemove) {
|
||||
|
||||
@@ -29,10 +29,6 @@ const formHashFromEnvironment = function () {
|
||||
return `circle-${env.CIRCLE_BRANCH}-${env.CIRCLE_SHA1}`
|
||||
}
|
||||
|
||||
if (env.APPVEYOR) {
|
||||
return `appveyor-${env.APPVEYOR_REPO_BRANCH}-${env.APPVEYOR_REPO_COMMIT}`
|
||||
}
|
||||
|
||||
throw new Error('Do not know how to form unique build hash on this CI')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user