-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] enable external partner testing #5567
Merged
+166
−15
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
'use strict'; | ||
/* eslint-disable no-console, node/no-extraneous-require, node/no-unpublished-require */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { shellSync } = require('execa'); | ||
// apparently violates no-extraneous require? /shrug | ||
const debug = require('debug')('test-external'); | ||
const rimraf = require('rimraf'); | ||
|
||
const projectRoot = path.resolve(__dirname, '../../'); | ||
const externalProjectName = process.argv[2]; | ||
const gitUrl = process.argv[3]; | ||
const tempDir = path.join(projectRoot, '../__external-test-cache'); | ||
const projectTempDir = path.join(tempDir, externalProjectName); | ||
|
||
if (!gitUrl) { | ||
throw new Error( | ||
'No git url provided to `node ./lib/scripts/test-external`. An https git url should be the first argument.' | ||
); | ||
} else if (gitUrl.indexOf('https') !== 0) { | ||
throw new Error( | ||
`The git url provided to \`node ./lib/scripts/test-external\` should use https. Received '${gitUrl}'` | ||
); | ||
} | ||
|
||
console.log( | ||
`Preparing to test external project ${externalProjectName} located at ${gitUrl} against this ember-data commit.` | ||
); | ||
|
||
function execWithLog(command, force) { | ||
if (debug.enabled || force) { | ||
return shellSync(command, { stdio: [0, 1, 2] }); | ||
} | ||
|
||
return shellSync(command); | ||
} | ||
|
||
if (!fs.existsSync(tempDir)) { | ||
fs.mkdirSync(tempDir); | ||
} | ||
|
||
if (fs.existsSync(projectTempDir)) { | ||
rimraf.sync(projectTempDir); | ||
} | ||
|
||
// install the project | ||
try { | ||
execWithLog( | ||
`cd ../__external-test-cache && git clone --depth=1 ${gitUrl} ./${externalProjectName}` | ||
); | ||
} catch (e) { | ||
debug(e); | ||
throw new Error( | ||
`Install of ${gitUrl} for external project ${externalProjectName} testing failed.` | ||
); | ||
} | ||
|
||
const useYarn = fs.existsSync(path.join(projectTempDir, 'yarn.lock')); | ||
const useBower = fs.existsSync(path.join(projectTempDir, 'bower.json')); | ||
|
||
// install project dependencies and link our local version of ember-data | ||
try { | ||
execWithLog( | ||
`${ | ||
useYarn ? 'yarn link' : 'npm link' | ||
} && cd ../__external-test-cache/${externalProjectName} && ${useYarn ? 'yarn' : 'npm install'}${ | ||
useBower ? ' && bower install' : '' | ||
}` | ||
); | ||
} catch (e) { | ||
debug(e); | ||
throw new Error( | ||
`Unable to complete install of dependencies for external project ${externalProjectName}` | ||
); | ||
} | ||
|
||
// run project tests | ||
console.log(`Running tests for ${externalProjectName}`); | ||
|
||
let smokeTestPassed = true; | ||
let commitTestPassed = true; | ||
|
||
try { | ||
debug('Running Smoke Test'); | ||
execWithLog(`cd ../__external-test-cache/${externalProjectName} && ember test`); | ||
} catch (e) { | ||
smokeTestPassed = false; | ||
} | ||
|
||
try { | ||
execWithLog(`${useYarn ? 'yarn link ember-data' : 'npm link ember-data'}`); | ||
} catch (e) { | ||
debug(e); | ||
throw new Error( | ||
`Unable to \`${useYarn ? 'yarn' : 'npm'} link ember-data\` for ${externalProjectName}` | ||
); | ||
} | ||
|
||
try { | ||
debug('Re-running tests against EmberData commit'); | ||
execWithLog(`cd ../__external-test-cache/${externalProjectName} && ember test`, true); | ||
} catch (e) { | ||
commitTestPassed = false; | ||
} | ||
|
||
if (!smokeTestPassed && !commitTestPassed) { | ||
throw new Error( | ||
`Commit may result in a regression, but the smoke test for ${externalProjectName} also failed.` | ||
); | ||
} else if (smokeTestPassed && !commitTestPassed) { | ||
throw new Error(`Commit results in a regression in ${externalProjectName}`); | ||
} else if (!smokeTestPassed) { | ||
console.log(`Commit may resolve issues present in the smoke test for ${externalProjectName}`); | ||
} else { | ||
console.log(`Commit does not regress ${externalProjectName}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intend to set this up such that we can cache the repositories we test on travis and use
git pull
to get latest most of the time vs needing to blow away and start over all the time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you could shallow clone for some speed improvement and not have to worry about caching mechanisms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kategengler how does that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git clone --depth=1 <repo>
will get you just the HEAD of the repo, so you don't get all history.