Skip to content

Commit 1dc106e

Browse files
authored
Merge pull request #1213 from NASA-IMPACT/dev
Merge Dev Into Staging
2 parents ed30d45 + 111cdfa commit 1dc106e

File tree

170 files changed

+18239
-1212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+18239
-1212
lines changed

.dockerignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@
77
.pre-commit-config.yaml
88
.readthedocs.yml
99
.travis.yml
10-
venv
1110
.git
11+
12+
# ignore local python environments
13+
venv
14+
.venv
15+
16+
# prevent large backup files from being copied into the image
17+
/backups
18+
*.sql
19+
*.gz

.envs/.local/.django

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ SINEQUA_CONFIGS_REPO_WEBAPP_PR_BRANCH='dummy_branch'
3333
# Slack Webhook
3434
# ------------------------------------------------------------------------------
3535
SLACK_WEBHOOK_URL=''
36-
LRM_USER=''
37-
LRM_PASSWORD=''
36+
37+
#Server Credentials
38+
#--------------------------------------------------------------------------------
39+
LRM_DEV_USER=''
40+
LRM_DEV_PASSWORD=''
3841
XLI_USER=''
3942
XLI_PASSWORD=''
43+
LRM_QA_USER=''
44+
LRM_QA_PASSWORD=''
45+
46+
#Server Tokens
47+
#--------------------------------------------------------------------------------
48+
LRM_DEV_TOKEN=''
49+
XLI_TOKEN=''
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Django Test Suite on PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- dev
7+
paths-ignore:
8+
- '**/*.md'
9+
10+
jobs:
11+
run-tests:
12+
runs-on: ubuntu-latest
13+
14+
services:
15+
docker:
16+
image: docker:24.0.5
17+
options: --privileged
18+
ports:
19+
- 5432:5432
20+
21+
steps:
22+
- name: Check out merged code
23+
uses: actions/checkout@v2
24+
25+
- name: Set up Docker Compose
26+
run: |
27+
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
28+
sudo chmod +x /usr/local/bin/docker-compose
29+
30+
- name: Build the Docker environment
31+
run: docker-compose -f local.yml build
32+
33+
- name: Run test suite
34+
env:
35+
DJANGO_ENV: test
36+
run: docker-compose -f local.yml run --rm django bash ./init.sh
37+
38+
- name: Generate Coverage Report
39+
env:
40+
DJANGO_ENV: test
41+
run: docker-compose -f local.yml run --rm django bash -c "coverage report"
42+
43+
- name: Cleanup
44+
run: docker-compose -f local.yml down --volumes

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ config_generation/config.py
292292
# Model's inference files
293293
Document_Classifier_inference/model.pt
294294

295-
# Database backup
296-
backup.json
297-
298-
# Prod backup
299-
prod_backup-20240423.json
295+
# Ignore Database Backup files
296+
/backups
297+
*.sql
298+
*.gz

.pre-commit-config.yaml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,77 @@ default_stages: [commit]
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.4.0
6+
rev: v4.6.0
77
hooks:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
1010
- id: check-yaml
11+
- id: check-merge-conflict
12+
- id: debug-statements
1113

1214
- repo: https://github.com/asottile/pyupgrade
13-
rev: v3.3.1
15+
rev: v3.17.0
1416
hooks:
1517
- id: pyupgrade
1618
args: [--py310-plus]
1719

1820
- repo: https://github.com/psf/black
19-
rev: 23.1.0
21+
rev: 24.8.0
2022
hooks:
2123
- id: black
2224

2325
- repo: https://github.com/PyCQA/isort
24-
rev: 5.12.0
26+
rev: 5.13.2
2527
hooks:
2628
- id: isort
2729

2830
- repo: https://github.com/PyCQA/flake8
29-
rev: 6.0.0
31+
rev: 7.1.1
3032
hooks:
3133
- id: flake8
3234
args: ["--config=setup.cfg"]
3335
additional_dependencies: [flake8-isort]
3436

