Skip to content

Commit

Permalink
Add airbyte rock (#12)
Browse files Browse the repository at this point in the history
* add airbyte rock
  • Loading branch information
kelkawi-a authored Oct 15, 2024
1 parent d007065 commit 8e8012e
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
with:
channel: 1.28-strict/stable
modules: '["test_charm.py"]'
juju-channel: 3.1/stable
juju-channel: 3.4/stable
self-hosted-runner: true
self-hosted-runner-label: "xlarge"
microk8s-addons: "dns ingress rbac storage metallb:10.15.119.2-10.15.119.4 registry"
trivy-severity-config: CRITICAL
6 changes: 6 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# stdlib CVEs
CVE-2024-24790
CVE-2023-24538
CVE-2023-24540

CVE-2024-21534
4 changes: 4 additions & 0 deletions airbyte_ui_rock/.trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore vulnerabilities on stdlib
CVE-2024-24790
CVE-2023-24538
CVE-2023-24540
15 changes: 15 additions & 0 deletions airbyte_ui_rock/patches/vite-config-http.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

diff --git a/airbyte-webapp/vite.config.mts b/airbyte-webapp/vite.config.mts
index 4cf29fa0de..6359ab2a55 100644
--- a/airbyte-webapp/vite.config.mts
+++ b/airbyte-webapp/vite.config.mts
@@ -118,6 +118,7 @@ export default defineConfig(() => {
},
},
server: {
+ https: false,
host: true,
port: Number(process.env.PORT) || 3000,
strictPort: true,
75 changes: 75 additions & 0 deletions airbyte_ui_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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
license: Apache-2.0
platforms:
amd64:

services:
airbyte-webapp:
override: replace
summary: "airbyte-webapp service"
startup: disabled
command: "/usr/bin/pnpm -C airbyte-webapp start"
environment:
PORT: "8080"

parts:
patches:
plugin: dump
source: ./patches
organize:
vite-config-http.patch: patches/vite-config-http.patch
stage:
- patches/vite-config-http.patch
prime:
- "-*"

airbyte-webapp:
after: [patches]
plugin: dump
source: https://github.com/airbytehq/airbyte-platform.git # yamllint disable-line
source-type: git
source-tag: v0.63.8
build-packages:
- jq
- curl
- nodejs
- npm
- coreutils
- bash
override-build: |
git apply ${CRAFT_STAGE}/patches/*.patch
curl https://raw.githubusercontent.com/creationix/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
cd airbyte-webapp
nvm install 20.11.0
nvm alias default 20.11.0
npm install -g pnpm@8.6.12 --force
pnpm install
pnpm run build
mkdir -p ${CRAFT_PART_INSTALL}/bin ${CRAFT_PART_INSTALL}/lib
# Copy build directory files to app
cp -r . ${CRAFT_PART_INSTALL}/airbyte-webapp
cp -r ../airbyte-connector-builder-resources/ ${CRAFT_PART_INSTALL}/airbyte-connector-builder-resources
cp -r /root/.nvm/versions/node/v20.11.0/bin/node ${CRAFT_PART_INSTALL}/node
cp -r /root/.nvm/versions/node/v20.11.0/bin/pnpm ${CRAFT_PART_INSTALL}/pnpm
cp -r /root/.nvm/versions/node/v20.11.0/lib ${CRAFT_PART_INSTALL}/
organize:
node: bin/node
pnpm: bin/pnpm
stage:
- airbyte-webapp
- airbyte-connector-builder-resources
- bin/node
- bin/pnpm
- lib
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": "/usr/bin/pnpm -C airbyte-webapp 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
2 changes: 1 addition & 1 deletion tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def perform_airbyte_integrations(ops_test: OpsTest):
apps=[APP_NAME_AIRBYTE_SERVER, APP_NAME_AIRBYTE_UI, "nginx-ingress-integrator"],
status="active",
raise_on_blocked=False,
timeout=600,
timeout=240,
)

assert ops_test.model.applications[APP_NAME_AIRBYTE_SERVER].units[0].workload_status == "active"
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": "/usr/bin/pnpm -C airbyte-webapp 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: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ commands =
description = Run integration tests
deps =
ipdb==0.13.9
juju==3.2.0.1
juju==3.5.2.0
pytest==7.1.3
pytest-operator==0.35.0
temporalio==1.1.0
Expand Down

0 comments on commit 8e8012e

Please sign in to comment.