From a4e410ba481f5c4e078ef9a769c6bd41cac38134 Mon Sep 17 00:00:00 2001 From: IceS2 Date: Fri, 10 May 2024 14:59:44 +0200 Subject: [PATCH 1/2] Fix Github Workflows for Release (#16224) --- .../prepare-for-docker-build-and-push/action.yml | 16 +++++++++++----- .github/workflows/docker-openmetadata-db.yml | 2 ++ .../docker-openmetadata-ingestion-base-slim.yml | 2 ++ .../docker-openmetadata-ingestion-base.yml | 2 ++ .../workflows/docker-openmetadata-ingestion.yml | 2 ++ .../workflows/docker-openmetadata-postgres.yml | 4 +++- .github/workflows/docker-openmetadata-server.yml | 4 +++- scripts/update_version.py | 2 +- 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/actions/prepare-for-docker-build-and-push/action.yml b/.github/actions/prepare-for-docker-build-and-push/action.yml index c219d1dffae6..3c0e445ceb7a 100644 --- a/.github/actions/prepare-for-docker-build-and-push/action.yml +++ b/.github/actions/prepare-for-docker-build-and-push/action.yml @@ -16,6 +16,12 @@ inputs: description: true if we are building an Ingestion image, false otherwise required: true default: "false" + dockerhub_username: + description: Dockerhub Username + required: true + dockerhub_token: + description: Dockerhub Token + required: true outputs: tags: @@ -34,17 +40,17 @@ runs: - name: Login to DockerHub uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} - password: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }} + username: ${{ inputs.dockerhub_username }} + password: ${{ inputs.dockerhub_token }} - name: Install Ubuntu dependencies - if: ${{ inputs.is_ingestion == "true" }} + if: inputs.is_ingestion == true shell: bash run: | sudo apt-get install -y python3-venv - name: Install open-metadata dependencies - if: ${{ inputs.is_ingestion == "true" }} + if: inputs.is_ingestion == true shell: bash run: | python3 -m venv env @@ -57,7 +63,7 @@ runs: id: generate-tags shell: bash run: | - if ${{ inputs.push_latest == "true" }}; then + if ${{ inputs.push_latest == 'true' }}; then echo "tags=${{ inputs.image }}:${{ inputs.tag }},${{ inputs.image }}:latest" >> $GITHUB_OUTPUT else echo "tags=${{ inputs.image }}:${{ inputs.tag }}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/docker-openmetadata-db.yml b/.github/workflows/docker-openmetadata-db.yml index 731be366048c..999aa7da9725 100644 --- a/.github/workflows/docker-openmetadata-db.yml +++ b/.github/workflows/docker-openmetadata-db.yml @@ -35,6 +35,8 @@ jobs: image: openmetadata/db tag: ${{ inputs.tag }} push_latest: ${{ inputs.push_latest_tag_to_release }} + dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }} - name: Build and push if event is workflow_dispatch and input is checked diff --git a/.github/workflows/docker-openmetadata-ingestion-base-slim.yml b/.github/workflows/docker-openmetadata-ingestion-base-slim.yml index bf194aac02f8..78fb4b827e3f 100644 --- a/.github/workflows/docker-openmetadata-ingestion-base-slim.yml +++ b/.github/workflows/docker-openmetadata-ingestion-base-slim.yml @@ -36,6 +36,8 @@ jobs: tag: ${{ inputs.tag }} push_latest: ${{ inputs.push_latest_tag_to_release }} is_ingestion: true + dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }} - name: Build and push if event is workflow_dispatch and input is checked uses: docker/build-push-action@v3 diff --git a/.github/workflows/docker-openmetadata-ingestion-base.yml b/.github/workflows/docker-openmetadata-ingestion-base.yml index 31b5666a3465..8a004291e2ad 100644 --- a/.github/workflows/docker-openmetadata-ingestion-base.yml +++ b/.github/workflows/docker-openmetadata-ingestion-base.yml @@ -36,6 +36,8 @@ jobs: tag: ${{ inputs.tag }} push_latest: ${{ inputs.push_latest_tag_to_release }} is_ingestion: true + dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }} - name: Build and push if event is workflow_dispatch and input is checked uses: docker/build-push-action@v3 diff --git a/.github/workflows/docker-openmetadata-ingestion.yml b/.github/workflows/docker-openmetadata-ingestion.yml index 72f1bfad8694..aba55ecfb8d4 100644 --- a/.github/workflows/docker-openmetadata-ingestion.yml +++ b/.github/workflows/docker-openmetadata-ingestion.yml @@ -36,6 +36,8 @@ jobs: tag: ${{ inputs.tag }} push_latest: ${{ inputs.push_latest_tag_to_release }} is_ingestion: true + dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }} - name: Build and push if event is workflow_dispatch and input is checked uses: docker/build-push-action@v3 diff --git a/.github/workflows/docker-openmetadata-postgres.yml b/.github/workflows/docker-openmetadata-postgres.yml index b4fe7f1fe536..645e925969e6 100644 --- a/.github/workflows/docker-openmetadata-postgres.yml +++ b/.github/workflows/docker-openmetadata-postgres.yml @@ -34,7 +34,9 @@ jobs: with: image: openmetadata/postgresql tag: ${{ inputs.tag }} - push_latest: ${{ inputs.push_latest_tag_to_release }} + push_latest: ${{ inputs.p + dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }}ush_latest_tag_to_release }} - name: Build and push if event is workflow_dispatch and input is checked uses: docker/build-push-action@v3 diff --git a/.github/workflows/docker-openmetadata-server.yml b/.github/workflows/docker-openmetadata-server.yml index 6c4eae9ffd0e..57d452b6461d 100644 --- a/.github/workflows/docker-openmetadata-server.yml +++ b/.github/workflows/docker-openmetadata-server.yml @@ -101,7 +101,9 @@ jobs: with: image: openmetadata/server tag: ${{ inputs.DOCKER_RELEASE_TAG }} - push_latest: ${{ inputs.push_latest_tag_to_release }} + push_latest: ${{ inputs.push_ + dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }} + dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }}latest_tag_to_release }} - name: Build and push if event is workflow_dispatch and input is checked uses: docker/build-push-action@v3 diff --git a/scripts/update_version.py b/scripts/update_version.py index 282551833d12..dc10c3d895f8 100644 --- a/scripts/update_version.py +++ b/scripts/update_version.py @@ -37,7 +37,7 @@ def update_dockerfile_arg(arg, file_path, value): regex_sub( file_path, rf"(ARG\s+{arg}=).+", - rf"\1={value}", + rf'\1"{value}"', ) From e4add9ea6e851e87054d2398ab6cdc492b469e36 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Fri, 10 May 2024 23:40:15 +0530 Subject: [PATCH 2/2] MINNOR: fix the reloading of application when current user team or role changes (#16219) * fix the reloading of application when current user team or role changes * fix the infinite load * added test for no loader if current user not present --- .../PermissionProvider.test.tsx | 20 +++++++++++++++++++ .../PermissionProvider/PermissionProvider.tsx | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.test.tsx b/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.test.tsx index 10c7b6bca8d3..5421a3402487 100644 --- a/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.test.tsx @@ -52,7 +52,24 @@ jest.mock('../../hooks/useApplicationStore', () => { }; }); +jest.mock('../../components/common/Loader/Loader', () => { + return jest.fn().mockImplementation(() =>

Loader

); +}); + describe('PermissionProvider', () => { + it('Should render loader and call getLoggedInUserPermissions', async () => { + render( + +
Children
+
+ ); + + // Verify that the API methods were called + expect(getLoggedInUserPermissions).toHaveBeenCalled(); + + expect(screen.getByText('Loader')).toBeInTheDocument(); + }); + it('Should render children and call apis when current user is present', async () => { render( @@ -82,5 +99,8 @@ describe('PermissionProvider', () => { expect(getEntityPermissionById).not.toHaveBeenCalled(); expect(getEntityPermissionByFqn).not.toHaveBeenCalled(); expect(getResourcePermission).not.toHaveBeenCalled(); + + expect(screen.queryByText('Loader')).not.toBeInTheDocument(); + expect(await screen.findByTestId('children')).toBeInTheDocument(); }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.tsx index 981754073ac8..56246d482c96 100644 --- a/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/context/PermissionProvider/PermissionProvider.tsx @@ -67,7 +67,7 @@ const PermissionProvider: FC = ({ children }) => { const { currentUser } = useApplicationStore(); const cookieStorage = new CookieStorage(); const history = useHistory(); - const [loading, setLoading] = useState(false); + const [loading, setLoading] = useState(true); const [entitiesPermission, setEntitiesPermission] = useState({} as EntityPermissionMap); @@ -89,7 +89,6 @@ const PermissionProvider: FC = ({ children }) => { */ const fetchLoggedInUserPermissions = useCallback(async () => { try { - setLoading(true); const response = await getLoggedInUserPermissions(); setPermissions(getUIPermission(response.data || [])); redirectToStoredPath(); @@ -173,6 +172,8 @@ const PermissionProvider: FC = ({ children }) => { */ if (!isEmpty(currentUser)) { fetchLoggedInUserPermissions(); + } else { + setLoading(false); } if (isEmpty(currentUser)) { resetPermissions();