Skip to content
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

Set up CI with Azure Pipelines #6495

Merged
merged 38 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b631120
Set up CI with Azure Pipelines
arcanis Oct 4, 2018
7f05fe3
Update azure-pipelines.yml
arcanis Oct 4, 2018
a1f0994
Update azure-pipelines.yml
arcanis Oct 5, 2018
573c9e7
Update package.json
arcanis Oct 5, 2018
0d801d0
Adds debug
Oct 5, 2018
3e168d7
Tries using bash
Oct 5, 2018
808eb7e
Tweaks timeouts
Oct 5, 2018
95eb3d7
Fixes various things related to the win32 compat
arcanis Oct 19, 2018
b95bbc0
I get the same 22 failed tests with/without the delay.
Nov 5, 2018
ea5810e
Fix makeFakeBinary for win32.
Nov 5, 2018
6830dd3
Check custom output instead of versions.
Nov 5, 2018
3a0c614
Remove quotes from echo (not removed in Windows).
Nov 5, 2018
c743366
Some tweaks
Nov 5, 2018
2c6949f
Fixes syntax
Nov 5, 2018
2312b35
Merge remote-tracking branch 'upstream/master' into azure-pipelines
Nov 5, 2018
596e8c1
Fixes tests on Windows
Nov 5, 2018
7c5a6be
Adds test reporting
Nov 5, 2018
c5dfc47
Fixes things (?)
Nov 5, 2018
9273271
Fixes indent
Nov 5, 2018
0c17392
Always run the test result publishing
Nov 5, 2018
420f74f
Fixes yml
Nov 5, 2018
6b2b594
Use node scripts to avoid Windows interoperability issues.
Nov 7, 2018
b7cf111
Fixes the "must use the same Node as Yarn itself" test
Nov 7, 2018
15bc762
Fixes escaping from within the tests
arcanis Nov 8, 2018
fbe8ced
Removes the accidental .only flag
arcanis Nov 8, 2018
0c4bd14
Fixes a test on Windows
arcanis Nov 8, 2018
3c1a97e
Add support for different drives in Windows.
Nov 8, 2018
990f43a
No need to getPackageLocation
Nov 9, 2018
9cf85d6
Add support for environment and arguments by using a custom solution …
Nov 9, 2018
1bbee27
Merge remote-tracking branch 'origin/master' into azure-pipelines
Nov 9, 2018
1d9ea16
Missing escape on path in pnpapi test.
Nov 9, 2018
adf5a2b
Some cleaning
arcanis Nov 12, 2018
a2dabc9
Runs tests on all three platforms
arcanis Nov 12, 2018
e786a9b
Fixes write paths
arcanis Nov 12, 2018
f96f54f
Fixes normalizePath
arcanis Nov 12, 2018
8f72462
Disables pkg-tests from CircleCI (moved to Azure)
arcanis Nov 12, 2018
3a8e9e5
Increase Windows timeouts and better name Test results (#6680)
pablonete Nov 14, 2018
649ae72
Revert "Disables pkg-tests from CircleCI (moved to Azure)"
arcanis Nov 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
jobs:

- job: Windows
pool: 'Hosted VS2017'

variables:
os_name: Windows

strategy:
matrix:
node_8_x:
node_version: 8.x
node_10_x:
node_version: 10.x

steps:
- template: scripts/azure-run-tests.yml

- job: Linux
pool:
vmImage: 'Ubuntu 16.04'

variables:
os_name: Linux

strategy:
matrix:
node_8_x:
node_version: 8.x
node_10_x:
node_version: 10.x

steps:
- template: scripts/azure-run-tests.yml

- job: OSX
pool:
vmImage: 'macOS 10.13'

variables:
os_name: OSX

strategy:
matrix:
node_8_x:
node_version: 8.x
node_10_x:
node_version: 10.x

steps:
- template: scripts/azure-run-tests.yml
1 change: 1 addition & 0 deletions packages/pkg-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
yarn-error.log
junit.xml
3 changes: 2 additions & 1 deletion packages/pkg-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"babel-preset-flow": "^6.23.0",
"flow-bin": "^0.66.0",
"jest": "^23.0.0",
"jest-junit": "^5.2.0",
"prettier": "^1.10.2"
},
"scripts": {
Expand All @@ -25,7 +26,7 @@
},
"jest": {
"modulePathIgnorePatterns": [
"<rootDir>[/\\\\]pkg-tests-fixtures[/\\\\]packages[/\\\\]"
"<rootDir>/pkg-tests-fixtures/packages/"
]
}
}
2 changes: 2 additions & 0 deletions packages/pkg-tests/pkg-tests-core/sources/utils/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ exports.execFile = function(
if (error) {
reject(error);
} else {
stdout = stdout.replace(/\r\n?/g, `\n`);
stderr = stderr.replace(/\r\n?/g, `\n`);
resolve({stdout, stderr});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ no need for explicit template string use above.

}
});
Expand Down
17 changes: 11 additions & 6 deletions packages/pkg-tests/pkg-tests-core/sources/utils/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const zlib = require('zlib');

