Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Commit

Permalink
Dev Tools Upgrades
Browse files Browse the repository at this point in the history
- Changed pipeline build/tests to support Node 12 (LTS) and 13 (current)
  - Dropped Node 10
  - Added Node 13
- Added ESLint pre-commit hook
  - `eslint --fix` now runs for JS/TS files before being committed. If any
    staged files fail linting, commit will fail.
- Added `eslint-config-prettier`
  - Helps minimize conflicts between eslint and prettier configurations.
- Upgrade to TypeScript 3.8.
  - No breaking changes.
  - View changes here:
    <https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/>
- Upgrade to Jest 25
  - No breaking changes.
  - View changes here: <https://jestjs.io/blog/2020/01/21/jest-25>
- Upgrade to Prettier 2
  - No Breaking changes.
  - Default of `trailingComma`, `arrowParens`, and `endOfLine` have been
    changed. Prettier has been run on the codebase to adjust for these changes.
  - View changes here: <https://prettier.io/blog/2020/03/21/2.0.0.html>
  • Loading branch information
evanlouie committed Mar 23, 2020
1 parent 7f38950 commit 75b3584
Show file tree
Hide file tree
Showing 116 changed files with 2,491 additions and 2,024 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
module.exports = {
root: true,
env: {
node: true,
},
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
],
};
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ pr:

strategy:
matrix:
node_10_x:
node_version: 10.x
node_12_x:
node_version: 12.x
node_13_x:
node_version: 13.x
maxParallel: 2

pool:
Expand Down Expand Up @@ -55,7 +55,7 @@ steps:
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/junit.xml'
testResultsFiles: '**/junit.xml'
condition: and(eq(variables['Agent.JobStatus'], 'Succeeded'), endsWith(variables['Agent.JobName'], 'node_12_x'))