3537
- repo: https://github.com/pre-commit/mirrors-mypy
36-
rev: v1.4.0
38+
rev: v1.11.2
3739
hooks:
3840
- id: mypy
3941
args: ["--strict"]
40-
# ignoring everything for now
41-
exclude: .
42-
additional_dependencies: [django-stubs, celery, django-environ, django-extensions, django-crispy-forms,
43-
crispy-bootstrap5, django-allauth, django-celery-beat, djangorestframework, djangorestframework-datatables,
44-
django-debug-toolbar, psycopg2-binary, python-slugify, xmltodict, PyGithub, boto3, scrapy, types-requests]
42+
exclude: "."
43+
additional_dependencies:
44+
- django-stubs
45+
- celery
46+
- django-environ
47+
- django-extensions
48+
- django-crispy-forms
49+
- crispy-bootstrap5
50+
- django-allauth
51+
- django-celery-beat
52+
- djangorestframework
53+
- djangorestframework-datatables
54+
- django-debug-toolbar
55+
- psycopg2-binary
56+
- python-slugify
57+
- xmltodict
58+
- PyGithub
59+
- boto3
60+
- scrapy
61+
- types-requests
62+
63+
- repo: https://github.com/PyCQA/bandit
64+
rev: '1.7.0'
65+
hooks:
66+
- id: bandit
67+
args: ['-r', '--configfile=bandit-config.yml']
68+
69+
- repo: https://github.com/zricethezav/gitleaks
70+
rev: 'v8.0.4'
71+
hooks:
72+
- id: gitleaks
73+
args: ['--config=gitleaks-config.toml']
74+
4575

4676

47-
# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
4877
ci:
4978
autoupdate_schedule: weekly
5079
skip: []

CHANGELOG.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## Overview
2+
These are not the release notes, which can be found https://github.com/NASA-IMPACT/COSMOS/releases. Instead, this is a changelog that developers use to log key changes to the codebase with each pull request.
3+
4+
## What to Include
5+
For each PR made, an entry should be added to this changelog. It should contain
6+
- a brief description of the deliverable of the feature or bugfix
7+
- exact listing of key changes such as:
8+
- API endpoint modified
9+
- frontend components added
10+
- model updates
11+
- deployment changes needed on the servers
12+
- etc.
13+
14+
## Changelog
15+
- 2889-serialize-the-tdamm-tags
16+
- Description: Have TDAMM serialzed in a specific way and exposed via the Curated URLs API to be consumed into SDE Test/Prod
17+
- Changes:
18+
- Changed `get_tdamm_tag` method in the `CuratedURLAPISerializer` to process the TDAMM tags and pass them to the API endpoint
19+
20+
- 960-notifications-add-a-dropdown-with-options-on-the-feedback-form
21+
- Description: Generate an API endpoint and publish all the dropdown options necessary as a list for LRM to consume it.
22+
- Changes:
23+
- Created a new model `FeedbackFormDropdown`
24+
- Added the migration file
25+
- Added the `dropdown_option` field to the `Feedback` model
26+
- Updated the slack notification structure by adding the dropdown option text
27+
- Created a new serializer called `FeedbackFormDropdownSerializer`
28+
- Added a new API endpoint `feedback-form-dropdown-options-api/` where the list is going to be accesible
29+
- Added a list view called `FeedbackFormDropdownListView`
30+
- Added tests
31+
32+
- 1217-add-data-validation-to-the-feedback-form-api-to-restrict-html-content
33+
- Description: The feedback form API does not currently have any form of data validation on the backend which makes it easy for the user with the endpoint to send in data with html tags. We need to have a validation scheme on the backend to protect this from happening.
34+
- Changes:
35+
- Defined a class `HTMLFreeCharField` which inherits `serializers.CharField`
36+
- Used regex to catch any HTML content comming in as an input to form fields
37+
- Called this class within the serializer for necessary fields
38+
39+
- 3227-bugfix-title-patterns-selecting-multi-url-pattern-does-nothing
40+
- Description: When selecting options from the match pattern type filter, the system does not filter the results as expected. Instead of displaying only the chosen variety of patterns, it continues to show all patterns.
41+
- Changes:
42+
- In `title_patterns_table` definition, corrected the column reference
43+
- Made `match_pattern_type` searchable
44+
- Corrected the column references and made code consistent on all the other tables, i.e., `exclude_patterns_table`, `include_patterns_table`, `division_patterns_table` and `document_type_patterns_table`
45+
46+
- 1001-tests-for-critical-functionalities
47+
- Description: Critical functionalities have been identified and listed, and critical areas lacking tests listed
48+
- Changes:
49+
- Integrated coverage.py as an indicative tool in the workflow for automated coverage reports on PRs, with separate display from test results.
50+
- Introduced docs/architecture-decisions/testing_strategy.md, which includes the coverage report, lists critical areas, and specifically identifies those critical areas that are untested or under-tested.
51+
52+
- 1192-finalize-the-infrastructure-for-frontend-testing
53+
- Description: Set up comprehensive frontend testing infrastructure using Selenium WebDriver with Chrome, establishing a foundation for automated UI testing.
54+
- Changes:
55+
- Added Selenium testing dependency to `requirements/local.txt`
56+
- Updated Dockerfile to support Chrome and ChromeDriver
57+
- Created BaseTestCase and AuthenticationMixin for reusable test components
58+
- Implemented core authentication test suite
59+
60+
- 1195-implement-unit-test-for-forms-on-the-frontend
61+
- Description: Implemented comprehensive frontend test suite covering authentication, collection management, search functionality, and pattern application forms.
62+
- Changes:
63+
- Added tests for authentication flows
64+
- Implemented collection display and data table tests
65+
- Added universal search functionality tests
66+
- Created search pane filter tests
67+
- Added pattern application form tests with validation checks

