Skip to content

CI workflow

CI workflow #86

Workflow file for this run

name: CI for FiLiP
on:
push:
branches:
- "**"
pull_request:
branches:
- main
jobs:
setup:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false # Ensure all setups run even if one fails
steps:
# Step 1: Checkout correct branch
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: 315-Unittest-via-Github-actions # Ensure correct branch
# Step 2: Debug - Verify directory structure
- name: Debug - Verify Repository Structure
run: |
pwd
ls -la
# Step 3: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# Step 6: Create .env file
- name: Create .env file
run: |
cat <<EOF > .env
LOG_LEVEL="INFO"
CB_URL="http://localhost:1026"
ORION_LD_URL="http://localhost:1027"
IOTA_JSON_URL="http://localhost:4041"
IOTA_UL_URL="http://localhost:4061"
QL_URL="http://localhost:8668"
MQTT_BROKER_URL="mqtt://localhost:1883"
MQTT_BROKER_URL_INTERNAL="mqtt://mqtt-broker:1883"
LD_MQTT_BROKER_URL="mqtt://localhost:1883"
LD_MQTT_BROKER_URL_INTERNAL="mqtt://mqtt-broker:1883"
FIWARE_SERVICE="filip"
FIWARE_SERVICEPATH="/testing"
EOF
# Step 7: Verify .env file
- name: Verify .env file
run: cat .env
# Step 8: Start FIWARE services
- name: Start FIWARE Services
run: |
cd docker
docker compose up -d
# Step 9: Wait for FIWARE Services
- name: Wait for FIWARE Services
run: |
for i in {1..30}; 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 4: Install dependencies (if cache is empty)
- name: Install dependencies (if needed)
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install .
pip install pytest
# Step 10: Debug - Show Running Docker Containers
- name: Debug - Show Running Docker Containers
run: docker ps -a
# Step 6: Navigate back to tests folder
- name: Navigate to Tests Folder
run: |
cd $GITHUB_WORKSPACE
ls -la
# Step 6: Run Tests
- name: Run tests with unittest and pytest
run: |
python -m pytest tests