Add GitHub Actions workflow for unit tests #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Unit Tests | |
on: | |
push: | |
branches: | |
- 315-Unittest-via-Github-actions | |
pull_request: | |
branches: | |
- 315-Unittest-via-Github-actions | |
jobs: | |
setup-python: | |
name: Setup Python Versions | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout Repository | |
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: Verify Python Installation | |
- name: Verify Python Version | |
run: | | |
python --version | |
pip --version | |
run-unittests: | |
name: Run Unit Tests on All Python Versions | |
needs: setup-python | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout Repository | |
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 Dependencies | |
- name: Install Dependencies | |
run: | | |
echo "geojson_pydantic>=1.0.2" > requirements.txt | |
pip install --upgrade pip | |
pip install -r requirements.txt --timeout 120 --verbose | |
pip install -e . --timeout 120 --verbose | |
# Step 4: Create .env File | |
- name: Set up Test Environment | |
run: | | |
echo "LOG_LEVEL=INFO" >> tests/.env | |
echo "CB_URL=http://localhost:1026" >> tests/.env | |
echo "IOTA_JSON_URL=http://localhost:4041" >> tests/.env | |
echo "IOTA_UL_URL=http://localhost:4061" >> tests/.env | |
echo "QL_URL=http://localhost:8668" >> tests/.env | |
echo "MQTT_BROKER_URL=mqtt://localhost:1883" >> tests/.env | |
echo "FIWARE_SERVICE=filip" >> tests/.env | |
echo "FIWARE_SERVICEPATH=/testing" >> tests/.env | |
# Step 5: Run Unit Tests | |
- name: Run Unit Tests | |
run: | | |
python -m unittest discover tests --verbose |