Skip to content

Commit

Permalink
CI: generalize wrappers generate scripts (#25459)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Bulychev <[email protected]>
  • Loading branch information
iBat and Alexander Bulychev authored Aug 30, 2023
1 parent 7349c5c commit 54b4c74
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 167 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/devextreme_angular_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: npm run build

- name: Generate wrappers
run: npm run angular:generate
run: npm run angular:regenerate

- name: Check generated code
shell: bash
Expand All @@ -56,10 +56,14 @@ jobs:
if [ -n "$changes" ]; then
echo "Generated code is outdated. The following files have uncommitted changes:"
echo "$changes";
echo "To update generated code, use "npm run angular:generate" and commit changes."
echo "To update generated code, use "npm run regenerate-all" and commit changes."
exit 1
fi
- name: Build wrappers
working-directory: ./packages/devextreme-angular
run: npm run build

- name: Run tests
working-directory: ./packages/devextreme-angular
run: npm run test:dev
Expand Down
82 changes: 0 additions & 82 deletions .github/workflows/devextreme_npm_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,87 +60,6 @@ jobs:
devextreme-dist-installer.tgz
retention-days: 1

test_angular_wrappers:
name: Angular wrapper tests
needs: build
runs-on: devextreme-shr2
timeout-minutes: 30

steps:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.16.1'

- name: Get sources
uses: actions/checkout@v3
with:
path: ./devextreme

- name: Pin browsers
uses: ./devextreme/.github/actions/pin-browsers

- name: Restore npm cache
uses: actions/cache@v3
with:
path: './devextreme/**/node_modules'
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules

- name: Install packages in devextreme repo
working-directory: ./devextreme
run: npm install --no-audit --no-fund

- name: Discover declarations in devextreme repo
working-directory: ./devextreme
run: npx nx discover-declarations devextreme-main

- name: Clone devextreme-angular repo from PR author fork
continue-on-error: true
if: github.event_name == 'pull_request'
run: |
REMOTE_URL=https://github.com/${{github.event.pull_request.user.login}}/devextreme-angular
REMOTE_BRANCH=${{github.event.pull_request.head.ref}}
if [ "$(git ls-remote --heads $REMOTE_URL $REMOTE_BRANCH | wc -l)" == "1" ]; then
git clone -b $REMOTE_BRANCH $REMOTE_URL ./devextreme-angular-repo
fi
- name: Clone devextreme-angular repo
run: |
test -d ./devextreme-angular-repo || git clone -b master https://github.com/devexpress/devextreme-angular ./devextreme-angular-repo
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: devextreme-npm
path: ./devextreme-angular-repo/devextreme-setup

- name: Install packages for devextreme-angular
working-directory: ./devextreme-angular-repo
run: npm install --no-audit --no-fund

- name: Install devextreme package
working-directory: ./devextreme-angular-repo
run: |
pushd devextreme-setup
installerName=$(realpath .)/devextreme-installer.tgz
popd
cd ./packages/devextreme-angular
npm install --save-dev --legacy-peer-deps $installerName
cd ../sandbox
npm install --save-dev --legacy-peer-deps $installerName
cd ../../
npm install --save-dev --legacy-peer-deps $installerName
- name: Build with Angular 12
working-directory: ./devextreme-angular-repo
run: npm run build

- name: Run tests with Angular 12
working-directory: ./devextreme-angular-repo/packages/devextreme-angular
run: npm run test:dev

test_bundlers:
name: Bundlers tests
needs: build
Expand Down Expand Up @@ -291,7 +210,6 @@ jobs:
name: Send notifications
needs:
- build
- test_angular_wrappers
- test_bundlers
- test_demos
if: always() && contains(needs.*.result, 'failure')
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/devextreme_react_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@ jobs:
working-directory: ./packages/devextreme-react
run: npm run lint

- name: Generate metadata
run: npm run react:discover-metadata

- name: Build generator
run: npm run react:build-generator

- name: Generate wrappers
working-directory: ./packages/devextreme-react
run: npm run generate
run: npm run react:regenerate

- name: Check generated code
shell: bash
Expand All @@ -54,7 +47,7 @@ jobs:
if [ -n "$changes" ]; then
echo "Generated code is outdated. The following files have uncommitted changes:"
echo "$changes";
echo "To update generated code, use "npm run react:generate" and commit changes."
echo "To update generated code, use "npm run regenerate-all" and commit changes."
exit 1
fi
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/devextreme_vue_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,12 @@ jobs:
working-directory: ./packages/devextreme-vue
run: npm run lint

- name: Generate metadata
run: npm run vue:discover-metadata

- name: Build generator
run: npm run vue:build-generator

- name: Build devextreme package
run: |
npx nx build devextreme-main
npx nx build devextreme-main
- name: Generate wrappers
working-directory: ./packages/devextreme-vue
run: npm run generate
run: npm run vue:regenerate

- name: Check generated code
shell: bash
Expand All @@ -63,7 +56,7 @@ jobs:
if [ -n "$changes" ]; then
echo "Generated code is outdated. The following files have uncommitted changes:"
echo "$changes";
echo "To update generated code, use "npm run vue:generate" and commit changes."
echo "To update generated code, use "npm run regenerate-all" and commit changes."
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ts_declarations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
target=./ts/dx.all.d.ts
cp $target $target.current
npm run update-ts
npm run regenerate
if ! diff $target.current $target -U 5 > $target.diff; then
echo "FAIL: $target is outdated:"
Expand Down
9 changes: 9 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
"dependsOn": [
"^build"
]
},
"angular:copy-metadata": {
"dependsOn": ["tools:discover-metadata"]
},
"react:copy-metadata": {
"dependsOn": ["tools:discover-metadata"]
},
"vue:copy-metadata": {
"dependsOn": ["tools:discover-metadata"]
}
},
"workspaceLayout": {
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
"license": "MIT",
"scripts": {
"angular:build-generator": "cd node_modules/devextreme-angular-generator && npm i --no-audit --no-fund && npm run build:local",
"angular:discover-metadata": "npm run tools:discover-declarations && npm run tools:generate-imd -- --output-path ./packages/devextreme-angular/metadata/integration-data.json",
"angular:generate": "npm run angular:discover-metadata && npm run angular:build-generator && cd packages/devextreme-angular && npm run generate",
"angular:copy-metadata": "shx mkdir -p ./packages/devextreme-angular/metadata/ && shx cp ./artifacts/internal-tools/NGMetaData.json ./packages/devextreme-angular/metadata/",
"angular:regenerate": "nx regenerate devextreme-angular",
"react:build-generator": "cd node_modules/devextreme-react-generator && npm i --no-audit --no-fund && npm run build:local",
"react:discover-metadata": "npm run tools:discover-declarations && npm run tools:generate-imd -- --output-path ./packages/devextreme-react/metadata/integration-data.json",
"react:generate": "npm run react:discover-metadata && npm run react:build-generator && cd packages/devextreme-react && npm run generate",
"react:copy-metadata": "shx mkdir -p ./packages/devextreme-react/metadata/ && shx cp ./artifacts/internal-tools/integration-data.json ./packages/devextreme-react/metadata/",
"react:regenerate": "nx regenerate devextreme-react",
"tools:discover-declarations": "dx-tools discover --js-scripts ./packages/devextreme/js --exclude \"js/(renovation|__internal|.eslintrc.js)\" --compiler-options \"{ \\\"typeRoots\\\": [] }\" --artifacts ./artifacts/internal-tools",
"tools:generate-imd": "dx-tools integration-data-generator --artifacts ./artifacts/internal-tools",
"tools:generate-ng-smd": "dx-tools generate-ng-smd --artifacts ./artifacts/internal-tools",
"tools:discover-metadata": "npm run tools:discover-declarations && npm run tools:generate-imd && npm run tools:generate-ng-smd",
"vue:build-generator": "cd node_modules/devextreme-vue-generator && npm i --no-audit --no-fund && npm run build:local",
"vue:discover-metadata": "npm run tools:discover-declarations && npm run tools:generate-imd -- --output-path ./packages/devextreme-vue/metadata/integration-data.json",
"vue:generate": "npm run vue:discover-metadata && npm run vue:build-generator && cd packages/devextreme-vue && npm run generate",
"vue:copy-metadata": "shx mkdir -p ./packages/devextreme-vue/metadata/ && shx cp ./artifacts/internal-tools/integration-data.json ./packages/devextreme-vue/metadata/",
"vue:regenerate": "nx regenerate devextreme-vue",
"regenerate-all": "nx run-many -t regenerate",
"lint-staged": "lint-staged",
"prepare": "husky install"
},
"nx": {},
"private": true,
"devDependencies": {
"@types/node": "^18.15.3",
Expand Down Expand Up @@ -45,6 +49,7 @@
"nx": "16.5.5",
"nx-cloud": "^16.0.5",
"postcss": "^8.4.24",
"shx": "0.3.4",
"source-map": "0.7.4",
"typescript": "~4.2.4"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/devextreme-angular/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ gulp.task('build.remove-unusable-variable', function() {
.pipe(gulp.dest(config.distPath));
});

gulp.task('build.components', gulp.series('generate.facades',
'generate.common-reexports',
gulp.task('build.components', gulp.series(
'build.copy-sources',
'build.license-headers',
'build.ngc',
Expand Down Expand Up @@ -170,6 +169,10 @@ var buildTask = gulp.series(

gulp.task('build', buildTask);
gulp.task('default', buildTask);
gulp.task('generate', gulp.series(
'generate.facades',
'generate.common-reexports'
));


//------------Testing------------
Expand Down
5 changes: 2 additions & 3 deletions packages/devextreme-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
"scripts": {
"gulp": "npx --node-options='--max_old_space_size=8192' gulp",
"build": "npm run gulp -- build",
"generate": "npm run update-integration-meta && npm run build",
"regenerate": "gulp generate",
"lint": "eslint src",
"test": "npm run gulp -- test",
"test:dev": "npm run gulp -- run.tests",
"pack": "npm run gulp -- npm.pack",
"inject-descriptions": "dx-tools inject-descriptions-to-bundle --js-scripts ./npm/dist --artifacts ../../artifacts/internal-tools",
"update-integration-meta": "dx-tools generate-ng-smd --artifacts ../../artifacts/internal-tools --output-path ./metadata/NGMetaData.json"
"inject-descriptions": "dx-tools inject-descriptions-to-bundle --js-scripts ./npm/dist --artifacts ../../artifacts/internal-tools"
},
"author": "Developer Express Inc.",
"license": "MIT",
Expand Down
16 changes: 16 additions & 0 deletions packages/devextreme-angular/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "devextreme-angular",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/devextreme-angular",
"projectType": "library",
"targets": {
"regenerate": {
"executor": "nx:run-script",
"options": {
"script": "regenerate"
},
"dependsOn": ["devextreme-monorepo:\"angular:copy-metadata\"", "devextreme-monorepo:\"angular:build-generator\""]
}
},
"tags": []
}
2 changes: 1 addition & 1 deletion packages/devextreme-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"types": "index.d.ts",
"scripts": {
"clean": "gulp clean",
"generate": "npm run clean && gulp generate",
"regenerate": "npm run clean && gulp generate",
"lint": "eslint --ignore-pattern __tests__ src/core",
"pack": "npm run clean && gulp npm.pack",
"test": "jest"
Expand Down
16 changes: 16 additions & 0 deletions packages/devextreme-react/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "devextreme-react",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/devextreme-react",
"projectType": "library",
"targets": {
"regenerate": {
"executor": "nx:run-script",
"options": {
"script": "regenerate"
},
"dependsOn": ["devextreme-monorepo:\"react:copy-metadata\"", "devextreme-monorepo:\"react:build-generator\""]
}
},
"tags": []
}
2 changes: 1 addition & 1 deletion packages/devextreme-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types": "index.d.ts",
"scripts": {
"clean": "gulp clean",
"generate": "npm run clean && gulp generate",
"regenerate": "npm run clean && gulp generate",
"lint": "eslint --ignore-pattern src/core/__tests__/ src/core",
"pack": "gulp npm.pack",
"test": "jest"
Expand Down
16 changes: 16 additions & 0 deletions packages/devextreme-vue/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "devextreme-vue",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/devextreme-vue",
"projectType": "library",
"targets": {
"regenerate": {
"executor": "nx:run-script",
"options": {
"script": "regenerate"
},
"dependsOn": ["devextreme-monorepo:\"vue:copy-metadata\"", "devextreme-monorepo:\"vue:build-generator\""]
}
},
"tags": []
}
Loading

0 comments on commit 54b4c74

Please sign in to comment.