- task: PublishPipelineArtifact@1
Expand All @@ -67,7 +67,7 @@ steps:
- bash: |
[ -z "$COVERAGE_VARIANCE" ] && { echo "Missing COVERAGE_VARIANCE variable"; exit 1; }
echo "Code coverage variance value is: $COVERAGE_VARIANCE"
displayName: 'Build quality pre-validation'
displayName: 'Build quality pre-validation'
failOnStderr: true
env:
COVERAGE_VARIANCE: $(COVERAGE_VARIANCE)
Expand Down
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "shx rm -rf dist && webpack && pkg -t node12-linux-x64,node12-macos-x64,node12-win-x64 dist/spk.js && shx mv spk-{linux,macos,win.exe} dist",
"build-cmd-docs": "ts-node tools/generateDoc.ts",
"lint": "eslint 'src/**/*.ts{,x}'",
"lint-fix": "tslint --fix 'src/**/*.ts{,x}'",
"lint-fix": "eslint --fix 'src/**/*.ts{,x}'",
"format": "prettier --write 'src/**/*.ts{,x}'",
"test": "jest --rootDir src --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --coverageReporters=html",
"test-watch": "jest --watchAll",
"postinstall": "cd node_modules/azure-devops-node-api && git apply ../../patches/001-azure-devops-node.patch || true",
Expand All @@ -29,24 +30,25 @@
"@types/node-emoji": "^1.8.1",
"@types/shelljs": "^0.8.5",
"@types/uuid": "^3.4.5",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"husky": ">=1",
"jest": "^24.9.0",
"jest-junit": "^9.0.0",
"jest": "^25.1.0",
"jest-junit": "^10.0.0",
"jest-when": "^2.7.0",
"lint-staged": ">=8",
"lint-staged": ">=10",
"mock-fs": "^4.10.2",
"nyc": "^14.1.1",
"pkg": "^4.4.0",
"prettier": "^1.19.1",
"prettier": "^2.0.1",
"shx": "^0.3.2",
"ts-jest": "^24.2.0",
"ts-loader": "^6.2.1",
"ts-node": "^8.5.4",
"ts-jest": "^25.2.1",
"ts-loader": "^6.2.2",
"ts-node": "^8.8.1",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.4",
"typescript": "^3.8.3",
"url-loader": "^3.0.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9"
Expand All @@ -60,10 +62,10 @@
}
},
"lint-staged": {
"*.{ts,tsx,js,jsx,css,json,md}": [
"prettier --write",
"git add"
]
"*.{js,jsx,ts,tsx}": [
"eslint --cache --fix"
],
"*.{js,jsx,ts,tsx,json,css,md}": "prettier --write"
},
"dependencies": {
"@azure/arm-containerregistry": "^7.0.0",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ export const Command = (
}

// Catch-all for unknown commands
cmd.on("command:*", calledCmd => {
cmd.on("command:*", (calledCmd) => {
logger.error(`Unknown command "${calledCmd}"`);
cmd.outputHelp();
});
cmd.on("option:*", unknownOption => {
cmd.on("option:*", (unknownOption) => {
logger.error(`Unknown option "${unknownOption}"`);
});

return linkSubCommands({
command: cmd,
description,
name: name.toLowerCase(),
subCommands
subCommands,
});
};

Expand Down Expand Up @@ -125,7 +125,7 @@ const decrementArgv = (argv: string[]): string[] => {
export const executeCommand = (cmd: Command, argv: string[]): void => {
const targetCommandName = argv.slice(2, 3)[0];
const targetCommand = cmd.subCommands.find(
sc => sc.name === targetCommandName
(sc) => sc.name === targetCommandName
);

// If the the next argument matches against a sub-command, recur into it.
Expand Down
10 changes: 5 additions & 5 deletions src/commands/deployment/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const MOCKED_VALS: CommandOptions = {
pr: undefined,
repository: undefined,
service: undefined,
tableName: undefined
tableName: undefined,
};

const getMockedValues = (withKeyValue = false): CommandOptions => {
Expand Down Expand Up @@ -72,7 +72,7 @@ describe("test execute function", () => {
commitId: uuid(),
imageTag: uuid(),
p1: uuid(),
service: uuid()
service: uuid(),
})
);
const exitFn = jest.fn();
Expand Down Expand Up @@ -122,7 +122,7 @@ describe("test execute function", () => {
imageTag: uuid(),
p1: uuid(),
p2: uuid(),
service: uuid()
service: uuid(),
})
);
const exitFn = jest.fn();
Expand Down Expand Up @@ -165,7 +165,7 @@ describe("test execute function", () => {
p1: uuid(),
p2: uuid(),
p3: uuid(),
service: uuid()
service: uuid(),
})
);
const exitFn = jest.fn();
Expand Down Expand Up @@ -205,7 +205,7 @@ describe("test execute function", () => {
p1: uuid(),
p2: uuid(),
p3: uuid(),
service: uuid()
service: uuid(),
})
);
const exitFn = jest.fn();
Expand Down
4 changes: 2 additions & 2 deletions src/commands/deployment/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
DeploymentTable,
updateACRToHLDPipeline,
updateHLDToManifestPipeline,
updateManifestCommitId
updateManifestCommitId,
} from "../../lib/azure/deploymenttable";
import { build as buildCmd, exit as exitCmd } from "../../lib/commandBuilder";
import { hasValue } from "../../lib/validator";
Expand Down Expand Up @@ -121,7 +121,7 @@ export const execute = async (
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
partitionKey: opts.partitionKey!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
tableName: opts.tableName!
tableName: opts.tableName!,
};

if (hasValue(opts.p1)) {
Expand Down
46 changes: 24 additions & 22 deletions src/commands/deployment/dashboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/camelcase */

jest.mock("open");
import open from "open";
jest.mock("../../config");
Expand All @@ -7,14 +9,14 @@ import { validatePrereqs } from "../../lib/validator";
import {
disableVerboseLogging,
enableVerboseLogging,
logger
logger,
} from "../../logger";
import {
execute,
extractManifestRepositoryInformation,
getEnvVars,
launchDashboard,
validateValues
validateValues,
} from "./dashboard";
import * as dashboard from "./dashboard";

Expand All @@ -30,20 +32,20 @@ afterAll(() => {

const mockConfig = (): void => {
(Config as jest.Mock).mockReturnValueOnce({
"azure_devops": {
"access_token": uuid(),
azure_devops: {
access_token: uuid(),
org: uuid(),
project: uuid()
project: uuid(),
},
introspection: {
azure: {
"account_name": uuid(),
account_name: uuid(),
key: uuid(),
"partition_key": uuid(),
"source_repo_access_token": "test_token",
"table_name": uuid()
}
}
partition_key: uuid(),
source_repo_access_token: "test_token",
table_name: uuid(),
},
},
});
};

Expand All @@ -53,7 +55,7 @@ describe("Test validateValues function", () => {
try {
validateValues(config, {
port: "abc",
removeAll: false
removeAll: false,
});
expect(true).toBe(false);
} catch (e) {
Expand All @@ -68,7 +70,7 @@ describe("Test validateValues function", () => {
{},
{
port: "4000",
removeAll: false
removeAll: false,
}
);
expect(true).toBe(false);
Expand All @@ -83,7 +85,7 @@ describe("Test validateValues function", () => {
const config = Config();
validateValues(config, {
port: "4000",
removeAll: false
removeAll: false,
});
});
});
Expand All @@ -100,7 +102,7 @@ describe("Test execute function", () => {
await execute(
{
port: "4000",
removeAll: false
removeAll: false,
},
exitFn
);
Expand All @@ -112,7 +114,7 @@ describe("Test execute function", () => {
await execute(
{
port: "4000",
removeAll: false
removeAll: false,
},
exitFn
);
Expand All @@ -133,7 +135,7 @@ describe("Validate dashboard container pull", () => {
"images",
"-q",
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
config.introspection!.dashboard!.image!
config.introspection!.dashboard!.image!,
]);
expect(dockerId).toBeDefined();
expect(dashboardContainerId).not.toBe("");
Expand All @@ -160,7 +162,7 @@ describe("Validate dashboard clean up", () => {
"images",
"-q",
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
config.introspection!.dashboard!.image!
config.introspection!.dashboard!.image!,
]);

expect(dockerId).toBeDefined();
Expand Down Expand Up @@ -208,10 +210,10 @@ describe("Fallback to azure devops access token", () => {
describe("Extract manifest repository information", () => {
test("Manifest repository information is successfully extracted", () => {
(Config as jest.Mock).mockReturnValue({
"azure_devops": {
"manifest_repository":
"https://dev.azure.com/bhnook/fabrikam/_git/materialized"
}
azure_devops: {
manifest_repository:
"https://dev.azure.com/bhnook/fabrikam/_git/materialized",
},
});
const config = Config();
let manifestInfo = extractManifestRepositoryInformation(config);
Expand Down
8 changes: 4 additions & 4 deletions src/commands/deployment/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const cleanDashboardContainers = async (
"-q",
"--filter",
"ancestor=" + config.introspection!.dashboard!.image!,
'--format="{{.ID}}"'
'--format="{{.ID}}"',
]);
if (dockerOutput.length > 0) {
dockerOutput = dockerOutput.replace(/\n/g, " ");
Expand Down Expand Up @@ -99,11 +99,11 @@ export const extractManifestRepositoryInformation = (
if (gitComponents.resource === "github.com") {
return {
githubUsername: gitComponents.organization,
manifestRepoName
manifestRepoName,
};
} else {
return {
manifestRepoName
manifestRepoName,
};
}
}
Expand Down Expand Up @@ -218,7 +218,7 @@ export const launchDashboard = async (
...(await getEnvVars(config)),
"-p",
port + ":5000",
dockerRepository
dockerRepository,
]);
return containerId;
} catch (err) {
Expand Down
Loading

0 comments on commit 75b3584

Please sign in to comment.