Skip to content
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

refactor(monorepo): move superset-ui to superset(stage 2) #17552

Merged
merged 21 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 12 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ codecov:
after_n_builds: 4
ignore:
- "superset/migrations/versions/*.py"
- "superset-frontend/packages/superset-ui-demo/**/*"
- "**/*.stories.tsx"
- "**/*.stories.jsx"
coverage:
Expand All @@ -14,6 +15,17 @@ coverage:
# project coverage decrease:
target: auto
threshold: 0%
core-packages-ts:
target: 95%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers - this was set to 95 % due to codecov reporting slightly lower coverage stats than on superset-ui. This will be fixed in a follow-up PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder.

paths:
- 'superset-frontend/packages'
- '!superset-frontend/packages/**/*.jsx'
- '!superset-frontend/packages/**/*.tsx'
core-packages-tsx:
target: 50%
paths:
- 'superset-frontend/packages/**/*.jsx'
- 'superset-frontend/packages/**/*.tsx'
patch:
default:
informational: true
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ jobs:
run: |
npm run lint
npm run prettier-check
- name: Build plugins packages
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: npm run plugins:build
- name: Build plugins Storybook
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: npm run plugins:build-storybook
- name: unit tests
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
Expand Down
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,29 @@ tmp
rat-results.txt
superset/app/

# Node.js, webpack artifacts
# Node.js, webpack artifacts, storybook
*.entry.js
*.js.map
node_modules
npm-debug.log*
superset/static/assets
superset/static/version_info.json
superset-frontend/**/esm/*
superset-frontend/**/lib/*
superset-frontend/**/storybook-static/*
yarn-error.log
*.map
*.min.js
test-changelog.md
*.tsbuildinfo

# Ignore package-lock in packages
plugins/*/package-lock.json
packages/*/package-lock.json

# For country map geojson conversion script
.ipynb_checkpoints/
scripts/*.zip

# IntelliJ
*.iml
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ ENV BUILD_CMD=${NPM_BUILD_CMD}
RUN mkdir -p /app/superset-frontend
RUN mkdir -p /app/superset/assets
COPY ./docker/frontend-mem-nag.sh /
COPY ./superset-frontend/package* /app/superset-frontend/
COPY ./superset-frontend /app/superset-frontend
RUN /frontend-mem-nag.sh \
&& cd /app/superset-frontend \
&& npm ci

# Next, copy in the rest and let webpack do its thing
COPY ./superset-frontend /app/superset-frontend
# This seems to be the most expensive step
RUN cd /app/superset-frontend \
&& npm run ${BUILD_CMD} \
Expand Down
51 changes: 51 additions & 0 deletions scripts/babel_extract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
LICENSE_TMP=$(mktemp)
cat <<'EOF'> "$LICENSE_TMP"
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

EOF

cd $ROOT_DIR
pybabel extract \
-F superset/translations/babel.cfg \
-o superset/translations/messages.pot \
--sort-output \
--copyright-holder=Superset \
--project=Superset \
-k _ -k __ -k t -k tn -k tct .
cat $LICENSE_TMP $ROOT_DIR/superset/translations/messages.pot > messages.pot.tmp \
&& mv messages.pot.tmp $ROOT_DIR/superset/translations/messages.pot \
&& cd $CURRENT_DIR
5 changes: 5 additions & 0 deletions superset-frontend/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ src/dashboard/deprecated/*
src/temp/*
**/node_modules
*.d.ts
coverage/
esm/
lib/
tmp/
storybook-static/
temporary_superset_ui/**/*
13 changes: 13 additions & 0 deletions superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ Object.entries(packageConfig.dependencies).forEach(([pkg]) => {
importCoreModules.push(pkg);
}
});

// ignore files when running ForkTsCheckerWebpackPlugin
let ignorePatterns = [];
if (process.env.NODE_ENV === 'production') {
ignorePatterns = [
'*.test.{js,ts,jsx,tsx}',
'plugins/**/test/**/*',
'packages/**/test/**/*',
'packages/generator-superset/**/*',
];
}

