Skip to content

typing: adding check and fixing #155

typing: adding check and fixing

typing: adding check and fixing #155

Workflow file for this run

name: Test
on:
pull_request:
branches: [master]
push:
branches: [master]
schedule:
# * is a special character in YAML so you have to quote this string
# min hours day(month) month day(week)
- cron: "0 0 * * 0"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
pytester:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
backend: ["local", "db"]
exclude:
# ToDo: take if back when the connection become stable
# or resolve using `InMemoryMongoClient`
- { os: "macOS-latest", backend: "db" }
env:
CACHIER_TEST_HOST: "localhost"
CACHIER_TEST_PORT: "27017"
#CACHIER_TEST_DB: "dummy_db"
#CACHIER_TEST_USERNAME: "myuser"
#CACHIER_TEST_PASSWORD: "yourpassword"
CACHIER_TEST_VS_DOCKERIZED_MONGO: "true"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e . -r tests/requirements.txt
- name: Unit tests (local)
if: matrix.backend == 'local'
run: pytest -m "not mongo" --cov=cachier --cov-report=term --cov-report=xml:cov.xml
- name: Setup docker (missing on MacOS)
if: runner.os == 'macOS' && matrix.backend == 'db'
run: |
brew install docker
colima start
# For testcontainers to find the Colima socket
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
# ToDo: find a way to cache docker images
#- name: Cache Container Images
# if: matrix.backend == 'db'
# uses: borda/cache-container-images-action@b32a5e804cb39af3c3d134fc03ab76eac0bfcfa9
# with:
# prefix-key: "mongo-db"
# images: mongo:latest
- name: Start MongoDB in docker
if: matrix.backend == 'db'
run: |
# start MongoDB in a container
docker run -d -p ${{ env.CACHIER_TEST_PORT }}:27017 --name mongodb mongo:latest
# wait for MongoDB to start, which is in average 5 seconds
sleep 5
# show running containers
docker ps -a
- name: Unit tests (DB)
if: matrix.backend == 'db'
run: pytest -m "mongo" --cov=cachier --cov-report=term --cov-report=xml:cov.xml
- name: Speed eval
run: python tests/speed_eval.py
- name: Upload coverage to Codecov
continue-on-error: true
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }} # required
flags: ${{ matrix.backend }}
testing-guardian:
runs-on: ubuntu-latest
needs: pytester
if: always()
steps:
- run: echo "${{ needs.pytester.result }}"
- name: failing...
if: needs.pytester.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result)
timeout-minutes: 1
run: sleep 90