-
Notifications
You must be signed in to change notification settings - Fork 12k
ci: add ts api guardian #12010
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
Merged
Merged
ci: add ts api guardian #12010
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d13ace8
refactor: fix `import` and `export` paths to work with classic resolu…
alan-agius4 6cca037
build: add `npm_package` to packages
alan-agius4 72c770a
build: add ts-api-guardian to repo
alan-agius4 1dc4bb9
test: add api golden files
alan-agius4 1f2357c
refactor: use proper namespace instead of alias export
alan-agius4 1c336e6
refactor: use proper namspace einstead of alias export
alan-agius4 d34c58e
build: add `_golden_api` files
alan-agius4 c1b47bd
build: update angular archive for workspace
alan-agius4 a1d9ba2
test: fix reference to `TestHost` to use namespace
alan-agius4 ee6a8b2
refactor: create `fs` namespace instead of aliased export
alan-agius4 ea43163
test: update api golden file for `@angular-devkit/core/node`
alan-agius4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,50 @@ | ||
load("@angular//tools/ts-api-guardian:index.bzl", "ts_api_guardian_test") | ||
|
||
[ts_api_guardian_test( | ||
name = "%s_%s_%sapi" % ( | ||
bundle[0], | ||
bundle[1], | ||
bundle[2].replace("src/", "").replace("index", "").replace("_golden-api", "").replace("/", "_"), | ||
), | ||
actual = "angular_cli/packages/%s/%s/npm_package/%s.d.ts" % ( | ||
bundle[0], | ||
bundle[1], | ||
bundle[2], | ||
), | ||
data = glob([ | ||
"%s/%s/**/*.d.ts" % ( | ||
bundle[0], | ||
bundle[1], | ||
), | ||
]) + [ | ||
"//packages/%s/%s:npm_package" % ( | ||
bundle[0], | ||
bundle[1], | ||
), | ||
], | ||
golden = "angular_cli/etc/api/%s/%s/%s.d.ts" % ( | ||
bundle[0], | ||
bundle[1], | ||
bundle[2], | ||
), | ||
# We don't want to analyse these exports nor add them to the golden files | ||
# in most cases it's because Ts API Guardian doesn't support Symbol Aliases. | ||
strip_export_pattern = [ | ||
# @angular-devkit/schematics | ||
"^workflow$", | ||
"^formats$", | ||
# @angular-devkit/build-optimizer | ||
"^buildOptimizerLoader$", | ||
], | ||
allow_module_identifiers = [ | ||
"fs", | ||
"ts", | ||
"ajv", | ||
"Symbol", | ||
"webpack", | ||
], | ||
# At the moment using this will ignore a big change | ||
use_angular_tag_rules = False, | ||
) for bundle in [b[:-len(".d.ts")].split("/", 2) for b in glob( | ||
["**/*.d.ts"], | ||
)]] |
This file contains hidden or 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,102 @@ | ||
export declare class Architect { | ||
constructor(_workspace: experimental.workspace.Workspace); | ||
getBuilder<OptionsT>(builderDescription: BuilderDescription, context: BuilderContext): Builder<OptionsT>; | ||
getBuilderConfiguration<OptionsT>(targetSpec: TargetSpecifier): BuilderConfiguration<OptionsT>; | ||
getBuilderDescription<OptionsT>(builderConfig: BuilderConfiguration<OptionsT>): Observable<BuilderDescription>; | ||
listProjectTargets(projectName: string): string[]; | ||
loadArchitect(): Observable<this>; | ||
run<OptionsT>(builderConfig: BuilderConfiguration<OptionsT>, partialContext?: Partial<BuilderContext>): Observable<BuildEvent>; | ||
validateBuilderOptions<OptionsT>(builderConfig: BuilderConfiguration<OptionsT>, builderDescription: BuilderDescription): Observable<BuilderConfiguration<OptionsT>>; | ||
} | ||
|
||
export declare class ArchitectNotYetLoadedException extends BaseException { | ||
constructor(); | ||
} | ||
|
||
export interface Builder<OptionsT> { | ||
run(builderConfig: BuilderConfiguration<Partial<OptionsT>>): Observable<BuildEvent>; | ||
} | ||
|
||
export declare class BuilderCannotBeResolvedException extends BaseException { | ||
constructor(builder: string); | ||
} | ||
|
||
export interface BuilderConfiguration<OptionsT = {}> { | ||
builder: string; | ||
options: OptionsT; | ||
projectType: string; | ||
root: Path; | ||
sourceRoot?: Path; | ||
} | ||
|
||
export interface BuilderConstructor<OptionsT> { | ||
new (context: BuilderContext): Builder<OptionsT>; | ||
} | ||
|
||
export interface BuilderContext { | ||
architect: Architect; | ||
host: virtualFs.Host<{}>; | ||
logger: logging.Logger; | ||
workspace: experimental.workspace.Workspace; | ||
} | ||
|
||
export interface BuilderDescription { | ||
description: string; | ||
name: string; | ||
schema: JsonObject; | ||
} | ||
|
||
export declare class BuilderNotFoundException extends BaseException { | ||
constructor(builder: string); | ||
} | ||
|
||
export interface BuilderPaths { | ||
class: Path; | ||
description: string; | ||
schema: Path; | ||
} | ||
|
||
export interface BuilderPathsMap { | ||
builders: { | ||
[k: string]: BuilderPaths; | ||
}; | ||
} | ||
|
||
export interface BuildEvent { | ||
success: boolean; | ||
} | ||
|
||
export declare class ConfigurationNotFoundException extends BaseException { | ||
constructor(projectName: string, configurationName: string); | ||
} | ||
|
||
export declare class ProjectNotFoundException extends BaseException { | ||
constructor(projectName: string); | ||
} | ||
|
||
export interface Target<T = JsonObject> { | ||
builder: string; | ||
configurations?: { | ||
[k: string]: TargetConfiguration<T>; | ||
}; | ||
options: TargetOptions<T>; | ||
} | ||
|
||
export declare type TargetConfiguration<T = JsonObject> = Partial<T>; | ||
|
||
export interface TargetMap { | ||
[k: string]: Target; | ||
} | ||
|
||
export declare class TargetNotFoundException extends BaseException { | ||
constructor(projectName: string, targetName: string); | ||
} | ||
|
||
export declare type TargetOptions<T = JsonObject> = T; | ||
|
||
export interface TargetSpecifier<OptionsT = {}> { | ||
configuration?: string; | ||
overrides?: Partial<OptionsT>; | ||
project: string; | ||
target: string; | ||
} |
This file contains hidden or 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,28 @@ | ||
export declare const DefaultTimeout = 45000; | ||
|
||
export declare function request(url: string, headers?: {}): Promise<string>; | ||
|
||
export declare function runTargetSpec(host: TestProjectHost, targetSpec: TargetSpecifier, overrides?: {}, timeout?: number, logger?: logging.Logger): Observable<BuildEvent>; | ||
|
||
export declare class TestLogger extends logging.Logger { | ||
constructor(name: string, parent?: logging.Logger | null); | ||
clear(): void; | ||
includes(message: string): boolean; | ||
test(re: RegExp): boolean; | ||
} | ||
|
||
export declare class TestProjectHost extends NodeJsSyncHost { | ||
protected _templateRoot: Path; | ||
constructor(_templateRoot: Path); | ||
appendToFile(path: string, str: string): void; | ||
copyFile(from: string, to: string): void; | ||
fileMatchExists(dir: string, regex: RegExp): PathFragment | undefined; | ||
initialize(): Observable<void>; | ||
replaceInFile(path: string, match: RegExp | string, replacement: string): void; | ||
restore(): Observable<void>; | ||
root(): Path; | ||
scopedSync(): virtualFs.SyncDelegateHost<Stats>; | ||
writeMultipleFiles(files: { | ||
[path: string]: string | ArrayBufferLike | Buffer; | ||
}): void; | ||
} |
This file contains hidden or 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,91 @@ | ||
export interface AggregatedMetric extends Metric { | ||
componentValues: number[]; | ||
} | ||
|
||
export interface AggregatedProcessStats { | ||
cpu: number; | ||
ctime: number; | ||
elapsed: number; | ||
memory: number; | ||
pid: number; | ||
ppid: number; | ||
processes: number; | ||
timestamp: number; | ||
} | ||
|
||
export declare const aggregateMetricGroups: (g1: MetricGroup, g2: MetricGroup) => MetricGroup; | ||
|
||
export declare const aggregateMetrics: (m1: Metric | AggregatedMetric, m2: Metric | AggregatedMetric) => AggregatedMetric; | ||
|
||
export declare type BenchmarkReporter = (command: Command, groups: MetricGroup[]) => void; | ||
|
||
export declare type Capture = (process: MonitoredProcess) => Observable<MetricGroup>; | ||
|
||
export declare class Command { | ||
args: string[]; | ||
cmd: string; | ||
cwd: string; | ||
expectedExitCode: number; | ||
constructor(cmd: string, args?: string[], cwd?: string, expectedExitCode?: number); | ||
toString(): string; | ||
} | ||
|
||
export declare const cumulativeMovingAverage: (acc: number, val: number, accSize: number) => number; | ||
|
||
export declare const defaultReporter: (logger: logging.Logger) => BenchmarkReporter; | ||
|
||
export declare const defaultStatsCapture: Capture; | ||
|
||
export declare class LocalMonitoredProcess implements MonitoredProcess { | ||
stats$: Observable<AggregatedProcessStats>; | ||
stderr$: Observable<Buffer>; | ||
stdout$: Observable<Buffer>; | ||
constructor(command: Command); | ||
run(): Observable<number>; | ||
} | ||
|
||
export declare function main({ args, stdout, stderr, }: MainOptions): Promise<0 | 1>; | ||
|
||
export interface MainOptions { | ||
args: string[]; | ||
stderr?: ProcessOutput; | ||
stdout?: ProcessOutput; | ||
} | ||
|
||
export declare const max: (v1: number, v2: number) => number; | ||
|
||
export declare class MaximumRetriesExceeded extends BaseException { | ||
constructor(retries: number); | ||
} | ||
|
||
export interface Metric { | ||
componentValues?: number[]; | ||
name: string; | ||
unit: string; | ||
value: number; | ||
} | ||
|
||
export interface MetricGroup { | ||
metrics: (Metric | AggregatedMetric)[]; | ||
name: string; | ||
} | ||
|
||
export interface MonitoredProcess { | ||
stats$: Observable<AggregatedProcessStats>; | ||
stderr$: Observable<Buffer>; | ||
stdout$: Observable<Buffer>; | ||
run(): Observable<number>; | ||
toString(): string; | ||
} | ||
|
||
export declare function runBenchmark({ command, captures, reporters, iterations, retries, logger, }: RunBenchmarkOptions): Observable<MetricGroup[]>; | ||
|
||
export interface RunBenchmarkOptions { | ||
captures: Capture[]; | ||
command: Command; | ||
expectedExitCode?: number; | ||
iterations?: number; | ||
logger?: logging.Logger; | ||
reporters: BenchmarkReporter[]; | ||
retries?: number; | ||
} |
23 changes: 23 additions & 0 deletions
23
etc/api/angular_devkit/build_optimizer/src/_golden-api.d.ts
This file contains hidden or 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,23 @@ | ||
export declare function buildOptimizer(options: BuildOptimizerOptions): TransformJavascriptOutput; | ||
|
||
export default function buildOptimizerLoader(this: webpack.loader.LoaderContext, content: string, previousSourceMap: RawSourceMap): void; | ||
|
||
export declare function getFoldFileTransformer(program: ts.Program): ts.TransformerFactory<ts.SourceFile>; | ||
|
||
export declare function getImportTslibTransformer(): ts.TransformerFactory<ts.SourceFile>; | ||
|
||
export declare function getPrefixClassesTransformer(): ts.TransformerFactory<ts.SourceFile>; | ||
|
||
export declare function getPrefixFunctionsTransformer(): ts.TransformerFactory<ts.SourceFile>; | ||
|
||
export declare function getScrubFileTransformer(program: ts.Program): ts.TransformerFactory<ts.SourceFile>; | ||
|
||
export declare function getWrapEnumsTransformer(): ts.TransformerFactory<ts.SourceFile>; | ||
|
||
export declare function testImportTslib(content: string): boolean; | ||
|
||
export declare function testPrefixClasses(content: string): boolean; | ||
|
||
export declare function testScrubFile(content: string): boolean; | ||
|
||
export declare function transformJavascript(options: TransformJavascriptOptions): TransformJavascriptOutput; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.