-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: run e2e tests on pre-compiled packages
The NPM packages being tested must be pre-compiled and the tar packages specified via --package. This way the real packages such as snapshots, release artifacts or cached packages can be tested. Previously the e2e tests compiled and packaged during test execution.
- Loading branch information
1 parent
aeb5233
commit 2624d89
Showing
12 changed files
with
138 additions
and
41 deletions.
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import { getGlobalVariable } from '../utils/env'; | ||
import { PkgInfo } from '../utils/packages'; | ||
import { globalNpm, extractNpmEnv } from '../utils/process'; | ||
import { isPrereleaseCli } from '../utils/project'; | ||
|
||
export default async function () { | ||
const testRegistry: string = getGlobalVariable('package-registry'); | ||
await globalNpm( | ||
[ | ||
'run', | ||
'admin', | ||
'--', | ||
'publish', | ||
'--no-versionCheck', | ||
'--no-branchCheck', | ||
`--registry=${testRegistry}`, | ||
'--tag', | ||
isPrereleaseCli() ? 'next' : 'latest', | ||
], | ||
{ | ||
...extractNpmEnv(), | ||
// Also set an auth token value for the local test registry which is required by npm 7+ | ||
// even though it is never actually used. | ||
'NPM_CONFIG__AUTH': 'e2e-testing', | ||
}, | ||
const packageTars: PkgInfo[] = Object.values(getGlobalVariable('package-tars')); | ||
|
||
// Publish packages specified with --package | ||
await Promise.all( | ||
packageTars.map(({ path: p }) => | ||
globalNpm( | ||
[ | ||
'publish', | ||
`--registry=${testRegistry}`, | ||
'--tag', | ||
isPrereleaseCli() ? 'next' : 'latest', | ||
p, | ||
], | ||
{ | ||
...extractNpmEnv(), | ||
// Also set an auth token value for the local test registry which is required by npm 7+ | ||
// even though it is never actually used. | ||
'NPM_CONFIG__AUTH': 'e2e-testing', | ||
}, | ||
), | ||
), | ||
); | ||
} |
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
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
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,39 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import fs from 'fs'; | ||
import { normalize } from 'path'; | ||
import { Parse } from 'tar'; | ||
|
||
/** | ||
* Extract and return the contents of a single file out of a tar file. | ||
* | ||
* @param tarball the tar file to extract from | ||
* @param filePath the path of the file to extract | ||
* @returns the Buffer of file or an error on fs/tar error or file not found | ||
*/ | ||
export async function extractFile(tarball: string, filePath: string): Promise<Buffer> { | ||
return new Promise((resolve, reject) => { | ||
fs.createReadStream(tarball) | ||
.pipe( | ||
new Parse({ | ||
strict: true, | ||
filter: (p) => normalize(p) === normalize(filePath), | ||
// TODO: @types/tar 'entry' does not have ReadEntry.on | ||
onentry: (entry: any) => { | ||
const chunks: Buffer[] = []; | ||
|
||
entry.on('data', (chunk: any) => chunks!.push(chunk)); | ||
entry.on('error', reject); | ||
entry.on('finish', () => resolve(Buffer.concat(chunks!))); | ||
}, | ||
}), | ||
) | ||
.on('close', () => reject(`${tarball} does not contain ${filePath}`)); | ||
}); | ||
} |
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