Skip to content

Commit

Permalink
Merge branch 'master' into metrica-retries
Browse files Browse the repository at this point in the history
  • Loading branch information
guidopetri authored Oct 17, 2023
2 parents 3ac68a9 + d4ade51 commit d80609b
Show file tree
Hide file tree
Showing 18 changed files with 191 additions and 57 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ jobs:
- name: Build Docker Images
run: |
set -x
docker-compose build --build-arg install_groups="main,all_ds,dev" --build-arg skip_frontend_build=true
docker-compose up -d
docker compose build --build-arg install_groups="main,all_ds,dev" --build-arg skip_frontend_build=true
docker compose up -d
sleep 10
- name: Create Test Database
run: docker-compose -p redash run --rm postgres psql -h postgres -U postgres -c "create database tests;"
run: docker compose -p redash run --rm postgres psql -h postgres -U postgres -c "create database tests;"
- name: List Enabled Query Runners
run: docker-compose -p redash run --rm redash manage ds list_types
run: docker compose -p redash run --rm redash manage ds list_types
- name: Run Tests
run: docker-compose -p redash run --name tests redash tests --junitxml=junit.xml --cov-report=xml --cov=redash --cov-config=.coveragerc tests/
run: docker compose -p redash run --name tests redash tests --junitxml=junit.xml --cov-report=xml --cov=redash --cov-config=.coveragerc tests/
- name: Copy Test Results
run: |
mkdir -p /tmp/test-results/unit-tests
Expand Down Expand Up @@ -137,12 +137,12 @@ jobs:
set -x
yarn cypress build
yarn cypress start -- --skip-db-seed
docker-compose run cypress yarn cypress db-seed
docker compose run cypress yarn cypress db-seed
- name: Execute Cypress Tests
run: yarn cypress run-ci
- name: "Failure: output container logs to console"
if: failure()
run: docker-compose logs
run: docker compose logs
- name: Copy Code Coverage Results
run: docker cp cypress:/usr/src/app/coverage ./coverage || true
- name: Store Coverage Results
Expand All @@ -159,9 +159,18 @@ jobs:
- name: Skip?
id: skip-check
run: |
if [[ "${{ vars.DOCKER_USER }}" == '' ]] || [[ "${{ secrets.DOCKER_PASS }}" == '' ]]; then
if [[ "${{ vars.DOCKER_USER }}" == '' ]]; then
echo 'Docker user is empty. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
elif [[ "${{ secrets.DOCKER_PASS }}" == '' ]]; then
echo 'Docker password is empty. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
elif [[ "${{ github.ref_name }}" != 'master' ]]; then
echo 'Ref name is not `master`. Skipping build+push'
echo skip=true >> "$GITHUB_OUTPUT"
else
echo 'Docker user and password are set and branch is `master`.'
echo 'Building + pushing `preview` image.'
echo skip=false >> "$GITHUB_OUTPUT"
fi
Expand All @@ -172,7 +181,7 @@ jobs:
- frontend-unit-tests
- frontend-e2e-tests
- build-skip-check
if: ${{ needs.build-skip-check.outputs.skip == false}}
if: needs.build-skip-check.outputs.skip == 'false'
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -220,9 +229,10 @@ jobs:
test_all_deps=true
cache-from: type=ghq
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
env:
DOCKER_CONTENT_TRUST: true

- name: "Failure: output container logs to console"
if: failure()
run: docker-compose logs
run: docker compose logs
5 changes: 2 additions & 3 deletions .github/workflows/periodic-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
bump-version-and-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
date="$(date +%y.%m).0-dev"
gawk -i inplace -F: -v q=\" -v tag=$date '/^ "version": / { print $1 FS, q tag q ","; next} { print }' package.json
Expand All @@ -22,6 +22,5 @@ jobs:
git config user.email [email protected]
git add package.json redash/__init__.py pyproject.toml
git commit -m "Snapshot: ${date}"
git push origin
git tag $date
git push origin $date
git push --atomic origin master refs/tags/$date
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.20.1 as frontend-builder
FROM node:16.20.1-bookworm as frontend-builder

RUN npm install --global --force [email protected]