module.exports = {
extends: [
'airbnb',
Expand Down Expand Up @@ -307,4 +319,5 @@ module.exports = {
'react/static-property-placement': 0, // disabled temporarily
'prettier/prettier': 'error',
},
ignorePatterns,
};
19 changes: 18 additions & 1 deletion superset-frontend/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ module.exports = {
'@babel/preset-react',
{ development: process.env.BABEL_ENV === 'development' },
],
'@babel/preset-typescript',
[
'@emotion/babel-preset-css-prop',
{
autoLabel: 'dev-only',
labelFormat: '[local]',
},
],
],
plugins: [
'lodash',
Expand All @@ -47,6 +55,8 @@ module.exports = {
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: true }],
['@babel/plugin-transform-runtime', { corejs: 3 }],
// only used in packages/superset-ui-core/src/chart/components/reactify.tsx
['babel-plugin-typescript-to-proptypes', { loose: true }],
'react-hot-loader/babel',
],
env: {
Expand All @@ -70,7 +80,14 @@ module.exports = {
},
// build instrumented code for testing code coverage with Cypress
instrumented: {
plugins: ['istanbul'],
plugins: [
[
'istanbul',
{
exclude: ['plugins/**/*', 'packages/**/*'],
},
],
],
},
production: {
plugins: [
Expand Down
35 changes: 33 additions & 2 deletions superset-frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,64 @@
* specific language governing permissions and limitations
* under the License.
*/

module.exports = {
testRegex: '(\\/spec|\\/src)\\/.*(_spec|\\.test)\\.(j|t)sx?$',
testRegex: '\\/(spec|src|plugins|packages)\\/.*(_spec|\\.test)\\.[jt]sx?$',
testPathIgnorePatterns: [
'packages\\/generator-superset\\/.*',
villebro marked this conversation as resolved.
Show resolved Hide resolved
'/node_modules/',
],
moduleNameMapper: {
'\\.(css|less|geojson)$': '<rootDir>/spec/__mocks__/mockExportObject.js',
'\\.(gif|ttf|eot|png|jpg)$': '<rootDir>/spec/__mocks__/mockExportString.js',
'\\.svg$': '<rootDir>/spec/__mocks__/svgrMock.tsx',
'^src/(.*)$': '<rootDir>/src/$1',
'^spec/(.*)$': '<rootDir>/spec/$1',
// mapping to souce code instead of lib or esm module
'@superset-ui/(((?!(legacy-preset-chart-deckgl|core/src)).)*)$':
'<rootDir>/node_modules/@superset-ui/$1/src',
'@superset-ui/core/src/(.*)$':
'<rootDir>/node_modules/@superset-ui/core/src/$1',
},
testEnvironment: 'jsdom',
modulePathIgnorePatterns: ['<rootDir>/temporary_superset_ui'],
setupFilesAfterEnv: ['<rootDir>/spec/helpers/setup.ts'],
testURL: 'http://localhost',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!**/*.stories.*'],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'{packages,plugins}/**/src/**/*.{js,jsx,ts,tsx}',
'!**/*.stories.*',
'!packages/superset-ui-demo/**/*',
],
coverageDirectory: '<rootDir>/coverage/',
coveragePathIgnorePatterns: [
'coverage/',
'node_modules/',
'public/',
'tmp/',
'dist/',
],
coverageReporters: ['lcov', 'json-summary', 'html'],
transform: {
'^.+\\.jsx?$': 'babel-jest',
// ts-jest can't load plugin 'babel-plugin-typescript-to-proptypes'
'reactify\\.tsx$': 'babel-jest',
'^.+\\.tsx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
snapshotSerializers: ['@emotion/jest/enzyme-serializer'],
globals: {
'ts-jest': {
babelConfig: true,
// todo: duo to packages/**/test and plugins/**/test lack of type checking
// turning off checking in Jest.
// https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules
isolatedModules: true,
diagnostics: {
warnOnly: true,
},
},
__DEV__: true,
caches: true,
},
};
2 changes: 1 addition & 1 deletion superset-frontend/lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lerna": "3.2.1",
"npmClient": "npm",
"packages": ["packages/*", "plugins/*", "temporary_superset_ui/*"],
"packages": ["packages/*", "plugins/*"],
"useWorkspaces": true,
"version": "0.0.0",
"ignoreChanges": [
Expand Down
Loading