My GitHub workflow that runs tests on different versions of Python:
name: Tests
on:
push:
branches:
- Development
jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: python -m unittest discover -s ./tests -p '*.py'
One of the tests creates a connection to an SQLite database (sqlite3.connect('MIND.db')
). This creates and opens the database. I get:
sqlite3.OperationalError: unable to open database file
I know about permissions but don't know which one to set to write
for it to work (as far as I know, the problem is that the workflow is not allowed to write, but I don't know how to fix this).
Turns out that the database was attempted to be created in a folder that didn't exist. I added a command before the one that runs the tests that creates the missing folder. Now the workflow runs fine.