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

WI-5739 Add PR deployment workflow #35

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on:
push:
branches:
- master
pull_request:
types: [opened, reopened, synchronize]
workflow_call:
outputs:
tag_hash:
description: "The commit hash used to tag the Docker image"
value: ${{ jobs.build-image.outputs.tag_hash }}

env:
AWS_REGION: eu-west-1
Expand All @@ -14,6 +17,9 @@ jobs:
build-image:
name: Build, Tag and Upload
runs-on: ubuntu-latest
env:
SUPERSET_REPOSITORY_URI: "289222877357.dkr.ecr.eu-west-1.amazonaws.com/webgains/superset"

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -22,14 +28,14 @@ jobs:
run: mkdir dist

- name: Compute labels
id: 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
echo "tag_hash=$TAG_HASH" >> $GITHUB_OUTPUT

- name: Configure AWS Credentials
uses: aws-actions/[email protected]
Expand All @@ -56,3 +62,5 @@ jobs:
${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_HASH }}
${{ env.SUPERSET_REPOSITORY_URI }}:${{ env.TAG_NAME }}
${{ env.LATEST_TAG }}
outputs:
tag_hash: ${{ steps.compute_labels.outputs.tag_hash }}
5 changes: 3 additions & 2 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: License Template Check

on:
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
workflow_dispatch:
# pull_request:
# types: [synchronize, opened, reopened, ready_for_review]

# cancel previous workflow jobs for PRs
concurrency:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/pr-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR Cleanup

on:
pull_request:
types: [closed]

jobs:
destroy:
name: Destroy Stack
uses: webgains/github-workflows/.github/workflows/destroy-stack.yml@main
secrets: inherit
with:
environment: feature
stack: superset-pr-${{ github.event.pull_request.number }}SupersetService
permissions:
contents: read
deployments: write
id-token: write
50 changes: 50 additions & 0 deletions .github/workflows/pr-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PR Deployment

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
uses: ./.github/workflows/build.yml
name: Build
secrets: inherit
permissions:
checks: write
actions: write
contents: write
packages: read
issues: read
pull-requests: write

labels:
runs-on: ubuntu-latest
name: Add Labels
steps:
- name: Add labels
id: add_labels
run: |
echo "feature_name=superset-pr-${{ github.event.pull_request.number }}" | sed 's:\.:-:g' >> $GITHUB_OUTPUT
outputs:
feature_name: ${{ steps.add_labels.outputs.feature_name }}

deploy:
name: Deploy to Feature Environment
needs: [labels, build]
uses: webgains/github-workflows/.github/workflows/deploy-service-to-environment.yml@WI-5868-allow-service-deploy-workflow-to-use-any-repositor
secrets: inherit
with:
environment: feature
name: ${{ needs.labels.outputs.feature_name }}
stack: ${{ needs.labels.outputs.feature_name }}
service: superset
component: service
override: |
{
"namespace": "${{ needs.labels.outputs.feature_name }}",
"supersetImageTag": "${{ needs.build.outputs.tag_hash }}"
}
permissions:
contents: read
deployments: write
id-token: write
5 changes: 3 additions & 2 deletions .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: PR Lint

on:
pull_request:
workflow_dispatch:
# pull_request:
# By default, a workflow only runs when a pull_request's activity type is opened, synchronize, or reopened. We
# explicity override here so that PR titles are re-linted when the PR text content is edited.
#
# Possible values: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
types: [opened, edited, reopened, synchronize]
# types: [opened, edited, reopened, synchronize]

jobs:
lint-check:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/superset-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: E2E

on:
push:
branches:
- "master"
- "[0-9].[0-9]*"
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
# push:
# branches:
# - "master"
# - "[0-9].[0-9]*"
# pull_request:
# types: [synchronize, opened, reopened, ready_for_review]
workflow_dispatch:
inputs:
use_dashboard:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Frontend