Expand All @@ -25,7 +25,7 @@ COPY --chown=redash client /frontend/client
COPY --chown=redash webpack.config.js /frontend/
RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn build; else mkdir -p /frontend/client/dist && touch /frontend/client/dist/multi_org.html && touch /frontend/client/dist/index.html; fi

FROM python:3.8-slim-buster
FROM python:3.8-slim-bookworm

EXPOSE 5000

Expand Down Expand Up @@ -64,8 +64,8 @@ RUN apt-get update && \
ARG TARGETPLATFORM
ARG databricks_odbc_driver_url=https://databricks-bi-artifacts.s3.us-east-2.amazonaws.com/simbaspark-drivers/odbc/2.6.26/SimbaSparkODBC-2.6.26.1045-Debian-64bit.zip
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list \
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
&& curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql17 \
&& apt-get clean \
Expand Down
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
.PHONY: compose_build up test_db create_database clean down tests lint backend-unit-tests frontend-unit-tests test build watch start redis-cli bash

compose_build: .env
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose build
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose build

up:
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up -d --build
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose up -d --build

test_db:
@for i in `seq 1 5`; do \
if (docker-compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \
if (docker compose exec postgres sh -c 'psql -U postgres -c "select 1;"' 2>&1 > /dev/null) then break; \
else echo "postgres initializing..."; sleep 5; fi \
done
docker-compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"'
docker compose exec postgres sh -c 'psql -U postgres -c "drop database if exists tests;" && psql -U postgres -c "create database tests;"'

create_database: .env
docker-compose run server create_db
docker compose run server create_db

clean:
docker-compose down && docker-compose rm
docker compose down && docker compose rm

down:
docker-compose down
docker compose down

.env:
printf "REDASH_COOKIE_SECRET=`pwgen -1s 32`\nREDASH_SECRET_KEY=`pwgen -1s 32`\n" >> .env
Expand All @@ -31,14 +31,14 @@ format:
pre-commit run --all-files

tests:
docker-compose run server tests
docker compose run server tests

lint:
ruff check .
black --check . --diff

backend-unit-tests: up test_db
docker-compose run --rm --name tests server tests
docker compose run --rm --name tests server tests

frontend-unit-tests:
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn --frozen-lockfile
Expand All @@ -56,7 +56,7 @@ start:
yarn start

redis-cli:
docker-compose run --rm redis redis-cli -h redis
docker compose run --rm redis redis-cli -h redis

bash:
docker-compose run --rm server bash
docker compose run --rm server bash
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
</p>

[![Documentation](https://img.shields.io/badge/docs-redash.io/help-brightgreen.svg)](https://redash.io/help/)
[![Datree](https://s3.amazonaws.com/catalog.static.datree.io/datree-badge-20px.svg)](https://datree.io/?src=badge)
[![GitHub Build](https://github.com/getredash/redash/actions/workflows/ci.yml/badge.svg)](https://github.com/getredash/redash/actions)

Redash is designed to enable anyone, regardless of the level of technical sophistication, to harness the power of data big and small. SQL users leverage Redash to explore, query, visualize, and share data from any data sources. Their work in turn enables anybody in their organization to use the data. Every day, millions of users at thousands of organizations around the world use Redash to develop insights and make data-driven decisions.
Expand Down
1 change: 1 addition & 0 deletions client/app/assets/less/redash/query.less
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ body.fixed-layout {
}

.editor__left__schema {
min-height: 120px;
flex-grow: 1;
display: flex;
flex-direction: column;
Expand Down
3 changes: 2 additions & 1 deletion client/app/pages/queries/QuerySource.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@

&.active {
overflow: visible;
max-height: unset !important;
.ant-input {
resize: vertical;
max-height: 150px - 15px * 2;
height: 30vh;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions client/cypress/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ function seedDatabase(seedValues) {

function buildServer() {
console.log("Building the server...");
execSync("docker-compose -p cypress build", { stdio: "inherit" });
execSync("docker compose -p cypress build", { stdio: "inherit" });
}

function startServer() {
console.log("Starting the server...");
execSync("docker-compose -p cypress up -d", { stdio: "inherit" });
execSync("docker-compose -p cypress run server create_db", { stdio: "inherit" });
execSync("docker compose -p cypress up -d", { stdio: "inherit" });
execSync("docker compose -p cypress run server create_db", { stdio: "inherit" });
}

function stopServer() {
console.log("Stopping the server...");
execSync("docker-compose -p cypress down", { stdio: "inherit" });
execSync("docker compose -p cypress down", { stdio: "inherit" });
}

function runCypressCI() {
Expand All @@ -81,7 +81,7 @@ function runCypressCI() {
}

execSync(
"COMMIT_INFO_MESSAGE=$(git show -s --format=%s) docker-compose run --name cypress cypress ./node_modules/.bin/percy exec -t 300 -- ./node_modules/.bin/cypress run $CYPRESS_OPTIONS",
"COMMIT_INFO_MESSAGE=$(git show -s --format=%s) docker compose run --name cypress cypress ./node_modules/.bin/percy exec -t 300 -- ./node_modules/.bin/cypress run $CYPRESS_OPTIONS",
{ stdio: "inherit" }
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""create sqlalchemy_searchable expressions
Revision ID: 7ce5925f832b
Revises: 1038c2174f5d
Create Date: 2023-09-29 16:48:29.517762
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy_searchable import sql_expressions


# revision identifiers, used by Alembic.
revision = '7ce5925f832b'
down_revision = '1038c2174f5d'
branch_labels = None
depends_on = None


def upgrade():
op.execute(sql_expressions)


def downgrade():
pass
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redash-client",
"version": "23.09.0-dev",
"version": "23.10.0-dev",
"description": "The frontend part of Redash.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ force-exclude = '''

[tool.poetry]
name = "redash"
version = "23.09.0-dev"
version = "23.10.0-dev"
description = "Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data."
authors = ["Arik Fraimovich <[email protected]>"]
# to be added to/removed from the mailing list, please reach out to Arik via the above email or Discord
Expand Down
2 changes: 1 addition & 1 deletion redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from redash.destinations import import_destinations
from redash.query_runner import import_query_runners

__version__ = "23.09.0-dev"
__version__ = "23.10.0-dev"


if os.environ.get("REMOTE_DEBUG"):
Expand Down
2 changes: 1 addition & 1 deletion redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def update_group_permission(self, group, view_only):

@property
def uses_ssh_tunnel(self):
return "ssh_tunnel" in self.options
return self.options and "ssh_tunnel" in self.options

@property
def query_runner(self):
Expand Down
20 changes: 13 additions & 7 deletions redash/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from functools import reduce
from operator import or_

from flask import current_app as app
from flask import request_started, url_for
from flask import current_app, request_started, url_for
from flask_login import AnonymousUserMixin, UserMixin, current_user
from passlib.apps import custom_app_context as pwd_context
from sqlalchemy.dialects import postgresql
Expand Down Expand Up @@ -129,7 +128,7 @@ def regenerate_api_key(self):
def to_dict(self, with_api_key=False):
profile_image_url = self.profile_image_url
if self.is_disabled:
assets = app.extensions["webpack"]["assets"] or {}
assets = current_app.extensions["webpack"]["assets"] or {}
path = "images/avatar.svg"
profile_image_url = url_for("static", filename=assets.get(path, path))

Expand Down Expand Up @@ -158,7 +157,8 @@ def to_dict(self, with_api_key=False):

return d

def is_api_user(self):
@staticmethod
def is_api_user():
return False

@property
Expand Down Expand Up @@ -377,7 +377,8 @@ class AnonymousUser(AnonymousUserMixin, PermissionsCheckMixin):
def permissions(self):
return []

def is_api_user(self):
@staticmethod
def is_api_user():
return False


Expand All @@ -397,7 +398,8 @@ def __init__(self, api_key, org, groups, name=None):
def __repr__(self):
return "<{}>".format(self.name)

def is_api_user(self):
@staticmethod
def is_api_user():
return True

@property
Expand All @@ -410,5 +412,9 @@ def org_id(self):
def permissions(self):
return ["view_query"]

def has_access(self, obj, access_type):
@staticmethod
def has_access(obj, access_type):
return False

def get_actual_user(self):
return repr(self)
Loading

0 comments on commit d80609b

Please sign in to comment.