Skip to content

Commit

Permalink
[DB-29943,DB-28355] fix: show views when browsing data, feature: upgr…
Browse files Browse the repository at this point in the history
…ade to 0.50 (#31)

* Compatibility with 0.49.0

* Make driver work with 0.50.0

* More cleanup

* Fix comment

* Fix docker build

* Minor updates

* Make build tarball work, hopefully

* Cleanup
  • Loading branch information
alougov1 authored Oct 17, 2024
1 parent 024ab97 commit facc883
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 108 deletions.
39 changes: 20 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
ARG METABASE_VERSION=v0.44.4
ARG METABASE_VERSION=v0.50.1
ARG METABASE_EDITION=oss

#################
# Metabase repo #
#################
FROM clojure:openjdk-11-tools-deps-slim-buster AS stg_base
FROM clojure:temurin-11-tools-deps-jammy AS stg_base

ARG METABASE_EDITION
ARG METABASE_VERSION

# Reequirements for building the driver
# Requirements for building the driver.
# The nodejs binary contains npm, so we don't need to reinstall it
RUN apt-get update \
&& apt-get install -y \
curl \
jq \
make \
npm \
unzip \
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
Expand All @@ -40,13 +40,17 @@ RUN git checkout $(curl -s -H "Accept: application/vnd.github+json" https://api.
# Then prep our Metabase dependencies
# We need to build java deps
# Ref: https://github.com/metabase/metabase/wiki/Migrating-from-Leiningen-to-tools.deps#preparing-dependencies

RUN --mount=type=cache,target=/root/.m2/repository \
clojure -X:deps prep

WORKDIR /build/metabase/bin
RUN --mount=type=cache,target=/root/.m2/repository \
clojure -X:deps prep

WORKDIR /build/metabase/modules/drivers
RUN --mount=type=cache,target=/root/.m2/repository \
clojure -X:deps prep

WORKDIR /build

Expand All @@ -68,14 +72,14 @@ RUN --mount=type=cache,target=/root/.m2/repository \
##############
FROM stg_driver as stg_unit_test

COPY test ./
COPY test ./test

# Run the unit tests
RUN --mount=type=cache,target=/root/.m2/repository \
cd metabase && \
CI=true \
DRIVERS=ocient \
clojure -X:dev:unit-test \
:project-dir "\"$(pwd)\""
DRIVERS=ocient clojure -Sdeps "{:deps {com.metabase/ocient-driver {:local/root \"/build\"} ocient/ocient-driver-tests {:local/root \"/build/test\"}}}" \
-X:dev:drivers:drivers-dev:test :only metabase.driver.ocient-unit-test


###############
Expand All @@ -88,10 +92,11 @@ RUN --mount=type=cache,target=/root/.m2/repository \
:project-dir "\"$(pwd)\""

# Then build the driver
RUN clojure -X:build \
:project-dir "\"$(pwd)\"" \
:target-dir "./target" \
-v 100
RUN cd metabase && clojure \
-Sdeps "{:aliases {:ocient {:extra-deps {com.metabase/ocient-driver {:local/root \"/build\"} javax.activation/javax.activation-api {:mvn/version \"1.2.0\"}}}}}" \
-X:build:ocient \
build-drivers.build-driver/build-driver! \
"{:driver :ocient, :project-dir \"/build\", :target-dir \"/build/target\", :extra-paths [\"/build/src\" \"/build/resources\"]}"


############################
Expand All @@ -115,10 +120,6 @@ COPY src/ /build/metabase/modules/drivers/ocient/
COPY resources/metabase-plugin.yaml /build/metabase/modules/drivers/ocient/resources/
COPY test/ /build/metabase/modules/drivers/ocient/

# FIXME Can we get rid of the patch here and build an uberjar via clojure???
COPY patches/test-tarball.patch /build/
RUN git apply /build/test-tarball.patch

RUN --mount=type=cache,target=/root/.m2/repository \
clojure -X:test:deps prep

Expand All @@ -133,7 +134,7 @@ RUN --mount=type=cache,target=/root/.m2/repository \

# Build the uberjar
RUN --mount=type=cache,target=/root/.m2/repository \
clojure -T:dev:build uberjar
clojure -X:dev:build:build/uberjar


######################
Expand All @@ -153,6 +154,7 @@ ARG TARBALL_NAME=metabase_test_${METABASE_TEST_TARBALL_VERSION}
WORKDIR /build

# Place uberjar and remaining deps in a directory named "metabase_test" and tarball it
#TODO: it's possible we now need to include the e2e test dependencies here
RUN mv metabase/target/uberjar/metabase.jar metabase/ \
&& mv metabase metabase_test \
&& echo "{"\
Expand All @@ -172,7 +174,6 @@ RUN mv metabase/target/uberjar/metabase.jar metabase/ \
&& tar rvf metabase_test/target/${TARBALL_NAME}.tar metabase_test/test_modules/drivers/driver-deprecation-test-legacy/resources/metabase-plugin.yaml \
&& tar rvf metabase_test/target/${TARBALL_NAME}.tar metabase_test/README.md \
&& tar rvf metabase_test/target/${TARBALL_NAME}.tar metabase_test/frontend/test/__runner__/test_db_fixture.db.mv.db \
&& tar rvf metabase_test/target/${TARBALL_NAME}.tar metabase_test/frontend/test/__runner__/empty.db.mv.db \
&& tar rvf metabase_test/target/${TARBALL_NAME}.tar metabase_test/test_resources/* \
&& tar rvf metabase_test/target/${TARBALL_NAME}.tar metabase_test/test/metabase/test/data/dataset_definitions/*.edn \
&& gzip metabase_test/target/${TARBALL_NAME}.tar
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@ install:

# Builds the Metabase Ocient driver. A single JAR executable
build:
clojure -X:build :project-dir "\"$(shell pwd)\""
cd metabase && clojure \
-Sdeps "{:aliases {:ocient {:extra-deps {com.metabase/ocient-driver {:local/root \"$(shell pwd)\"} javax.activation/javax.activation-api {:mvn/version \"1.2.0\"}}}}}" \
-X:build:ocient \
build-drivers.build-driver/build-driver! \
"{:driver :ocient, :project-dir \"$(shell pwd)\", :target-dir \"$(shell pwd)/metabase/plugins\", :extra-paths [\"src\" \"resources\"]}"

# Run Metabase
run:
clojure -M:run > $(shell pwd)/metabase.log 2>&1 &
cd metabase && clojure -X:deps prep && cd modules/drivers && clojure -X:deps prep && cd ../.. && clojure -M:run > $(shell pwd)/metabase.log 2>&1 &

# Run Metabase, but output all logs to the CLI
run-log-in-cli:
cd metabase && clojure -X:deps prep && cd modules/drivers && clojure -X:deps prep && cd ../.. && clojure -M:run

# Run Ocient unit tests
run-unit-test:
DRIVERS=ocient clojure -X:dev:unit-test :project-dir "\"$(shell pwd)\""
cd metabase && DRIVERS=ocient clojure -Sdeps "{:deps {com.metabase/ocient-driver {:local/root \"$(shell pwd)\"} ocient/ocient-driver-tests {:local/root \"$(shell pwd)/test\"}}}" \
-X:dev:drivers:drivers-dev:test :only metabase.driver.ocient-unit-test

# Builds the test tarball which can be deployed in environments with JAVA installed
test-tarball:
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@ If you already have a Metabase binary release (see [Metabase distribution page](
The Ocient driver, can be built using [`Clouure Tools`](https://clojure.org/releases/tools):

```shell
# Outputs jar to `plugins/ocient.metabase-driver.jar`
# Outputs jar to `metabase/plugins/ocient.metabase-driver.jar`. Should be run from the project's root directory, NOT the metabase subrepo
make build
```

### Run a local Metabase instance
To run a local instance of Metabase, run:
To run a local instance of Metabase, run the following from the project root:

```shell
make run
```

For the front-end, you also should use whatever node version was LTS _at the time of whatever metabase version is being used_.

For the front-end: `yarn build-hot` (hot reloading enabled). This will run on localhost port 3000. If this results in a white screen with the console showing resources failing to load, you may need to run `yarn build` first.

### Run unit tests
To run the unit tests against the Ocient driver, run:

Expand Down
27 changes: 3 additions & 24 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,6 @@
:mvn/repos
{"sonatype" {:url "https://oss.sonatype.org/content/groups/staging/"}}

;; build the driver with clojure -X:build
:aliases
{:build
{:extra-deps {metabase/metabase-core {:local/root "metabase"}
metabase/build-drivers {:local/root "metabase/bin/build-drivers"
;; for whatever reason, the athena JDBC driver gets pulled in??
:exclusions [com.metabase/athena-jdbc]}
javax.activation/javax.activation-api {:mvn/version "1.2.0"}}
:exec-fn build-drivers.build-driver/build-driver!
:exec-args {:driver :ocient
:extra-paths ["src" "resources"]
:project-dir "."
:target-dir "./plugins"}}

;; for local development: start a REPL with
;;
;; clojure -A:dev (basic dev REPL that includes test namespaces)
Expand Down Expand Up @@ -72,15 +58,6 @@
"-Djava.awt.headless=true" ; prevent Java icon from randomly popping up in macOS dock
"-Dmb.jetty.port=3000"]}

;; includes unit test code as source paths. Run unit tests with clojure -X:dev:unit-test
:unit-test
{:extra-paths ["test" "metabase/test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test
:exec-args {:patterns ["metabase.driver.ocient-unit-test"]}}

;; includes test code as source paths. Run tests with clojure -X:dev:test
:test
{:extra-paths ["test" "metabase/test" "metabase/dev/src" "metabase/local/src" "metabase/shared/test" "metabase/test_resources"]
Expand All @@ -98,4 +75,6 @@
;; TODO -- figure out how to do a random port like in the old project.clj?
"-Dmb.jetty.port=3001"
"-Dmb.ocient.test.host=localhost"
"-Dmb.ocient.test.port=4050"]}}}
"-Dmb.ocient.test.port=4050"]}

}
2 changes: 1 addition & 1 deletion metabase
Submodule metabase updated 12177 files
2 changes: 1 addition & 1 deletion metabase_test_tarball_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.0
v1.1.0
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject metabase/ocient-driver "v1.1.0"
(defproject metabase/ocient-driver "v1.2.0"
:min-lein-version "2.5.0"

:repositories {"project" "file:repo"}
Expand Down
2 changes: 1 addition & 1 deletion resources/metabase-plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Complete list of options here: https://github.com/metabase/metabase/wiki/Metabase-Plugin-Manifest-Reference
info:
name: Metabase Ocient Driver
version: v1.1.0
version: v1.2.0
description: Allows Metabase to connect to Ocient databases.

driver:
Expand Down
Loading

0 comments on commit facc883

Please sign in to comment.