I’m testing my Flask application on CircleCI. It gave me the errors when I pushed my latest commit:
============================= test session starts ==============================
platform linux -- Python 3.6.4, pytest-3.4.2, py-1.5.2, pluggy-0.6.0
rootdir: /home/circleci/project, inifile:
collected 0 items / 1 errors
------ generated xml file: /home/circleci/project/test-reports/junit.xml -------
==================================== ERRORS ====================================
_____________________ ERROR collecting tests/test_views.py _____________________
tests/test_views.py:5: in <module>
from less0n import app, database
less0n/__init__.py:17: in <module>
import less0n.views
less0n/views.py:6: in <module>
from less0n.models import *
less0n/models.py:99: in <module>
class Teaching(db.Base):
E AttributeError: 'SQLAlchemy' object has no attribute 'Base'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.63 seconds ============================
Exited with code 2
This was a bug; however, I’ve fixed it in the latest commit but seems CircleCI was still using the old version. Now in the GitHub repo line 99 of models.py is no longer class Teaching(db.Base):
.
I’ve cleared the source and dependencies caches in CircleCI settings. It did not help.
My config file looks like this:
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6.4-stretch-browsers
environment:
FLASK_CONFIG: test
PYTHONPATH: ${PYTHONPATH}:${HOME}/google_appengine
- image: circleci/postgres:9.6-alpine-ram
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: "deleted"
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
name: Set up Google App Engline SDK
command: |
curl -o ${HOME}/google_appengine_1.9.67.zip https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.67.zip
unzip -q -d ${HOME} ${HOME}/google_appengine_1.9.67.zip
- run:
name: Install Python dependencies in a virtual environment
command: |
python3 -m venv less0n
. less0n/bin/activate
pip3 install -r requirements.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "less0n"
- run:
name: Testing
command: |
. less0n/bin/activate
pip3 install pytest
mkdir test-reports
python3 -m pytest --junitxml=test-reports/junit.xml
- store_artifacts:
path: test-reports/
- store_test_results:
path: test-reports/
deploy:
filters:
branches:
only:
- master
docker:
- image: google/cloud-sdk:latest
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
name: Authenticate with Google Cloud Platform
command: |
echo $CLIENT_SECRET | base64 --decode > ${HOME}/client-secret.json
gcloud auth activate-service-account --key-file ${HOME}/client-secret.json
- run:
name: Deploy to Google App Engine
command: |
gcloud config set project ${GCLOUD_PROJECT_ID}
gcloud -q app deploy app.yaml --promote --version=1
- run:
name: Discarding all changes
command: git checkout -- .
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "less0n"
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
Any thoughts on this? Thanks in advance.