Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test : Create unit tests for User Info #79

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/qa-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Open Source Programs QA Checks

on: [push, pull_request]

jobs:
lint:
name: Linting and Code Formatting Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Installing QA-CHECKS Dependencies
run: |
python -m pip install --upgrade pip
pip install black==20.8b1
pip install isort==5.7.0
pip install flake8==3.8.4
- name: Running QA-CHECKS
run: ./osp-qa-checks
58 changes: 58 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Tests Build

on: [push, pull_request]

jobs:

build:

name: Run tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres
env:
POSTGRES_USER: osp
POSTGRES_PASSWORD: osp
POSTGRES_DB: osp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:

- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Installing dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install coverage==5.4

- name: Creating Zulip API key
run: echo -e "${{ secrets.ZULIP_API_KEY }}" >> download

- name: Migrating Test Database
run: python manage.py migrate

- name: Run tests
run: coverage run manage.py test

- name: Generate coverage report
run: coverage xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
63 changes: 51 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Open Source Programs (Backend)

![Build Status](https://github.com/anitab-org/open-source-programs-backend/workflows/Tests%20Build/badge.svg)
[![project chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://anitab-org.zulipchat.com/#narrow/stream/237907-open-source-progs)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
[![Open Source Love](https://badges.frapsoft.com/os/v3/open-source.svg?v=103)](https://github.com/anitab-org/open-source-programs-backend/)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/anitab-org/open-source-programs-backend)
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)

Open Source Programs (OSP) is an application that simplifies the processing and selection procedure of Open Source Programs of AnitaB.org Open Source or other third-party programs. This is the Backend repo for OSP.

## Tech Stack
Expand Down Expand Up @@ -36,33 +44,34 @@ Next follow these instructions.
CREATE DATABASE osp;
\c osp;
GRANT ALL PRIVILEGES ON DATABASE osp to osp;
GRANT ALL PRIVILEGES ON DATABASE test_osp to osp;
ALTER USER osp CREATEDB;
```
2. You need to download API key file from your user-settings on Zulip. The file you download is named as 'download' or rename that to 'download'.
3. Place that download file in the project's directory.
2. **Set the environment variables:** You need to download Zulip API key file from your user-settings on Zulip. The file you download is named as `download` or rename it to `download`. Place that download file in the project's directory. For more information follow [Environment Variables](#Environment-Variables) section.

4. Move into the project's directory.
3. Move into the project's directory.

```
cd open-source-programs-backend
```
5. Create virtual environment (this is not a hard requirement, but its advisable)
4. Create virtual environment (this is not a hard requirement, but its advisable)
```
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
```
6. To run the migrations run:
5. To run the migrations run:
```
python manage.py migrate
```
7. To run the server:
6. To run the server:
```
python manage.py runserver
```
8. Navigate to `http://localhost:8000/` in your browser.
9. To change the port you may run `python manage.py runserver <port_number>`
10. To run the migrations run: `python manage.py migrate`
11. You can terminate the process by `Ctrl+C` in your terminal.
7. Navigate to `http://localhost:8000/` in your browser.
8. To change the port you may run `python manage.py runserver <port_number>`
9. To run the migrations run: `python manage.py migrate`
10. You can terminate the process by `Ctrl+C` in your terminal.

Follow the given instructions for Login into the app.

Expand All @@ -74,10 +83,40 @@ Follow the given instructions for Login into the app.
````
Fill up the things it asked to and then Login into the app.

## Environment Variables

1. `Zulip API KEY file` - You can go [Zulip](https://anitab-org.zulipchat.com) and follow [these instructions to get your API KEY](https://zulip.com/api/api-keys#get-your-api-key). Download the file and save it in the root folder of the project with the name `download`.

2. `SENDGRID_API_KEY` - Follow the given steps to create a Sendgrid API key:

1. Go to [Sendgrid's website](https://app.sendgrid.com/guide)
2. Navigate to Settings on the left navigation bar, and then - select API Keys.
3. Click Create API Key.
4. Give your API key a name.
5. Select Full Access, Restricted Access, or Billing Access. If you're selecting Restricted Access, or Billing Access, select the specific permissions to give each category. For more information, see API key permissions.
6. Click Create & View.
7. The API KEY is generated and displayed to you just once. So be sure to copy and save it somewhere.

Add it to your .env file as follows:
```
export SENDGRID_API_KEY=<your-sendgrid-api-key>
```

## Testing

To run the tests run: `python manage.py test`.

## QA Checks

Before creating a pull-request, always run QA checks to make your code more readable and error-free. Steps to run QA checks are:
1. Install QA checks dependencies:
```
pip install black==20.8b1
pip install isort==5.7.0
pip install flake8==3.8.4
```
2. Run QA checks: `./osp-qa-checks`.

### Run with Docker

1. Make sure the latest version of docker and docker-compose are installed.
Expand All @@ -104,12 +143,12 @@ Run ``sudo docker-compose up`` from the root directory of project. Navigate to `

## Documentation

- Read the [Meeting minutes](https://docs.google.com/document/d/1YF13IbBrU1ln4ZF1fOpgb-xGRgIF6tZLSjIBQgDmN7k/edit) notes from our open sessions about the project.
- Read the [Meeting minutes](https://docs.google.com/document/d/1JSyAr9bO4hJJxFvThvn_LVjW0KcEspXpzvWULRC_xJE/edit) notes from our open sessions about the project.
- For setting up the project locally watch [this video](https://youtu.be/_b2RQGbYN9w).
- To learn about the project's initial features, watch the video of [project demonstration](https://youtu.be/3A746GppZ0Y).
- [Design and Mocks Google Drive folder](https://drive.google.com/drive/folders/1MybSH3f8peXGUSRxhDydDtoAi8WJL1th).
- [Timeline deliverables for the project during GSoC 2020](https://docs.google.com/document/d/1xl9F5kMZrKo4mNhnP0SKpk7WkQc8PLca1ym7EZMpjSc/edit).
- [GSoC 2020 Project Meeting Minutes](https://docs.google.com/document/d/1YF13IbBrU1ln4ZF1fOpgb-xGRgIF6tZLSjIBQgDmN7k/edit).
- [GSoC 2020 Project Meeting Minutes](https://docs.google.com/document/d/1YF13IbBrU1ln4ZF1fOpgb-xGRgIF6tZLSjIBQgDmN7k/edit) [Old].

For more information, you can read [backend project wiki](https://github.com/anitab-org/open-source-programs-backend/wiki) and the [web project wiki](https://github.com/anitab-org/open-source-programs-web/wiki).

Expand Down
15 changes: 15 additions & 0 deletions docs/github_actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# GitHub Actions

The purpose of using GitHub actions is to run tests and QA-checks.

## Configuration

There is currently one environment variable needed for configuring the GitHub actions. Details are mentioned below:

1. `ZULIP_API_KEY`: This secret variable is needed to run tests. This is the API key that we get from zulip to access ZULIP API. To get this key follow t[hese instructions from official documentation](https://zulip.com/api/api-keys#get-your-api-key). The content of this secret variable should look like:
```
[api]
[email protected]
key=********************************************
site=https://anitab-org.zulipchat.com
```
2 changes: 1 addition & 1 deletion main/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")

application = get_asgi_application()
Loading