From 09a92ff79afa2fce029e4dbd9cdbf11edfc6c3f5 Mon Sep 17 00:00:00 2001 From: Ricardo Caceres Date: Fri, 20 Sep 2024 14:36:32 +0100 Subject: [PATCH 1/6] SRV-796 feat - adding build action --- .github/workflows/build.yml | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000000..51854f8d02b6a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,70 @@ +name: "Docker Images" + +on: + push: + branches: + - main + pull_request: + types: [opened, reopened, synchronize] + +env: + AWS_REGION: eu-west-1 + +jobs: + build-image: + name: Build, Tag and Upload + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Create dist directory + run: mkdir dist + + - name: Compute labels + run: | + TAG_HASH="$(echo $GITHUB_SHA | head -c 8)" + TAG_NAME="$(echo $GITHUB_REF | sed -E -e 's:refs/pull/([0-9]+)/merge:pr.\1:' -e 's:refs/heads/::' -e 's:tag/v?([.0-9]+):v\1:' -e 's:/:.:')" + SUPERSET_REPOSITORY_URI="289222877357.dkr.ecr.eu-west-1.amazonaws.com/webgains/superset" + echo "TAG_HASH=$TAG_HASH" >> $GITHUB_ENV + echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV + echo "SUPERSET_REPOSITORY_URI=$SUPERSET_REPOSITORY_URI" >> $GITHUB_ENV + if [ $TAG_NAME = "main" ]; then echo "LATEST_TAG=$SUPERSET_REPOSITORY_URI:latest" >> $GITHUB_ENV; fi + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2.0.1 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: | + ${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_HASH }} + ${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_NAME }} + ${{ env.LATEST_TAG }} + + - name: Create artifact + run: | + printf '[ + {"name":"superset","imageUri":"%s"} + ]' "$SUPERSET_REPOSITORY_URI:$TAG_HASH" > dist/images.json + + - name: Upload artifact to S3 + run: | + OBJECT_NAME="superset-$TAG_HASH-$(date +%Y-%m-%d)" + zip -r dist.zip dist + aws s3 cp dist.zip s3://superset-artifacts/$OBJECT_NAME \ No newline at end of file From e52707cd0e9f2b270fa2adcf487c7c8ff88455f5 Mon Sep 17 00:00:00 2001 From: Ricardo Caceres Date: Fri, 20 Sep 2024 14:55:34 +0100 Subject: [PATCH 2/6] SRV-796 fix - adding empty line at end of file --- .github/workflows/build.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 51854f8d02b6a..10cca7b834f1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,15 +56,3 @@ jobs: ${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_HASH }} ${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_NAME }} ${{ env.LATEST_TAG }} - - - name: Create artifact - run: | - printf '[ - {"name":"superset","imageUri":"%s"} - ]' "$SUPERSET_REPOSITORY_URI:$TAG_HASH" > dist/images.json - - - name: Upload artifact to S3 - run: | - OBJECT_NAME="superset-$TAG_HASH-$(date +%Y-%m-%d)" - zip -r dist.zip dist - aws s3 cp dist.zip s3://superset-artifacts/$OBJECT_NAME \ No newline at end of file From fcc2af7cffc292d9c157fb8197b77da3125162f9 Mon Sep 17 00:00:00 2001 From: Ricardo Caceres Date: Fri, 20 Sep 2024 16:32:06 +0100 Subject: [PATCH 3/6] SRV-796 debug - mute webpack output --- superset-frontend/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/webpack.config.js b/superset-frontend/webpack.config.js index c4f7952c0e631..f3074032b64bc 100644 --- a/superset-frontend/webpack.config.js +++ b/superset-frontend/webpack.config.js @@ -252,7 +252,7 @@ const config = { }, }, output, - stats: 'minimal', + stats: 'none', /* Silence warning for missing export in @data-ui's internal structure. This issue arises from an internal implementation detail of @data-ui. As it's From 144809d38e90b11e6bae5fb8c6e15dcd33407667 Mon Sep 17 00:00:00 2001 From: Ricardo Caceres Date: Fri, 20 Sep 2024 16:44:19 +0100 Subject: [PATCH 4/6] SRV-796 fix - adding translations before build --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index cd859490d32b9..4a46194cc3211 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,10 +45,6 @@ RUN --mount=type=bind,target=./package.json,src=./superset-frontend/package.json --mount=type=bind,target=./package-lock.json,src=./superset-frontend/package-lock.json \ npm ci -# Runs the webpack build process -COPY superset-frontend /app/superset-frontend -RUN npm run ${BUILD_CMD} - # This copies the .po files needed for translation RUN mkdir -p /app/superset/translations COPY superset/translations /app/superset/translations @@ -57,6 +53,10 @@ RUN npm run build-translation RUN rm /app/superset/translations/*/LC_MESSAGES/*.po RUN rm /app/superset/translations/messages.pot +# Runs the webpack build process +COPY superset-frontend /app/superset-frontend +RUN npm run ${BUILD_CMD} + ###################################################################### # Final lean image... ###################################################################### From 4eca37cdbc55e621456fffad02c64b59c10738ae Mon Sep 17 00:00:00 2001 From: Ricardo Caceres Date: Fri, 20 Sep 2024 17:05:18 +0100 Subject: [PATCH 5/6] SRV-796 fix - copying frontend folder before running build-translations --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4a46194cc3211..be0789a83f90a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,9 @@ RUN --mount=type=bind,target=./package.json,src=./superset-frontend/package.json --mount=type=bind,target=./package-lock.json,src=./superset-frontend/package-lock.json \ npm ci +# Runs the webpack build process +COPY superset-frontend /app/superset-frontend + # This copies the .po files needed for translation RUN mkdir -p /app/superset/translations COPY superset/translations /app/superset/translations @@ -53,8 +56,6 @@ RUN npm run build-translation RUN rm /app/superset/translations/*/LC_MESSAGES/*.po RUN rm /app/superset/translations/messages.pot -# Runs the webpack build process -COPY superset-frontend /app/superset-frontend RUN npm run ${BUILD_CMD} ###################################################################### From b944747576f96621d162d7f16036a461057ea67b Mon Sep 17 00:00:00 2001 From: Ricardo Caceres Date: Fri, 20 Sep 2024 17:49:48 +0100 Subject: [PATCH 6/6] SRV-796 fix - linter issues --- superset-frontend/src/constants.ts | 6 +++--- .../components/DashboardBuilder/DashboardBuilder.tsx | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/superset-frontend/src/constants.ts b/superset-frontend/src/constants.ts index 14a22b4a33c41..296db9cc16224 100644 --- a/superset-frontend/src/constants.ts +++ b/superset-frontend/src/constants.ts @@ -113,12 +113,12 @@ export const URL_PARAMS = { }, language: { name: 'lang', - type: 'string' + type: 'string', }, currency: { name: 'currency', - type: 'string' - } + type: 'string', + }, } as const; export const RESERVED_CHART_URL_PARAMS: string[] = [ diff --git a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx index 8437e66b0c807..6f666b7fb1aa1 100644 --- a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx +++ b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx @@ -444,12 +444,12 @@ const DashboardBuilder: FC = () => { const fireResizeEventToParent = () => { const data = { - event: "supersetContentRefreshed", - width: window.document.body.scrollWidth, - height: window.document.body.scrollHeight, - } - window.parent.postMessage(data, "*"); - } + event: 'supersetContentRefreshed', + width: window.document.body.scrollWidth, + height: window.document.body.scrollHeight, + }; + window.parent.postMessage(data, '*'); + }; useEffect(() => { setBarTopOffset(headerRef.current?.getBoundingClientRect()?.height || 0);