From 2b82c4cd8d97b8d24ee843e3c8c9ae9c0ff6d45b Mon Sep 17 00:00:00 2001 From: gitea_admin_user Date: Wed, 9 Apr 2025 16:46:05 +0000 Subject: [PATCH] Add initial files --- .gitea/workflows/cd_workflows.yml | 3 + .gitea/workflows/ci_workflows.yml | 74 ++++++++++++++++++++ Dockerfile | 29 ++++++++ README.md | 1 + flows.json | 19 +++++ request_schema.json | 1 + response_schema.json | 111 ++++++++++++++++++++++++++++++ 7 files changed, 238 insertions(+) create mode 100644 .gitea/workflows/cd_workflows.yml create mode 100644 .gitea/workflows/ci_workflows.yml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 flows.json create mode 100644 request_schema.json create mode 100644 response_schema.json diff --git a/.gitea/workflows/cd_workflows.yml b/.gitea/workflows/cd_workflows.yml new file mode 100644 index 0000000..a6bf97c --- /dev/null +++ b/.gitea/workflows/cd_workflows.yml @@ -0,0 +1,3 @@ +{} + + diff --git a/.gitea/workflows/ci_workflows.yml b/.gitea/workflows/ci_workflows.yml new file mode 100644 index 0000000..4dac8b4 --- /dev/null +++ b/.gitea/workflows/ci_workflows.yml @@ -0,0 +1,74 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - '*' + branches-ignore: + - main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; else echo "requirements.txt not found, skipping installation."; fi + + - name: Run Unit Tests + run: python -m unittest discover -s . -p 'test_*.py' + + build_and_push: + runs-on: ubuntu-latest + needs: test # Ensures `build_and_push` runs only if `test` succeeds + env: + DOCKER_HOST: unix:///var/run/docker.sock + steps: + - name: Identify Repository + id: extract_repo + run: echo "::set-output name=repo_name::${GITHUB_REPOSITORY##*/}" + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Configure Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker + + - name: Auth to Container Registry + uses: docker/login-action@v2 + with: + registry: centurion-version-control.default.svc.cluster.local:3000 + username: ${{ secrets.CI_USER }} + password: ${{ secrets.CI_USER_TOKEN }} + + - name: Pull flow_wrapper Image + run: | + docker pull centurion-version-control.default.svc.cluster.local:3000/centurion/system/flows-wrapper:latest + + - name: Build and push Container Image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: | + centurion-version-control.default.svc.cluster.local:3000/centurion/${{ steps.extract_repo.outputs.repo_name }}/${{ github.ref_name }}:${{ github.sha }} + centurion-version-control.default.svc.cluster.local:3000/centurion/${{ steps.extract_repo.outputs.repo_name }}/${{ github.ref_name }}:latest + build-args: | + CONTAINER_REGISTRY=centurion-version-control.default.svc.cluster.local:3000/centurion/system + REPO_NAME=${{ steps.extract_repo.outputs.repo_name }} + BRANCH_NAME=${{ github.ref_name }} + VERSION=${{ github.sha }} + NAMESPACE=default diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c98ddcf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +ARG CONTAINER_REGISTRY=version-control.centurion.localhost + +# User Dockerfile +FROM ${CONTAINER_REGISTRY}/flows-wrapper:latest + +ARG REPO_NAME=default +ARG BRANCH_NAME=default +ARG VERSION=default +ARG NAMESPACE=default + +# Set up working directory +WORKDIR /app + +# Copy user-specific files (flows.json, schemas, requirements) +COPY . . + +# Install dependencies specific to the flow if requirements.txt exists +RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi + +ENV REPO_NAME=$REPO_NAME +ENV BRANCH_NAME=$BRANCH_NAME +ENV VERSION=$VERSION +ENV NAMESPACE=$NAMESPACE + +# Run the generator to create the workflow.py +RUN python generator.py --input-file /app/flows.json --output-file /app/workflow.py + +# Set the entry point to the worker with the generated workflow +ENTRYPOINT ["python", "/app/flow_wrapper.py"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..59a3efc --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +**Hello world!!!** diff --git a/flows.json b/flows.json new file mode 100644 index 0000000..069f342 --- /dev/null +++ b/flows.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "id": "c2w3wcw04fjyio9un4f", + "data": { "label": "Request" }, + "position": { "x": 0, "y": 150 }, + "type": "requestNode" + }, + { + "id": "c2xjc7k07ahdxoi7ad7", + "data": { "label": "+" }, + "position": { "x": 0, "y": 150 }, + "type": "placeholder" + } + ], + "edges": [ + { "id": "c2w3wcw04fjyio9un4f=>c2xjc7k07ahdxoi7ad7", "source": "c2w3wcw04fjyio9un4f", "target": "c2xjc7k07ahdxoi7ad7", "type": "placeholder" } + ] +} diff --git a/request_schema.json b/request_schema.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/request_schema.json @@ -0,0 +1 @@ +{} diff --git a/response_schema.json b/response_schema.json new file mode 100644 index 0000000..4cda7b9 --- /dev/null +++ b/response_schema.json @@ -0,0 +1,111 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "HybridWorkflow Schema", + "type": "object", + "properties": { + "request": { + "type": "object", + "description": "Inputs for the workflow" + }, + "workflow_output": { + "type": "object", + "description": "Output of the workflow", + "properties": { + "workflow_id": { + "type": "string", + "description": "ID of the workflow instance" + }, + "run_id": { + "type": "string", + "description": "ID of the workflow run" + }, + "name": { + "type": "string", + "description": "Name of the workflow" + }, + "status": { + "type": "string", + "description": "Current status of the workflow", + "enum": [ + "in_progress", + "completed", + "failed" + ] + }, + "blocks": { + "type": "array", + "description": "Details of executed blocks", + "items": { + "type": "object", + "properties": { + "activity_id": { + "type": "string", + "description": "ID of the activity" + }, + "name": { + "type": "string", + "description": "Name of the activity" + }, + "status": { + "type": "string", + "description": "Status of the activity", + "enum": [ + "completed", + "skipped", + "failed" + ] + }, + "input": { + "type": "object", + "description": "Input parameters for the activity" + }, + "result": { + "type": [ + "object", + "null" + ], + "description": "Result of the activity" + }, + "error": { + "type": [ + "object", + "null" + ], + "description": "Error details if activity failed", + "properties": { + "code": { + "type": "string", + "description": "Error code" + }, + "description": { + "type": "string", + "description": "Error description" + }, + "details": { + "type": "object", + "description": "Additional error details" + } + } + } + } + } + }, + # "root_input": { + # "type": "object", + # "description": "Original root inputs passed to the workflow" + # } + }, + "required": [ + "workflow_id", + "run_id", + "name", + "status", + "blocks", + "root_input" + ] + } + }, + "required": [ + "root_inputs" + ] +}