Skip to content

Commit

Permalink
Fix the pipeline and create the deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mostafa-wael committed Aug 9, 2024
1 parent 6da4b97 commit 5a0cdf7
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 9 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches:
- main

jobs:
Linux:
jobs:
Linux_cli:
name: Linux - Ubuntu Run
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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 \;
76 changes: 76 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -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": {}
}
}
}
}
}
}
}
}
]
'
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
config==0.5.1
metacall==0.5.0
PyYAML==6.0.1
PyYAML==6.0.2
11 changes: 8 additions & 3 deletions testing/runner/faas_interface.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5a0cdf7

Please sign in to comment.