* This file runs tests against the local workspace to mimic the CI build as * closely as possible. * @return {Promise }
()
| 23 | * @return {Promise<void>} |
| 24 | */ |
| 25 | async function prCheck() { |
| 26 | const runCheck = (cmd) => { |
| 27 | const {status} = timedExec(cmd); |
| 28 | if (status != 0) { |
| 29 | stopTimer(jobName, startTime); |
| 30 | throw new Error('Local PR check failed. See logs above.'); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | setLoggingPrefix(jobName); |
| 35 | const startTime = startTimer(jobName); |
| 36 | runNpmChecks(); |
| 37 | printChangeSummary(); |
| 38 | determineBuildTargets(); |
| 39 | |
| 40 | if (buildTargetsInclude(Targets.PRESUBMIT)) { |
| 41 | runCheck('amp presubmit'); |
| 42 | } |
| 43 | |
| 44 | if (buildTargetsInclude(Targets.INVALID_WHITESPACES)) { |
| 45 | runCheck('amp check-invalid-whitespaces --local_changes'); |
| 46 | } |
| 47 | |
| 48 | if (buildTargetsInclude(Targets.HTML_FIXTURES)) { |
| 49 | runCheck('amp validate-html-fixtures --local_changes'); |
| 50 | } |
| 51 | |
| 52 | if (buildTargetsInclude(Targets.LINT_RULES)) { |
| 53 | runCheck('amp lint'); |
| 54 | } else if (buildTargetsInclude(Targets.LINT)) { |
| 55 | runCheck('amp lint --local_changes'); |
| 56 | } |
| 57 | |
| 58 | if (buildTargetsInclude(Targets.PRETTIFY)) { |
| 59 | runCheck('amp prettify --local_changes'); |
| 60 | } |
| 61 | |
| 62 | if (buildTargetsInclude(Targets.AVA)) { |
| 63 | runCheck('amp ava'); |
| 64 | } |
| 65 | |
| 66 | if (buildTargetsInclude(Targets.BUILD_SYSTEM)) { |
| 67 | runCheck('amp check-build-system'); |
| 68 | } |
| 69 | |
| 70 | if (buildTargetsInclude(Targets.BABEL_PLUGIN)) { |
| 71 | runCheck('amp babel-plugin-tests'); |
| 72 | } |
| 73 | |
| 74 | if (buildTargetsInclude(Targets.DOCS)) { |
| 75 | runCheck('amp check-links --local_changes'); |
| 76 | } |
| 77 | |
| 78 | if (buildTargetsInclude(Targets.OWNERS)) { |
| 79 | runCheck('amp check-owners'); |
| 80 | } |
| 81 | |
| 82 | if (buildTargetsInclude(Targets.PACKAGE_UPGRADE)) { |
nothing calls this directly
no test coverage detected