diff --git a/airbyte_ui_rock/rockcraft.yaml b/airbyte_ui_rock/rockcraft.yaml new file mode 100644 index 0000000..6cadd37 --- /dev/null +++ b/airbyte_ui_rock/rockcraft.yaml @@ -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: ubuntu@22.04 +build-base: ubuntu@22.04 +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" diff --git a/charmcraft.yaml b/charmcraft.yaml index 3439acf..0689965 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -88,4 +88,3 @@ resources: airbyte-webapp: type: oci-image description: OCI image for Airbyte web UI - upstream-source: airbyte/webapp:0.60.0 diff --git a/src/charm.py b/src/charm.py index 8210255..ae63b0f 100755 --- a/src/charm.py +++ b/src/charm.py @@ -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) @@ -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 diff --git a/tests/conftest.py b/tests/conftest.py index 04df5c6..f6cdd0e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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="") diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 2b116cb..c7d23fc 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -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), diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index aea0e2f..8e2aefb 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -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": { @@ -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"}, } diff --git a/trivy.yaml b/trivy.yaml new file mode 100644 index 0000000..d6fb861 --- /dev/null +++ b/trivy.yaml @@ -0,0 +1,2 @@ +severity: + - CRITICAL