From d3487e53bb94053b8882ff02c0f2c010ac0c7f25 Mon Sep 17 00:00:00 2001 From: Satya Prakash <35588980+satya7289@users.noreply.github.com> Date: Wed, 29 Jul 2020 21:11:24 +0530 Subject: [PATCH 1/8] feat: Codecov --- .github/workflows/main.yml | 58 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 55 ------------------------------------ 2 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..07f4a83c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,58 @@ +name: Run Tests + +on: + push: + branches: [ develop ] + pull_request: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.6, 3.7] + env: + SECRET_KEY: foobarbaz + GOOGLE_MAPS_API_KEY: $GOOGLE_MAPS_API_KEY + ZOOM_API_KEY: $ZOOM_API_KEY + ZOOM_API_SECRET: $ZOOM_API_SECRET + ZOOM_USER_ID: $ZOOM_USER_ID + + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: test + POSTGRES_PASSWORD: password + POSTGRES_DB: systersdb + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements/dev.txt + sudo apt-get install python-gdal + python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')" + + - name: Run Flake Test + run: flake8 systers_portal + + - name: Run Tests + run: coverage run systers_portal/manage.py test --settings=systers_portal.settings.testing + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + name: codecov-umbrella + fail_ci_if_error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 74dd2384..00000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -sudo: true -language: python -dist: bionic -env: - - MOZ_HEADLESS=1 - -addons: - firefox: "55.0" - -services: - - postgresql - -python: - - "3.6" - - "3.7" - -before_install: - - wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz - - tar -xzvf geckodriver-v0.20.1-linux64.tar.gz - - sudo mv geckodriver /usr/local/bin -install: - - "pip install -r requirements/dev.txt" - - pip install coveralls==0.4.4 - - sudo apt-get install python-gdal - - python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords')" -before_script: - - export GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY - - export ZOOM_API_KEY=$ZOOM_API_KEY - - export ZOOM_API_SECRET=$ZOOM_API_SECRET - - export ZOOM_USER_ID=$ZOOM_USER_ID - - export SECRET_KEY=foobarbaz -# - curl -o ipdb.tar.gz https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENSE_KEY&suffix=tar.gz -# - tar -xzf ipdb.tar.gz -C systers_portal/ - - psql -c "CREATE DATABASE systersdb;" -U postgres - - cp .env.example .env -script: - - coverage run systers_portal/manage.py test --settings=systers_portal.settings.testing - - flake8 systers_portal -notifications: - irc: - channels: "irc.freenode.org#systers-dev" - template: - - "%{repository}@%{branch}: %{message} (%{build_url})" - on_success: change - on_failure: change - use_notice: true - email: false - webhooks: - urls: - - https://webhooks.gitter.im/e/c403378d624b2391961e - on_success: change - on_failure: always - on_start: false -after_success: - coveralls --rcfile=.coveragerc From 137b2a62944930c2b625aa05e859065481fdc2ef Mon Sep 17 00:00:00 2001 From: satya7289 Date: Thu, 30 Jul 2020 01:32:38 +0530 Subject: [PATCH 2/8] feat: Update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e666689..3ace3ad4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Systers Portal [![Build Status](https://travis-ci.org/systers/portal.svg?branch=master)](https://travis-ci.org/systers/portal) [![Coverage Status](https://coveralls.io/repos/github/systers/portal/badge.svg?branch=master)](https://coveralls.io/r/systers/portal?branch=master) +Systers Portal [![Build Status](https://codecov.io/gh/anitab-org/portal/branch/develop/graph/badge.svg)](https://codecov.io/gh/anitab-org/portal/) [![Coverage Status](https://coveralls.io/repos/github/systers/portal/badge.svg?branch=master)](https://coveralls.io/r/systers/portal?branch=master) ============== Systers Portal is for Systers communities to post and share information within From d388010554df6683093905c8f85a72ba8853ca39 Mon Sep 17 00:00:00 2001 From: satya7289 Date: Tue, 4 Aug 2020 21:54:27 +0530 Subject: [PATCH 3/8] feat: Update for 3.8 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07f4a83c..f8109f75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - python-version: [3.6, 3.7] + python-version: [3.6, 3.7, 3.8] env: SECRET_KEY: foobarbaz GOOGLE_MAPS_API_KEY: $GOOGLE_MAPS_API_KEY From 4bf562c814b395aac93718ea99616af32ba635cb Mon Sep 17 00:00:00 2001 From: satya7289 Date: Thu, 20 Aug 2020 13:21:27 +0530 Subject: [PATCH 4/8] feat: Update Testcases for python- 3.8 --- systers_portal/meetup/tests/test_forms.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/systers_portal/meetup/tests/test_forms.py b/systers_portal/meetup/tests/test_forms.py index 203b502b..cae176b7 100644 --- a/systers_portal/meetup/tests/test_forms.py +++ b/systers_portal/meetup/tests/test_forms.py @@ -61,9 +61,9 @@ def test_request_meetup_form_with_past_date(self): date = (timezone.now() - timedelta(2)).date() time = timezone.now().time() data = {'title': 'Foo', 'slug': 'foo', 'date': date, 'time': time, - 'meetup_location': self.location, + 'meetup_location': self.location.id, 'description': "It's a test meetup."} - form = AddMeetupForm(data=data, created_by=self.systers_user, leader=self.systers_user) + form = RequestMeetupForm(data=data, created_by=self.systers_user) self.assertFalse(form.is_valid()) self.assertTrue(form.errors['date'], ["Date should not be before today's date."]) @@ -72,13 +72,12 @@ def test_request_meetup_form_with_passed_time(self): date = timezone.now().date() time = (timezone.now() - timedelta(2)).time() data = {'title': 'Foo', 'slug': 'foo', 'date': date, 'time': time, - 'meetup_location': self.location, + 'meetup_location': self.location.id, 'description': "It's a test meetup."} - form = AddMeetupForm(data=data, created_by=self.systers_user, leader=self.systers_user) + form = RequestMeetupForm(data=data, created_by=self.systers_user) self.assertFalse(form.is_valid()) self.assertTrue(form.errors['time'], ["Time should not be a time that has already passed."]) - self.assertRaises(ValidationError, form.clean_time()) class AddMeetupFormTestCase(MeetupFormTestCaseBase, TestCase): From 0dc2fdfcbbc12bd1af247bcf1722f0b5141da99a Mon Sep 17 00:00:00 2001 From: satya7289 Date: Thu, 20 Aug 2020 13:33:23 +0530 Subject: [PATCH 5/8] feat: Fix flake error --- systers_portal/meetup/tests/test_forms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/systers_portal/meetup/tests/test_forms.py b/systers_portal/meetup/tests/test_forms.py index cae176b7..b4c78fb2 100644 --- a/systers_portal/meetup/tests/test_forms.py +++ b/systers_portal/meetup/tests/test_forms.py @@ -4,7 +4,6 @@ from django.utils.timezone import timedelta from cities_light.models import City, Country from django.contrib.contenttypes.models import ContentType -from django.core.exceptions import ValidationError from meetup.forms import (AddMeetupForm, EditMeetupForm, From 1cd8ac7f6113f3b89a0d66cf81174c91adc3e93f Mon Sep 17 00:00:00 2001 From: satya7289 Date: Thu, 20 Aug 2020 22:37:59 +0530 Subject: [PATCH 6/8] feat: Update for .env variables --- .env.example | 8 ++++++++ systers_portal/systers_portal/settings/testing.py | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.env.example b/.env.example index 5d721c22..8aa3adea 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,14 @@ DB_PASSWORD = DB_HOST = localhost DB_PORT = 5432 +# Test DB settings + +TEST_DB_NAME = systersdb +TEST_DB_USER = +TEST_DB_PASSWORD = +TEST_DB_HOST = localhost +TEST_DB_PORT = 5432 + # Email settings EMAIL_HOST = localhost diff --git a/systers_portal/systers_portal/settings/testing.py b/systers_portal/systers_portal/settings/testing.py index 361daef3..f21de47c 100644 --- a/systers_portal/systers_portal/settings/testing.py +++ b/systers_portal/systers_portal/settings/testing.py @@ -11,11 +11,11 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', - 'NAME': config('DB_NAME', default='systersdb'), - 'USER': config('DB_USER'), - 'PASSWORD': config('DB_PASSWORD'), - 'HOST': config('DB_HOST', default='localhost'), - 'PORT': config('DB_PORT', default=5432, cast=int), + 'NAME': config('TEST_DB_NAME', default='systersdb'), + 'USER': config('TEST_DB_USER'), + 'PASSWORD': config('TEST_DB_PASSWORD'), + 'HOST': config('TEST_DB_HOST', default='localhost'), + 'PORT': config('TEST_DB_PORT', default=5432, cast=int), } } From d563a076990f9b10541d858ac96209450524772f Mon Sep 17 00:00:00 2001 From: satya7289 Date: Thu, 20 Aug 2020 22:51:57 +0530 Subject: [PATCH 7/8] feat: Update for .env variables --- .env.example | 4 ++-- .github/workflows/main.yml | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 8aa3adea..ccf86dc3 100644 --- a/.env.example +++ b/.env.example @@ -13,8 +13,8 @@ DB_PORT = 5432 # Test DB settings TEST_DB_NAME = systersdb -TEST_DB_USER = -TEST_DB_PASSWORD = +TEST_DB_USER = test +TEST_DB_PASSWORD = password TEST_DB_HOST = localhost TEST_DB_PORT = 5432 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8109f75..2514a7e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,12 +12,6 @@ jobs: strategy: matrix: python-version: [3.6, 3.7, 3.8] - env: - SECRET_KEY: foobarbaz - GOOGLE_MAPS_API_KEY: $GOOGLE_MAPS_API_KEY - ZOOM_API_KEY: $ZOOM_API_KEY - ZOOM_API_SECRET: $ZOOM_API_SECRET - ZOOM_USER_ID: $ZOOM_USER_ID services: postgres: @@ -40,6 +34,7 @@ jobs: - name: Install Dependencies run: | + cp .env.example .env python -m pip install --upgrade pip pip install -r requirements/dev.txt sudo apt-get install python-gdal From c860727b056d621765476fca3708006db081736c Mon Sep 17 00:00:00 2001 From: satya7289 Date: Sat, 22 Aug 2020 19:46:40 +0530 Subject: [PATCH 8/8] feat: Use SQLite for test db --- .env.example | 8 -------- .github/workflows/main.yml | 12 ------------ systers_portal/systers_portal/settings/testing.py | 8 ++------ 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/.env.example b/.env.example index ccf86dc3..5d721c22 100644 --- a/.env.example +++ b/.env.example @@ -10,14 +10,6 @@ DB_PASSWORD = DB_HOST = localhost DB_PORT = 5432 -# Test DB settings - -TEST_DB_NAME = systersdb -TEST_DB_USER = test -TEST_DB_PASSWORD = password -TEST_DB_HOST = localhost -TEST_DB_PORT = 5432 - # Email settings EMAIL_HOST = localhost diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2514a7e3..fde38cd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,18 +12,6 @@ jobs: strategy: matrix: python-version: [3.6, 3.7, 3.8] - - services: - postgres: - image: postgres:10.8 - env: - POSTGRES_USER: test - POSTGRES_PASSWORD: password - POSTGRES_DB: systersdb - ports: - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v2 diff --git a/systers_portal/systers_portal/settings/testing.py b/systers_portal/systers_portal/settings/testing.py index f21de47c..35ab71d7 100644 --- a/systers_portal/systers_portal/settings/testing.py +++ b/systers_portal/systers_portal/settings/testing.py @@ -10,12 +10,8 @@ DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': config('TEST_DB_NAME', default='systersdb'), - 'USER': config('TEST_DB_USER'), - 'PASSWORD': config('TEST_DB_PASSWORD'), - 'HOST': config('TEST_DB_HOST', default='localhost'), - 'PORT': config('TEST_DB_PORT', default=5432, cast=int), + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }