-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
546 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
pyclean() { | ||
# Cleaning cache: | ||
find . | | ||
grep -E '(__pycache__|\.hypothesis|\.perm|\.cache|\.static|\.py[cod]$)' | | ||
xargs rm -rf | ||
} | ||
|
||
run_checks() { | ||
echo '[Check Started]' | ||
set -x # we want to print commands during the CI process. | ||
|
||
# Running linting for all python files in the project: | ||
python -m flake8 | ||
|
||
# Running type checking, see https://github.com/typeddjango/django-stubs | ||
python -m mypy leeteasy tests | ||
|
||
# Running tests: | ||
python -m pytest --cov | ||
|
||
# Checking dependencies status: | ||
python -m pip check | ||
|
||
set +x | ||
echo '[checks completed]' | ||
} | ||
|
||
# Remove any cache before the script: | ||
pyclean | ||
|
||
# Clean everything up: | ||
trap pyclean EXIT INT TERM | ||
|
||
# Run the CI process: | ||
run_checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
types: [ready_for_review] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, macOS-latest] | ||
python-version: [ '3.8', '3.9', '3.10' ] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
id: setup-python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Python version | ||
run: python -c "import sys; print(sys.version)" | ||
|
||
# Install pipenv | ||
- name: Install pipenv | ||
run: python3 -m pip install --upgrade pipenv | ||
|
||
# create .venv folder | ||
- name: create .venv folder | ||
run: mkdir -p .venv | ||
|
||
# caching dependencies | ||
- name: Caching Dependencies | ||
uses: actions/cache@v2 | ||
id: cache-dependencies | ||
with: | ||
path: .venv | ||
key: ${{ matrix.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} | ||
|
||
# install dependencies | ||
- name: Install dependencies | ||
if: steps.cache-dependencies.outputs.cache-hit != 'true' | ||
run: | | ||
pipenv install --dev --verbose | ||
pipenv install types-requests --dev | ||
# Run bash script | ||
- name: run Bash script | ||
run: pipenv run bash ./.github/check.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,55 @@ | ||
Given below is the general workflow we expect you to follow while making contributions to this project. | ||
|
||
|
||
### Workflow | ||
1. Go to the issues tab and find an issue you would like to work on. | ||
|
||
1.1. Clarify any doubts in the comments section of the issue. | ||
|
||
2. Fork the project | ||
|
||
3. Create a branch and make small changes on it. | ||
|
||
4. Create a **draft PR** | ||
|
||
5. Then make other changes and push to the remote branch you created. In this way, the maintainers will be able to provide early reviews and comments for your commits which will save time later on. | ||
|
||
|
||
6. Once the above steps are done, you can change the PR status from **draft to active** | ||
|
||
|
||
7. Once the PR is approved, make sure to update and sync your branch | ||
|
||
8. Wait for the maintainers to merge your contribution | ||
|
||
9. Congratulations! You made your first contribution to Leet Easy | ||
|
||
<br> | ||
|
||
### Fixing a bug, or adding a new feature | ||
|
||
This section generally defines how you can make code contribution. Please follow the below instructions to make code contributions. | ||
|
||
Code, PR, commit message format, etc convension I follow when I code. Please follow the links below to get details. | ||
Please follow the links given below to see the code, PR, commit message, etc. conventions which we follow. | ||
|
||
- [Git branch naming convension](BRANCH-NAMING.md) | ||
- [Git branch naming convention](BRANCH-NAMING.md) | ||
|
||
- [Conventional Commits](https://www.conventionalcommits.org/) for commit messages, and [Commit message format](https://gist.github.com/digitaljhelms/3761873) for what to write | ||
|
||
- [Linking a PR to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) | ||
|
||
<br> | ||
|
||
### Examples | ||
|
||
#### Branch Names: `{branch_type}/{issue-tracker-id-}issue-one-liner` | ||
1. feature/2234-infinite-scroll | ||
2. documentation/3344-linux-installation | ||
3. test/2222-unit-tests | ||
|
||
#### Commits | ||
1. [#1234] feature: Submit button added. | ||
2. [#1232] fix: Infinite scroll fixed | ||
3. [#333] test: Add unit tests for xyz feature | ||
|
||
Keep contributing. We're eager to see your contributions! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ class Constant: | |
|
||
# http call retries | ||
HTTP_CALL_RETRIES = 3 | ||
|
||
# default sleep duration | ||
DEFAULT_SLEEP = 3600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,44 @@ | ||
from typing import List | ||
from typing import Dict, List, Optional | ||
|
||
|
||
class Challenge: | ||
"""Singleton Model class for daily challenge.""" | ||
|
||
title: str = '' | ||
raw_tags: List[dict] = None | ||
raw_tags: List[Dict[str, str]] = [] | ||
ac_rate: float = 0 | ||
difficulty: str = None | ||
question_id: int = None | ||
difficulty: str = '' | ||
question_id: int = 0 | ||
title_slug: str = '' | ||
date: str = None | ||
date: str = '' | ||
|
||
def __new__(cls): | ||
if not hasattr(cls, 'instance'): | ||
cls.instance = super(Challenge, cls).__new__(cls) | ||
"""Override default class creation logic.""" | ||
if not hasattr(cls, 'instance'): # NOQA : WPS421 | ||
cls.instance = super(Challenge, cls).__new__(cls) # NOQA: WPS608 | ||
return cls.instance | ||
|
||
@property | ||
def problem_link(self) -> str: | ||
"""Returns the link of the problem.""" | ||
"""Return the link of the problem.""" | ||
return 'https://leetcode.com/problems/{0}/'.format( | ||
self.title_slug, | ||
) | ||
|
||
@property | ||
def tags(self) -> List[str]: | ||
"""Returns the link of the problem.""" | ||
def tags(self) -> List[Optional[str]]: | ||
"""Return the link of the problem.""" | ||
tags = [] | ||
for tag in self.raw_tags: | ||
tags.append(tag.get('name')) | ||
return tags | ||
|
||
def __str__(self): | ||
"""Returns the string rep of the class.""" | ||
return f"Title: {self.title}\nAcceptance Rate: {self.ac_rate}" \ | ||
f"\nDifficulty: {self.difficulty}\n" + \ | ||
f"id: {self.question_id}\nTags: {self.tags}" | ||
"""Return the string rep of the class.""" | ||
return 'Title: {0}\nAcceptance: {1}\nDifficulty: {2}\nID: {3}\nTags: {4}\n'.format( | ||
self.title, | ||
self.ac_rate, | ||
self.difficulty, | ||
self.question_id, | ||
self.tags, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.