Skip to content

Commit

Permalink
Merge pull request #69 from CanDIG/daisieh/no-travis
Browse files Browse the repository at this point in the history
DIG-1710: switch from Travis to GitHub Actions
  • Loading branch information
daisieh authored Oct 3, 2024
2 parents 3c79f4b + 9a552a6 commit ea5adb4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 480 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Github Actions Test

on: [push]
jobs:
build:
runs-on: ubuntu-latest
# Add in environment variables for the entire "build" job
env:
CANDIG_URL: "http://localhost"
SERVICE_NAME: "federation"
VAULT_URL: "http://localhost"
CONFIG_DIR: "config"
TESTING: true
strategy:
matrix:
python-version: ['3.12']
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
sudo mkdir -p /run/secrets
sudo touch /run/secrets/vault-approle-token
sudo chmod 777 /run/secrets/vault-approle-token
echo "test" > /run/secrets/vault-approle-token
sudo mkdir -p /home/candig
sudo touch /home/candig/roleid
sudo chmod 777 /home/candig/roleid
echo "test" > /home/candig/roleid
pip install -r requirements.txt
- name: Test with pytest
run: pytest --cov=candig_federation tests/ -vv
12 changes: 7 additions & 5 deletions candig_federation/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@


TYK_FEDERATION_API_ID = os.getenv("TYK_FEDERATION_API_ID")

APPROLE_TOKEN = None
if os.getenv("TESTING", False):
APPROLE_TOKEN = "test"

def get_registered_servers():
stored_servers_dict, status_code = authx.auth.get_service_store_secret("federation", key="servers")
stored_servers_dict, status_code = authx.auth.get_service_store_secret("federation", key="servers", token=APPROLE_TOKEN)
if status_code == 404:
# no value was found, so this must need to be initialized
stored_servers_dict, status_code = authx.auth.set_service_store_secret("federation", key="servers", value=json.dumps({"servers": {}}))
stored_servers_dict, status_code = authx.auth.set_service_store_secret("federation", key="servers", value=json.dumps({"servers": {}}), token=APPROLE_TOKEN)
return {}
if status_code != 200:
logger.error(f"Error in get_registered_servers: {stored_servers_dict}")
Expand Down Expand Up @@ -73,10 +75,10 @@ def unregister_server(server_id):


def get_registered_services():
stored_services_dict, status_code = authx.auth.get_service_store_secret("federation", key="services")
stored_services_dict, status_code = authx.auth.get_service_store_secret("federation", key="services", token=APPROLE_TOKEN)
if status_code == 404:
# no value was found, so this must need to be initialized
stored_services_dict, status_code = authx.auth.set_service_store_secret("federation", key="services", value=json.dumps({"services": {}}))
stored_services_dict, status_code = authx.auth.set_service_store_secret("federation", key="services", value=json.dumps({"services": {}}), token=APPROLE_TOKEN)
return {}
if status_code != 200:
logger.error(f"Error in get_registered_services: {stored_services_dict}")
Expand Down
Loading

0 comments on commit ea5adb4

Please sign in to comment.