on:
push:
branches:
- "master"
- "[0-9].[0-9]*"
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
workflow_dispatch:
# push:
# branches:
# - "master"
# - "[0-9].[0-9]*"
# pull_request:
# types: [synchronize, opened, reopened, ready_for_review]

# cancel previous workflow jobs for PRs
concurrency:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ export default typedMemo(function DataTable<D extends object>({
) : null}
</div>
{searchInput ? (
<div className={renderTimeComparisonDropdown ? 'col-sm-10' : 'col-sm-11'}>
<div
className={
renderTimeComparisonDropdown ? 'col-sm-10' : 'col-sm-11'
}
>
<GlobalFilter<D>
searchInput={
typeof searchInput === 'boolean' ? undefined : searchInput
Expand Down
2 changes: 1 addition & 1 deletion superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def _try_json_readsha(filepath: str, length: int) -> str | None:
"it": {"flag": "it", "name": "Italian"},
"fr": {"flag": "fr", "name": "French"},
"de": {"flag": "de", "name": "German"},
"nl": {"flag": "nl", "name": "Dutch"}
"nl": {"flag": "nl", "name": "Dutch"},
}


Expand Down
41 changes: 19 additions & 22 deletions superset/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,30 +355,27 @@ def get_filters(self, column: str, remove_filter: bool = False) -> list[Filter]:
op: str = flt["operator"].upper() if flt.get("operator") else None
# fltOpName: str = flt.get("filterOptionName")
if (
(flt.get("expressionType") == "SIMPLE"
flt.get("expressionType") == "SIMPLE"
and flt.get("clause") == "WHERE"
and flt.get("subject") == column
and val)
or
(isinstance(flt.get("subject"), dict)
and flt.get("expressionType") == "SIMPLE"
and flt.get("clause") == "WHERE"
and flt.get("subject").get("label") == column
and val)
and val
):
if remove_filter:
if column not in self.removed_filters:
self.removed_filters.append(column)
if column not in self.applied_filters:
self.applied_filters.append(column)

if op in (
FilterOperator.IN.value,
FilterOperator.NOT_IN.value,
) and not isinstance(val, list):
val = [val]

filters.append({"op": op, "col": column, "val": val})
if (flt.get("subject") == column) or (
isinstance(flt.get("subject"), dict)
and flt.get("subject").get("label") == column
):
if remove_filter:
if column not in self.removed_filters:
self.removed_filters.append(column)
if column not in self.applied_filters:
self.applied_filters.append(column)

if op in (
FilterOperator.IN.value,
FilterOperator.NOT_IN.value,
) and not isinstance(val, list):
val = [val]

filters.append({"op": op, "col": column, "val": val})

return filters

Expand Down
4 changes: 3 additions & 1 deletion superset/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2662,7 +2662,9 @@ def has_guest_access(self, dashboard: "Dashboard") -> bool:
return False

dashboards = [
r for r in user.resources if r["type"] == GuestTokenResourceType.DASHBOARD.value
r
for r in user.resources
if r["type"] == GuestTokenResourceType.DASHBOARD.value
]

# TODO (embedded): remove this check once uuids are rolled out
Expand Down
6 changes: 3 additions & 3 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
g,
get_flashed_messages,
redirect,
request,
Response,
session,
request
)
from flask_appbuilder import BaseView, expose, Model, ModelView
from flask_appbuilder.actions import action
Expand Down Expand Up @@ -350,8 +350,8 @@ def cached_common_bootstrap_data( # pylint: disable=unused-argument

def common_bootstrap_payload() -> dict[str, Any]:
locale = get_locale()
if request.args.get('lang'):
locale = Locale.parse(request.args.get('lang'))
if request.args.get("lang"):
locale = Locale.parse(request.args.get("lang"))
return {
**cached_common_bootstrap_data(utils.get_user_id(), locale),
"flash_messages": get_flashed_messages(with_categories=True),
Expand Down
Loading