From 5a0cdf7a19e83634e4b944c0a59bc586cc9c4dc8 Mon Sep 17 00:00:00 2001 From: Mostafa-wael Date: Fri, 9 Aug 2024 18:01:03 +0300 Subject: [PATCH] Fix the pipeline and create the deploy script --- .github/workflows/test.yml | 12 ++--- deploy.sh | 76 ++++++++++++++++++++++++++++++++ requirements.txt | 3 ++ testing/runner/faas_interface.py | 11 +++-- 4 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 deploy.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29b1afc..fe78598 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,8 @@ on: branches: - main -jobs: - Linux: +jobs: + Linux_cli: name: Linux - Ubuntu Run runs-on: ubuntu-latest steps: @@ -36,9 +36,9 @@ jobs: - name: Run Tests Suits run: | - find test-suites -type f -name "*.yaml" -exec python ./testing.py -f {} -V \; + find test-suites -type f -name "*.yaml" -exec python ./testing.py -f {} -V -e cli \; - Windows: + Windows_cli: name: Windows Run runs-on: windows-latest steps: @@ -74,7 +74,7 @@ jobs: - name: Run Test Suits shell: bash run: | - find test-suites -type f -name "*.yaml" -exec python ./testing.py -f {} -V \; + find test-suites -type f -name "*.yaml" -exec python ./testing.py -f {} -V -e cli \; # MacOS: @@ -100,4 +100,4 @@ jobs: # - name: Run Tests Suits # run: | - # find test-suites -type f -name "*.yaml" -exec python ./testing.py -f {} -V \; + # find test-suites -type f -name "*.yaml" -exec python ./testing.py -f {} -V -e cli \; diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..000ebe3 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# Accept the repo path as an argument +repo_path=$1 + +# Run the metacall-deploy command and store the output +output=$(metacall-deploy --inspect OpenAPIv3 --dev --workdir "$repo_path") + +# Parse the JSON output using jq to extract the server URL and paths +server_url=$(echo "$output" | jq -r '.[0].servers[0].url') +paths=$(echo "$output" | jq -r '.[0].paths | keys[]') + +# Output the server URL and paths +echo "Server URL: $server_url" +echo "Available Paths:" +for path in $paths; do + echo "$server_url$path" +done + +# Set the server URL as an environment variable +export SERVER_URL=$server_url + + +# multi line comment +: ' Exmaple output +[ + { + "openapi": "3.0.0", + "info": { + "title": "MetaCall Cloud FaaS deployment 'time-app-web'", + "description": "", + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost:9000/aa759149a70a/time-app-web/v1", + "description": "MetaCall Cloud FaaS" + } + ], + "paths": { + "/call/time": { + "get": { + "summary": "", + "description": "", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + }, + "/call/index": { + "get": { + "summary": "", + "description": "", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": {} + } + } + } + } + } + } + } + } +] +' \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index be2b74d..767fd22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ +config==0.5.1 +metacall==0.5.0 PyYAML==6.0.1 +PyYAML==6.0.2 diff --git a/testing/runner/faas_interface.py b/testing/runner/faas_interface.py index eed3797..f430e54 100644 --- a/testing/runner/faas_interface.py +++ b/testing/runner/faas_interface.py @@ -1,14 +1,19 @@ import json import subprocess -import config +import os from testing.runner.runner_interface import RunnerInterface class FaaSInterface(RunnerInterface): def __init__(self): - self.base_url = "http://localhost:9000/9b150a863eeb" + try: + # Get the base URL from the environment variable SERVER_URL + self.base_url = os.environ['SERVER_URL'] + except KeyError: + # If the environment variable is not set, return an error + raise KeyError("SERVER_URL environment variable not set, make sure to run 'source ./deploy.sh /path/to/repo' before running the tests") def get_name(self): return "faas" @@ -41,7 +46,7 @@ def parse_function_call(self, function_call): def run_test_command(self, file_path, function_call): function_name, params = self.parse_function_call(function_call) - url = f"{self.base_url}/{config.project_name}/v1/call/{function_name}" + url = f"{self.base_url}/call/{function_name}" if params: command = self.post_request(url, params)