Skip to content

Commit

Permalink
Merge pull request #191 from Polymer/fixswap
Browse files Browse the repository at this point in the history
Fix git checkout bug and improve dependency swapping
  • Loading branch information
aomarks authored Sep 11, 2020
2 parents 0030606 + f284801 commit 5a742c2
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 124 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
project adheres to [Semantic Versioning](http://semver.org/).

<!-- ## Unreleased -->
## Unreleased

- Fix `git checkout` errors when using advanced git-based dependency swapping.

- When using dependency swapping, a fresh install will now be performed whenever
any dependency version has changed (either in the original `package.json`, or
in the dependency-swap configuration). The `label` field is no longer
significant in this respect.

- When using advanced git-based dependency swapping `{kind: 'git', ...}`, a
query will now always be made to the remote git repo to determine if the
configured `ref` is still up to date. If it is stale, a fresh install will be
performed.

- When using dependency swapping, temp directories will be deleted when there is
an installation failure, so that they are not re-used in a broken state.

## [0.5.2] 2020-09-08

Expand Down
30 changes: 15 additions & 15 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"additionalProperties": false,
"properties": {
"dependencies": {
"$ref": "#/definitions/PackageDependencyMap",
"$ref": "#/definitions/ExtendedPackageDependencyMap",
"description": "Map from NPM package to version. Any version syntax supported by NPM is\nsupported here."
},
"label": {
Expand Down Expand Up @@ -226,6 +226,20 @@
],
"type": "object"
},
"ExtendedPackageDependencyMap": {
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/GitDependency"
},
{
"type": "string"
}
]
},
"description": "Tachometer's extensions to the NPM \"dependencies\" field, which allows for\nmore advanced configurations.",
"type": "object"
},
"FirefoxConfig": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -333,20 +347,6 @@
],
"type": "object"
},
"PackageDependencyMap": {
"additionalProperties": {
"anyOf": [
{
"$ref": "#/definitions/GitDependency"
},
{
"type": "string"
}
]
},
"description": "A mapping from NPM package name to version specifier, as used in a\npackage.json's \"dependencies\" and \"devDependencies\".",
"type": "object"
},
"PerformanceEntryMeasurement": {
"additionalProperties": false,
"properties": {
Expand Down
4 changes: 2 additions & 2 deletions src/configfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as jsonschema from 'jsonschema';
import {BrowserConfig, BrowserName, parseBrowserConfigString, validateBrowserConfig} from './browser';
import {Config, parseHorizons, urlFromLocalPath} from './config';
import * as defaults from './defaults';
import {BenchmarkSpec, Measurement, measurements, PackageDependencyMap} from './types';
import {BenchmarkSpec, ExtendedPackageDependencyMap, Measurement, measurements} from './types';
import {isHttpUrl} from './util';

/**
Expand Down Expand Up @@ -266,7 +266,7 @@ interface ConfigFilePackageVersion {
* Map from NPM package to version. Any version syntax supported by NPM is
* supported here.
*/
dependencies: PackageDependencyMap;
dependencies: ExtendedPackageDependencyMap;
}

/**
Expand Down
17 changes: 13 additions & 4 deletions src/test/versions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as path from 'path';

import * as defaults from '../defaults';
import {BenchmarkSpec} from '../types';
import {hashStrings, makeServerPlans, ServerPlan} from '../versions';
import {hashStrings, makeServerPlans, ServerPlan, tachometerVersion} from '../versions';
import {testData} from './test_helpers';

const defaultBrowser = {
Expand Down Expand Up @@ -119,8 +119,14 @@ suite('versions', () => {
const {plans: actualPlans, gitInstalls: actualGitInstalls} =
await makeServerPlans(testData, tempDir, specs);

const v1Hash = hashStrings(path.join(testData, 'mylib'), 'v1');
const v2Hash = hashStrings(path.join(testData, 'mylib'), 'v2');
const v1Hash = hashStrings(
tachometerVersion,
path.join(testData, 'mylib', 'package.json'),
JSON.stringify([['mylib', '1.0.0'], ['otherlib', '0.0.0']]));
const v2Hash = hashStrings(
tachometerVersion,
path.join(testData, 'mylib', 'package.json'),
JSON.stringify([['mylib', '2.0.0'], ['otherlib', '0.0.0']]));

const expectedPlans: ServerPlan[] = [
{
Expand Down Expand Up @@ -217,7 +223,10 @@ suite('versions', () => {
const {plans: actualPlans, gitInstalls: actualGitInstalls} =
await makeServerPlans(path.join(testData, 'mylib'), tempDir, specs);

const v1Hash = hashStrings(path.join(testData, 'mylib'), 'v1');
const v1Hash = hashStrings(
tachometerVersion,
path.join(testData, 'mylib', 'package.json'),
JSON.stringify([['mylib', '1.0.0'], ['otherlib', '0.0.0']]));
const expectedPlans: ServerPlan[] = [
{
specs: [specs[0]],
Expand Down
10 changes: 9 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export class Deferred<T> {
* package.json's "dependencies" and "devDependencies".
*/
export interface PackageDependencyMap {
[pkg: string]: string;
}

/**
* Tachometer's extensions to the NPM "dependencies" field, which allows for
* more advanced configurations.
*/
export interface ExtendedPackageDependencyMap {
[pkg: string]: string|GitDependency;
}

Expand Down Expand Up @@ -58,7 +66,7 @@ export interface GitDependency {
*/
export interface PackageVersion {
label: string;
dependencyOverrides: PackageDependencyMap;
dependencyOverrides: ExtendedPackageDependencyMap;
}

/** The subset of the format of an NPM package.json file we care about. */
Expand Down
Loading

0 comments on commit 5a742c2

Please sign in to comment.