CODE_STANDARDS.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Coding Standards and Conventions for COSMOS
2+
3+
## Overview
4+
To maintain high-quality code and ensure consistency across the entire COSMOS project, we have established coding standards and conventions. This document outlines the key standards and practices that all contributors are expected to follow. Adhering to these guidelines helps us to achieve a codebase that appears as if it were written by a single entity, regardless of the number of contributors.
5+
6+
## Coding Standards
7+
8+
### Formatting Standards
9+
- **Line Length**: Maximum of 120 characters per line to ensure readability across various environments.
10+
- **Code Formatting**: Utilize tools like Black for Python code to ensure consistent formatting across the entire codebase.
11+
- **Import Ordering**: Follow a consistent import order:
12+
- Standard library imports.
13+
- Third-party imports.
14+
- Application-specific imports.
15+
16+
### Naming Conventions
17+
- **Variables and Functions**: Use `snake_case`.
18+
- **Classes and Exceptions**: Use `CamelCase`.
19+
- **Constants**: Use `UPPER_CASE`.
20+
21+
### Commenting
22+
- Inline comments should be used sparingly and only when necessary to explain "why" something is done, not "what" is done.
23+
- All public methods, classes, and modules should include docstrings that follow the [Google style guide](https://google.github.io/styleguide/pyguide.html).
24+
25+
### Error Handling
26+
- Explicit is better than implicit. Raise exceptions rather than returning None or any error codes.
27+
- Use custom exceptions over generic exceptions when possible to make error handling more predictive.
28+
29+
## Tool Configurations and Pre-commit Hooks
30+
31+
To automate and enforce these standards, the following tools are configured with pre-commit hooks in our development process:
32+
33+
### Pre-commit Hooks Setup
34+
35+
To ensure that these tools are run automatically on every commit, contributors must set up pre-commit hooks locally. Run the following commands to install and configure pre-commit hooks:
36+
37+
```bash
38+
pip install pre-commit
39+
pre-commit install
40+
pre-commit run --all-files
41+
```
42+
43+
The following pre-commit hooks are configured:
44+
45+
- trailing-whitespace, end-of-file-fixer, check-yaml, check-merge-conflict, debug-statements: Checks for common formatting issues.
46+
- pyupgrade: Automatically upgrades syntax for newer versions of the language.
47+
- black: Formats Python code to ensure consistent styling.
48+
- isort: Sorts imports alphabetically and automatically separated into sections.
49+
- flake8: Lints code to catch styling errors and potential bugs.
50+
- mypy: Checks type annotations to catch potential bugs.
51+
- bandit: Scans code for common security issues.
52+
- gitleaks: Prevents secrets from being committed to the repository.
53+
- hadolint: Lints Dockerfiles to ensure best practices and common conventions are followed.
54+
55+
## Continuous Integration (CI)
56+
When a commit is pushed to a branch that is part of a Pull Request, our Continuous Integration (CI) pipeline automatically runs specified tools to check code quality, style, security and other standards. If these checks fail, the PR cannot be merged until all issues are resolved.
57+
58+
## Quality Standards Enforcement
59+
- PRs must pass all checks from the configured pre-commit hooks and CI pipeline to be eligible for merging.
60+
- Code reviews additionally focus on logical errors and code quality beyond what automated tools can detect.
61+
62+
## Conclusion
63+
By adhering to these standards and utilizing the tools set up, we maintain the high quality and consistency of our codebase, making it easier for developers to collaborate effectively.

CONTRIBUTING.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Thank you for your interest in contributing to COSMOS! We welcome contributions and appreciate your help in making this project better. Please follow the guidelines below to ensure a smooth contribution process.
2+
3+
## Pull Requests
4+
5+
### Prerequisites
6+
7+
- **GitHub CLI (`gh`)**: Make sure you have the GitHub CLI installed. If not, you can install it from [GitHub CLI installation page](https://cli.github.com/).
8+
9+
### 1. **Create an Issue on the Repo**
10+
11+
1. **Navigate to Your Repository**:
12+
13+
```bash
14+
$ cd path/to/your/repository
15+
```
16+
17+
2. **Create an Issue**:
18+
Use the `gh issue create` command to create a new issue.
19+
20+
```bash
21+
$ gh issue create --title "Issue Title" --body "Description of the issue"
22+
```
23+
24+
After running this command, you’ll get an issue number in the output. Note this number as it will be used to create a branch.
25+
26+
27+
### 2. **Create a Branch for the Issue**
28+
29+
1. **Create a Branch**:
30+
Use the `gh` CLI to create a branch associated with the issue. The `gh` CLI can automatically create a branch for you based on the issue number. In this case, the `<issue_number>` is 989.
31+
32+
```bash
33+
$ gh issue develop -c 989
34+
github.com/NASA-IMPACT/COSMOS/tree/989-make-coding-syntax-consistent
35+
From https://github.com/NASA-IMPACT/COSMOS
36+
* [new branch] 989-make-coding-syntax-consistent -> origin/989-make-coding-syntax-consistent
37+
38+
```
39+
40+
This command creates a new branch named `<issue_number>-issue` and switches to it. This branch will be used to work on the issue.
41+
42+
2. **Make Your Changes and Push:**
43+
Edit files, add code, or make any changes needed to address the issue. Commit your changes and push the branch to the remote repository.
44+
45+
```bash
46+
git add .
47+
git commit -m "Fixes issue #<issue_number>"
48+
git push origin <issue_number>-issue
49+
```
50+
51+
52+
### 3. **Create a Pull Request**
53+
54+
1. **Create the Pull Request**:
55+
After pushing the branch, create a pull request using the `gh pr create` command:
56+
57+
```bash
58+
gh pr create --base dev --head <issue_number>-issue --title "Title of the Pull Request" --body "Description of the changes"
59+
```
60+
61+
- **`-base`**: The base branch you want to merge your changes into (`dev` in our case)
62+
- **`-head`**: The branch that contains your changes (e.g., `<issue_number>-issue`).
63+
- **`-title`**: The title of the pull request.
64+
- **`-body`**: The description or body of the pull request.
65+
66+
This command will create a pull request from your branch into the base branch specified.
67+
68+
2. **Review and Merge**:
69+
Once the pull request is created, we will review it on GitHub and merge it if everything looks good. If any changes are required, we might ask you to make adjustments before the merge.

0 commit comments

Comments
 (0)