Skip to content

Commit

Permalink
add airbyte rock
Browse files Browse the repository at this point in the history
  • Loading branch information
kelkawi-a committed Sep 4, 2024
1 parent d007065 commit ebe8e52
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 7 deletions.
63 changes: 63 additions & 0 deletions airbyte_ui_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

name: airbyte-ui
summary: Airbyte UI rock
description: Airbyte UI OCI image for the Airbyte UI charm
version: "1.0"
base: [email protected]
build-base: [email protected]
license: Apache-2.0
platforms:
amd64:

services:
airbyte-webapp:
override: replace
summary: "airbyte-webapp service"
startup: disabled
command: "cd app && pnpm start"
environment:
PORT: "8080"

# Please refer to
# https://discourse.ubuntu.com/t/unifying-user-identity-across-snaps-and-rocks/36469
# for more information about shared user.
# The UID 584792 corresponds to _daemon_ user.
run_user: _daemon_

parts:
airbyte-webapp:
plugin: dump
source: https://github.com/airbytehq/airbyte-platform.git # yamllint disable-line
source-type: git
source-commit: 34d28a9a8d3092a7e22eec6562946e6ef6ca36ab # v0.60.0
build-packages:
- gradle
- openjdk-21-jdk
- jq
- curl
- nodejs
- npm
- coreutils
- bash
override-build: |
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
npm install -g pnpm
cd airbyte-webapp
nvm install
corepack enable && corepack install
pnpm install
pnpm run build
# Copy current directory files to app
cp -r build ${CRAFT_PART_INSTALL}/airbyte-webapp
stage:
- airbyte-webapp
permissions:
- path: airbyte-webapp
owner: 584792
group: 584792
mode: "755"
1 change: 0 additions & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ resources:
airbyte-webapp:
type: oci-image
description: OCI image for Airbyte web UI
upstream-source: airbyte/webapp:0.60.0
3 changes: 2 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def _update(self, event):
"CONNECTOR_BUILDER_API_HOST": f"{server_svc}:{CONNECTOR_BUILDER_API_PORT}",
"CONNECTOR_BUILDER_API_URL": "/connector-builder-api",
"KEYCLOAK_INTERNAL_HOST": "localhost",
"PORT": WEB_UI_PORT,
}

self.model.unit.set_ports(WEB_UI_PORT)
Expand All @@ -207,7 +208,7 @@ def _update(self, event):
"services": {
self.name: {
"summary": self.name,
"command": "./docker-entrypoint.sh nginx",
"command": "cd app/ && pnpm start",
"startup": "enabled",
"override": "replace",
# Including config values here so that a change in the
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ def pytest_addoption(parser: pytest.Parser):
"""
# The prebuilt charm file.
parser.addoption("--charm-file", action="append", default=[])
# The charm image name:tag.
parser.addoption("--airbyte-ui-image", action="store", default="")
28 changes: 24 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,48 @@

import asyncio
import logging
from pathlib import Path

import pytest
import pytest_asyncio
from helpers import (
APP_NAME_AIRBYTE_SERVER,
APP_NAME_AIRBYTE_UI,
APP_NAME_TEMPORAL_ADMIN,
APP_NAME_TEMPORAL_SERVER,
METADATA,
create_default_namespace,
perform_airbyte_integrations,
perform_temporal_integrations,
)
from pytest import FixtureRequest
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)


@pytest.fixture(scope="module", name="charm_image")
def charm_image_fixture(request: FixtureRequest) -> str:
"""The OCI image for charm."""
charm_image = request.config.getoption("--airbyte-ui-image")
assert charm_image, "--airbyte-ui-image argument is required which should contain the name of the OCI image."
return charm_image


@pytest_asyncio.fixture(scope="module", name="charm")
async def charm_fixture(request: FixtureRequest, ops_test: OpsTest) -> str | Path:
"""The path to charm."""
charms = request.config.getoption("--charm-file")
if not charms:
charm = await ops_test.build_charm(".")
assert charm, "Charm not built"
return charm
return charms[0]


@pytest_asyncio.fixture(name="deploy", scope="module")
async def deploy(ops_test: OpsTest):
async def deploy(ops_test: OpsTest, charm: str, charm_image: str):
"""Test the app is up and running."""
charm = await ops_test.build_charm(".")
resources = {"airbyte-webapp": METADATA["resources"]["airbyte-webapp"]["upstream-source"]}
resources = {"airbyte-webapp": charm_image}

asyncio.gather(
ops_test.model.deploy(charm, resources=resources, application_name=APP_NAME_AIRBYTE_UI),
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_ready(self):
"services": {
APP_NAME: {
"summary": APP_NAME,
"command": "./docker-entrypoint.sh nginx",
"command": "cd app/ && pnpm start",
"startup": "enabled",
"override": "replace",
"environment": {
Expand All @@ -141,6 +141,7 @@ def test_ready(self):
"INTERNAL_API_HOST": f"airbyte-k8s:{INTERNAL_API_PORT}",
"CONNECTOR_BUILDER_API_HOST": f"airbyte-k8s:{CONNECTOR_BUILDER_API_PORT}",
"KEYCLOAK_INTERNAL_HOST": "localhost",
"PORT": 8080,
},
"on-check-failure": {"up": "ignore"},
}
Expand Down
2 changes: 2 additions & 0 deletions trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
severity:
- CRITICAL

0 comments on commit ebe8e52

Please sign in to comment.