const miscUtils = require('./misc');

const IS_WIN32 = process.platform === `win32`;

exports.walk = function walk(
source: string,
{filter, relative = false}: {|filter?: Array<string>, relative?: boolean|} = {},
Expand Down Expand Up @@ -75,13 +77,13 @@ exports.packToStream = function packToStream(
const packStream = tarFs.pack(source, {
map: header => {
if (true) {
header.name = path.resolve('/', header.name);
header.name = path.relative('/', header.name);
header.name = path.posix.resolve('/', header.name);
header.name = path.posix.relative('/', header.name);
}

if (virtualPath) {
header.name = path.resolve('/', virtualPath, header.name);
header.name = path.relative('/', header.name);
header.name = path.posix.resolve('/', virtualPath, header.name);
header.name = path.posix.relative('/', header.name);
}

return header;
Expand Down Expand Up @@ -186,6 +188,9 @@ exports.makeFakeBinary = async function(
target: string,
{output = `Fake binary`, exitCode = 1}: {|output: string, exitCode: number|} = {},
): Promise<void> {
await exports.writeFile(target, `#!/bin/sh\necho "${output}"\nexit ${exitCode}\n`);
await exports.chmod(target, 0o755);
const realTarget = IS_WIN32 ? `${target}.cmd` : target;
const header = IS_WIN32 ? `@echo off\n` : `#!/bin/sh\n`;

await exports.writeFile(realTarget, `${header}echo ${output}\nexit ${exitCode}\n`);
await exports.chmod(realTarget, 0o755);
};
6 changes: 6 additions & 0 deletions packages/pkg-tests/pkg-tests-core/sources/utils/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,9 @@ exports.generatePkgDriver = function generatePkgDriver({runDriver}: {|runDriver:

return withConfig({});
};

exports.testIf = function testIf(condition, ...args) {
if (condition()) {
test(...args);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "no-deps-scripted",
"version": "1.0.0",
"scripts": {
"preinstall": "echo 'module.exports.push(100);' >> log.js",
"install": "echo 'module.exports.push(200);' >> log.js",
"postinstall": "echo 'module.exports.push(300);' >> log.js; echo 'module.exports = '\"$(node -p 'Math.floor(Math.random() * 512000)')\"';' > rnd.js"
"preinstall": "node scripts/preinstall",
"install": "node scripts/install",
"postinstall": "node scripts/postinstall"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const fs = require(`fs`);

fs.appendFileSync(`${__dirname}/../log.js`, `module.exports.push('install');`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const fs = require(`fs`);

fs.appendFileSync(`${__dirname}/../log.js`, `module.exports.push('postinstall');`);
fs.appendFileSync(`${__dirname}/../rnd.js`, `module.exports = ${Math.floor(Math.random() * 512000)};`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const fs = require(`fs`);

fs.appendFileSync(`${__dirname}/../log.js`, `module.exports.push('preinstall');`);
19 changes: 11 additions & 8 deletions packages/pkg-tests/pkg-tests-specs/sources/pnp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {satisfies} = require('semver');

const {
fs: {createTemporaryFolder, readFile, readJson, writeFile, writeJson},
tests: {getPackageDirectoryPath},
tests: {getPackageDirectoryPath, testIf},
} = require('pkg-tests-core');

module.exports = makeTemporaryEnv => {
Expand Down Expand Up @@ -312,7 +312,7 @@ module.exports = makeTemporaryEnv => {
makeTemporaryEnv(
{
dependencies: {[`no-deps`]: `1.0.0`},
scripts: {myScript: `node -p 'require("no-deps/package.json").version'`},
scripts: {myScript: `node -p "require('no-deps/package.json').version"`},
},
{
plugNPlay: true,
Expand Down Expand Up @@ -574,7 +574,7 @@ module.exports = makeTemporaryEnv => {

await writeFile(`${tmp}/folder/index.js`, `module.exports = 42;`);

await expect(source(`require("${tmp}/folder")`)).resolves.toEqual(42);
await expect(source(`require(${JSON.stringify(tmp)} + "/folder")`)).resolves.toEqual(42);
}),
);

Expand All @@ -587,7 +587,7 @@ module.exports = makeTemporaryEnv => {

await writeFile(`${tmp}/file.js`, `module.exports = 42;`);

await expect(source(`require("${tmp}/file")`)).resolves.toEqual(42);
await expect(source(`require(${JSON.stringify(tmp)} + "/file")`)).resolves.toEqual(42);
}),
);

Expand All @@ -601,7 +601,7 @@ module.exports = makeTemporaryEnv => {
await writeFile(`${tmp}/node_modules/dep/index.js`, `module.exports = 42;`);
await writeFile(`${tmp}/index.js`, `require('dep')`);

await source(`require("${tmp}/index.js")`);
await source(`require(${JSON.stringify(tmp)} + "/index.js")`);
}),
);

Expand Down Expand Up @@ -724,7 +724,8 @@ module.exports = makeTemporaryEnv => {
),
);

test(
testIf(
() => process.platform !== 'win32',
`it should generate a file that can be used as an executable to resolve a request (valid request)`,
makeTemporaryEnv(
{
Expand Down Expand Up @@ -753,7 +754,8 @@ module.exports = makeTemporaryEnv => {
),
);

test(
testIf(
() => process.platform !== `win32`,
`it should generate a file that can be used as an executable to resolve a request (builtin request)`,
makeTemporaryEnv(
{
Expand All @@ -777,7 +779,8 @@ module.exports = makeTemporaryEnv => {
),
);

test(
testIf(
() => process.platform !== `win32`,
`it should generate a file that can be used as an executable to resolve a request (invalid request)`,
makeTemporaryEnv(
{
Expand Down
20 changes: 12 additions & 8 deletions packages/pkg-tests/pkg-tests-specs/sources/pnpapi-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ module.exports = makeTemporaryEnv => {
makeTemporaryEnv({}, {plugNPlay: true}, async ({path, run, source}) => {
await run(`install`);

await expect(source(`require('pnpapi').resolveRequest('pnpapi', '${path}/')`)).resolves.toEqual(
normalize(`${path}/.pnp.js`),
);
await expect(
source(`require('pnpapi').resolveRequest('pnpapi', ${JSON.stringify(path + '/')})`),
).resolves.toEqual(normalize(`${path}/.pnp.js`));
}),
);

Expand All @@ -56,7 +56,9 @@ module.exports = makeTemporaryEnv => {
makeTemporaryEnv({}, {plugNPlay: true}, async ({path, run, source}) => {
await run(`install`);

await expect(source(`require('pnpapi').resolveRequest('fs', '${path}/')`)).resolves.toEqual(null);
await expect(
source(`require('pnpapi').resolveRequest('fs', ${JSON.stringify(path)} + '/')`),
).resolves.toEqual(null);
}),
);

Expand All @@ -77,8 +79,10 @@ module.exports = makeTemporaryEnv => {
await run(`install`);

await expect(
source(`require('pnpapi').resolveRequest('fs', '${path}/', {considerBuiltins: false})`),
).resolves.toEqual(`${path}/fs/index.js`);
source(
`require('pnpapi').resolveRequest('fs', ${JSON.stringify(path)} + '/', {considerBuiltins: false})`,
),
).resolves.toEqual(normalize(`${path}/fs/index.js`));
},
),
);
Expand All @@ -91,8 +95,8 @@ module.exports = makeTemporaryEnv => {
await run(`install`);

await expect(
source(`require('pnpapi').resolveRequest('./foo', '${path}/', {extensions: ['.bar']})`),
).resolves.toEqual(`${path}/foo.bar`);
source(`require('pnpapi').resolveRequest('./foo', ${JSON.stringify(path)} + '/', {extensions: ['.bar']})`),
).resolves.toEqual(normalize(`${path}/foo.bar`));
}),
);
});
Expand Down
18 changes: 9 additions & 9 deletions packages/pkg-tests/pkg-tests-specs/sources/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ module.exports = (makeTemporaryEnv: PackageDriver) => {
test(
`it should run scripts using the same Node than the one used by Yarn`,
makeTemporaryEnv({scripts: {myScript: `node --version`}}, async ({path, run, source}) => {
await makeFakeBinary(`${path}/bin/node`);
await makeFakeBinary(`${path}/bin/node`, {exitCode: 1});

await expect(run(`run`, `myScript`)).resolves.toMatchObject({
stdout: `${process.version}\n`,
});
await expect(run(`run`, `myScript`)).resolves.toBeTruthy();
}),
);

test(
`it should run scripts using the same package manager than the one running the scripts`,
makeTemporaryEnv({scripts: {myScript: `yarn --version`}}, async ({path, run, source}) => {
await makeFakeBinary(`${path}/bin/yarn`);
await makeFakeBinary(`${path}/bin/yarn`, {exitCode: 1});

await expect(run(`run`, `myScript`)).resolves.toMatchObject({
stdout: (await run(`--version`)).stdout,
});
await expect(run(`run`, `myScript`)).resolves.toBeTruthy();
}),
);

Expand Down Expand Up @@ -200,7 +196,11 @@ module.exports = (makeTemporaryEnv: PackageDriver) => {
makeTemporaryEnv({dependencies: {[`no-deps-scripted`]: `1.0.0`}}, async ({path, run, source}) => {
await run(`install`);

await expect(source(`require('no-deps-scripted/log.js')`)).resolves.toEqual([100, 200, 300]);
await expect(source(`require('no-deps-scripted/log.js')`)).resolves.toEqual([
'preinstall',
'install',
'postinstall',
]);
}),
);
});
Expand Down