Skip to content

CI workflow

CI workflow #46

Workflow file for this run

name: CI for FiLiP
on:
push:
branches:
- "**"
pull_request:
branches:
- main
jobs:
setup_and_fiware:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Step 3: Install build tools
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
# Step 4: Install dependencies
- name: Install dependencies
run: |
pip install .[development]
# Step 5: Create .env file
- name: Create .env file
run: |
echo "CB_URL=http://orion:1026" > .env
echo "IOTA_URL=http://iot-agent-json:4041" >> .env
echo "QL_URL=http://quantumleap:8668" >> .env
echo "MQTT_BROKER_URL=mqtt://mqtt-broker:1883" >> .env
# Step 6: Clone FIWARE repository
- name: Clone FIWARE repository
run: |
git clone https://github.com/N5GEH/n5geh.platform.git
# Step 7: Start docker pull
- name: Start FIWARE services
working-directory: n5geh.platform/v2
run: docker compose pull
test:
needs: setup_and_fiware
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Step 8: start docker
- name: Checking Docker
run: docker ps -a
# Step 7: Start FIWARE services
- name: Start FIWARE services
working-directory: n5geh.platform/v2
run: docker compose up -d
# Step 8: Wait for FIWARE services to start
- name: Wait for FIWARE services to start
run: |
for i in {1..100}; do
curl -s http://localhost:1026/version && \
curl -s http://localhost:4041/iot/about && \
curl -s http://localhost:8668/version && break || sleep 5
done
# Step 9: Verify FIWARE services
- name: Verify FIWARE services
run: |
curl -X GET "http://localhost:1026/version"
curl -X GET "http://localhost:4041/iot/about"
curl -X GET "http://localhost:8668/version"
# Step 10: Print Docker logs for debugging
- name: Print Docker logs
working-directory: n5geh.platform/v2
run: docker compose logs
# Step 3: Install build tools
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
# Step 4: Install test dependencies
- name: Install test dependencies
run: |
pip install .[test]
pip install pytest
# Step 5: Run tests with both unittest and pytest
- name: Run tests
run: |
TEST_PATH="tests"
python -m unittest discover -s $TEST_PATH -p "test_*.py" || true
python -m pytest $TEST_PATH || true