1
1
import * as pj from 'projen' ;
2
2
import { yarn } from 'cdklabs-projen-project-types' ;
3
3
import path from 'path' ;
4
- import { JobPermission } from 'projen/lib/github/workflows-model' ;
5
4
6
5
export interface AwsCdkIntegrationTestOptions {
7
6
readonly workflowRunsOn : string [ ] ;
@@ -26,8 +25,15 @@ export class AwsCdkIntegrationTest extends pj.Component {
26
25
const runsOn = options . workflowRunsOn ;
27
26
const awsCdkRepo = 'aws/aws-cdk' ;
28
27
const awsCdkPath = 'aws-cdk' ;
29
- const candidateSpec = ' aws-cdk-lib-candidate' ;
28
+ const candidateSpec = path . join ( awsCdkPath , 'packages' , ' aws-cdk-lib' ) ;
30
29
const candidateSpecJobName = 'test-with-new-codegen' ;
30
+ const jsiiDiffIgnore = '.jsiidiffignore' ;
31
+ const diffIgnoreFile = path . join (
32
+ root . name ,
33
+ path . relative ( options . serviceSpec . root . outdir , options . serviceSpec . outdir ) ,
34
+ jsiiDiffIgnore ,
35
+ ) ;
36
+ options . serviceSpec . addPackageIgnore ( jsiiDiffIgnore ) ;
31
37
32
38
workflow . addJob ( candidateSpecJobName , {
33
39
runsOn,
@@ -58,50 +64,7 @@ export class AwsCdkIntegrationTest extends pj.Component {
58
64
...linkPackage ( options . serviceSpecTypes , awsCdkPath ) ,
59
65
...useSpec2Cdk ( awsCdkPath ) ,
60
66
...buildAwsCdkLib ( awsCdkRepo , awsCdkPath ) ,
61
- ...uploadSpec ( candidateSpec , awsCdkPath ) ,
62
- ] ,
63
- } ) ;
64
-
65
- /**
66
- * @TODO Separate job for now because this it is failing
67
- * Once it passes, this should be merged with the main job above
68
- */
69
- const jsiiDiffIgnore = '.jsiidiffignore' ;
70
- const diffIgnoreFile = path . join (
71
- root . name ,
72
- path . relative ( options . serviceSpec . root . outdir , options . serviceSpec . outdir ) ,
73
- jsiiDiffIgnore ,
74
- ) ;
75
- options . serviceSpec . addPackageIgnore ( jsiiDiffIgnore ) ;
76
-
77
- workflow . addJob ( 'jsii-diff' , {
78
- needs : [ candidateSpecJobName ] ,
79
- runsOn,
80
- env : {
81
- ...awsCdkLibEnv ( ) ,
82
- } ,
83
- permissions : {
84
- contents : JobPermission . READ ,
85
- } ,
86
- steps : [
87
- {
88
- name : `Checkout ${ root . name } ` ,
89
- uses : 'actions/checkout@v3' ,
90
- with : {
91
- path : root . name ,
92
- ref : '${{ github.event.pull_request.head.ref }}' ,
93
- repository : '${{ github.event.pull_request.head.repo.full_name }}' ,
94
- } ,
95
- } ,
96
- ...specFromArtifact ( candidateSpec ) ,
97
- {
98
- name : `Install jsii-diff` ,
99
- run : 'npm install jsii-diff' ,
100
- } ,
101
- {
102
- name : `Compare current and candidate spec` ,
103
- run : `npx jsii-diff --verbose --keys --ignore-file=${ diffIgnoreFile } --error-on=non-experimental npm:aws-cdk-lib@latest ${ candidateSpec } ` ,
104
- } ,
67
+ ...runJsiiDiff ( candidateSpec , diffIgnoreFile ) ,
105
68
] ,
106
69
} ) ;
107
70
}
@@ -168,43 +131,15 @@ function buildAwsCdkLib(repository: string, path: string): pj.github.workflows.S
168
131
] ;
169
132
}
170
133
171
- function uploadSpec ( artifactName : string , workingDir : string ) : pj . github . workflows . Step [ ] {
134
+ function runJsiiDiff ( specPath : string , ignoreFilePath : string ) : pj . github . workflows . Step [ ] {
172
135
return [
173
136
{
174
- name : `Prepare artifacts` ,
175
- workingDirectory : workingDir ,
176
- run : [
177
- `jq 'del(.devDependencies)' packages/aws-cdk-lib/package.json > \${{ runner.temp }}/package.json` ,
178
- `cp packages/aws-cdk-lib/.jsii \${{ runner.temp }}/.jsii` ,
179
- `cp packages/aws-cdk-lib/.jsii.gz \${{ runner.temp }}/.jsii.gz` ,
180
- ] . join ( '\n' ) ,
181
- } ,
182
- {
183
- name : `Upload spec` ,
184
- uses : 'actions/upload-artifact@v3' ,
185
- with : {
186
- name : artifactName ,
187
- 'if-no-files-found' : 'error' ,
188
- path : [ '${{ runner.temp }}/package.json' , '${{ runner.temp }}/.jsii' , '${{ runner.temp }}/.jsii.gz' ] . join ( '\n' ) ,
189
- } ,
190
- } ,
191
- ] ;
192
- }
193
-
194
- function specFromArtifact ( name : string ) : pj . github . workflows . Step [ ] {
195
- return [
196
- {
197
- name : `Download ${ name } ` ,
198
- uses : 'actions/download-artifact@v3' ,
199
- with : {
200
- name : name ,
201
- path : name ,
202
- } ,
137
+ name : `Install jsii-diff` ,
138
+ run : 'npm install -g jsii-diff' ,
203
139
} ,
204
140
{
205
- name : `Prepare dependency closure` ,
206
- workingDirectory : name ,
207
- run : 'npm install' ,
141
+ name : `Compare current and candidate spec` ,
142
+ run : `npx jsii-diff --verbose --keys --ignore-file=${ ignoreFilePath } --error-on=non-experimental npm:aws-cdk-lib@latest ${ specPath } ` ,
208
143
} ,
209
144
] ;
210
145
}
0 commit comments