-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Create a virtual environment in the project directory and activate it:
python -m venv env
#On Windows:
env\Scripts\activate
#On Unix or macOS:
source env/bin/activate
Navigate to the project directory where the requirements.txt file is located and install required Python libraries listed in requirements.txt:
pip install -r requirements.txt
This command installs all the necessary packages specified in the requirements.txt file.
Navigate to the directory containing manage.py and perform database migrations:
python manage.py makemigrations
python manage.py migrate
python manage.py runscript generate_data
python manage.py runscript generate_jobs
python manage.py runserver
python manage.py qcluster
These commands set up the database schema based on the Django models defined in the project. Qcluster is optional when testing and is used for automating periodic tasks
python manage.py createsuperuser
Access API documentation at http://localhost:8000/api/docs.
/objects GET lists an object, with method name objects_list, can also have filter parameters
/objects/id GET retrieves a unique instance of object(/objects/id), with method name object_detail(id)
/objects/id POST creates an object, with method name object_add
/objects/id PATCH updates an object, with method name object_update(id)
/objects/id DELETE deletes an object, with method name object_delete(id)
python manage.py runscript delete_all_data
python manage.py runscript generate_data
All login credentials for generated users are stored in the fake_credentials.txt file located in the scripts folder.
Access the test site at http://localhost:8000.
If you encounter a ModuleNotFoundError related to pkg_resources during the migration make sure all dependencies, setup tools & pip are installed and up to date.
pip install setuptools
pip install --upgrade pip
Then retry running the migration commands.
In our organization, we use GitHub workflows to automate the testing, building, and deployment of our projects. These workflows are defined using YAML files located in the .github/workflows directory of each repository.
Each workflow file in the .github/workflows directory defines a specific pipeline. Here are the main components of our workflow file with explanations:
- Triggers: Specify the events that trigger the workflow, such as push, pull_request or manually with workflow_dispatch.
- Jobs: Define a sequence of tasks that the workflow will run. Each job runs in a fresh instance of a virtual environment.
- Steps: Individual tasks within a job. These can include actions like checking out the repository, setting up Node.js, installing dependencies, running tests, and deploying the application.
- codeql.yml: CodeQL performs static analysis of your code, meaning it inspects the code without executing it. This allows it to identify potential vulnerabilities, bugs, and code smells early in the development process. CodeQL can detect a wide range of security issues, including SQL injection, cross-site scripting (XSS), buffer overflows, and other common vulnerabilities.