-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from pymasterspl/feature/gh-actions
attempt ghactions
- Loading branch information
Showing
12 changed files
with
285 additions
and
18 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,22 @@ | ||
name: Run linting | ||
|
||
on: | ||
pull_request: | ||
types: [opened, ready_for_review, synchronize, reopened] | ||
|
||
jobs: | ||
pep8: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
python-version: ["3.11"] | ||
if: github.event.pull_request.draft == false | ||
steps: | ||
- name: Cancel Previous Runs | ||
if: "!endsWith(github.ref, '/master') && !endsWith(github.ref, '/dev')" | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/[email protected] | ||
- uses: actions/checkout@v4 | ||
- uses: chartboost/ruff-action@v1 |
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,78 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
types: [opened, ready_for_review, synchronize, reopened] | ||
|
||
jobs: | ||
pytests: | ||
runs-on: ubuntu-22.04 | ||
if: github.event.pull_request.draft == false | ||
steps: | ||
- name: Cancel Previous Runs | ||
if: "!endsWith(github.ref, '/master') && !endsWith(github.ref, '/dev')" | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/[email protected] | ||
|
||
- name: Set up Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.11" | ||
architecture: "x64" | ||
|
||
- name: Cache Poetry | ||
id: cache-poetry | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.poetry | ||
key: ${{ matrix.os }}-poetry | ||
|
||
# Only runs when key from caching step changes | ||
- name: Install Poetry | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
# Poetry still needs to be re-prepended to the PATH on each run, since | ||
# PATH does not persist between runs. | ||
- name: Add Poetry to $PATH | ||
run: | | ||
echo "$HOME/.poetry/bin" >> $GITHUB_PATH | ||
- name: Get Poetry version | ||
run: poetry --version | ||
|
||
- name: Check pyproject.toml validity | ||
run: | | ||
poetry check --no-interaction | ||
- name: Cache dependencies | ||
id: cache-deps | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{github.workspace}}/.venv | ||
key: ${{ matrix.os }}-${{ hashFiles('**/poetry.lock') }} | ||
restore-keys: ${{ matrix.os }}- | ||
|
||
- name: Install deps | ||
if: steps.cache-deps.cache-hit != 'true' | ||
run: | | ||
poetry config virtualenvs.in-project true | ||
poetry install --no-interaction | ||
- name: Create .env file | ||
run: | | ||
echo "SECRET_KEY=default_secret_key" > .env | ||
echo "DEBUG=False" >> .env | ||
echo "ALLOWED_HOSTS=[]" >> .env | ||
- name: Check Migrations | ||
run: | | ||
poetry run python manage.py makemigrations --check --dry-run | ||
- name: Run pytest | ||
run: | | ||
poetry run pytest -vv |
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,9 +1,101 @@ | ||
Reddit clone for educational purposes. | ||
|
||
## Roadmap | ||
- Users management | ||
- registration | ||
- login via email | ||
- password recovery | ||
- discuss next steps and design models | ||
Reddit clone for educational purposes. Developed by PyMasters | ||
|
||
## Rules of engagement | ||
Good reading on working with code changes and pull request is https://google.github.io/eng-practices/. It contains both views - change author and reviewer. | ||
|
||
### Rules | ||
|
||
1. Do not commit directly to `master` or `dev`. Both branches are protected. | ||
2. Check your code with `ruff check` prior to creating pull requests. The code is checked against PEP8 using `ruff`. Violations will not allow merging. | ||
- fix can be applied by ruff automatically for some issues, check `ruff check --fix`. | ||
3. Use pull request to add your work. Make pull request to `dev` branch. | ||
- After creating pull request use "reviewers" option on far right of the screen to request review from "pymasters/reddit" team, or you can request review from certain team member directly by mentioning their name. | ||
![alt text](readme-image.png) | ||
- One of the team members (or multiple) will perform code review and approve the pull request or request changes. | ||
- If changes are requested, all comments have to be in constructive and friendly manner, as shown in https://google.github.io/eng-practices/review/reviewer/comments.html | ||
- It's a good thing to comment on the good parts of code with "Nice work" or something similar. | ||
4. As this is a learning project, pair programming is most welcome. Jump on Zoom or google meet and work together: https://www.youtube.com/watch?v=wu6BOT-eMgc&t=105s&ab_channel=devmentor.pl | ||
5. Code quality and automated tests will be run and required to pass before pull request can be merged. | ||
6. At least one approval by other team member is required before pull request can be merged. | ||
7. After pull request is approved and code quality + tests are passed, pull request is merged by the author. | ||
8. It is author responsibility to watch over pull request, bump if there is no code review done, fix issues and merge pull request. | ||
|
||
#### How to Set up | ||
|
||
Clone repository to specific folder (ex. reddit): | ||
``` | ||
git clone https://github.com/pymasterspl/reddit.git | ||
``` | ||
You need to have installed Poetry package. If you don't have, please install using this command: | ||
``` | ||
pip install poetry | ||
``` | ||
Navigate to reddit folder by command: | ||
``` | ||
cd reddit | ||
``` | ||
Set poetry global option, to use project folder as place to hold Virtual environment (recommended): | ||
``` | ||
poetry config virtualenvs.in-project true | ||
``` | ||
Install virtual environment, using current dependencies: | ||
``` | ||
poetry install | ||
``` | ||
Copy file env-template to .env file using command: | ||
``` | ||
# linux/mac | ||
cp env-template .env | ||
# windows | ||
copy env-template .env | ||
``` | ||
Start poetry virtual environment | ||
``` | ||
poetry shell | ||
``` | ||
|
||
Update local .env file as needed | ||
|
||
Create admin account to access admin site: | ||
|
||
``` | ||
# linux/mac | ||
# to apply db changes | ||
./manage.py migrate | ||
./manage.py createsuperuser | ||
# windows | ||
# to apply db changes | ||
python manage.py migrate | ||
python manage.py createsuperuser | ||
``` | ||
|
||
|
||
Run project: | ||
``` | ||
# linux/mac | ||
# to apply db changes | ||
./manage.py migrate | ||
# to start project | ||
./manage.py runserver | ||
# windows | ||
# to apply db changes | ||
python manage.py migrate | ||
# to start project | ||
python manage.py runserver | ||
``` | ||
|
||
Load data from fixtures: | ||
``` | ||
python manage.py loaddata {fixture_name}.json | ||
``` | ||
|
||
Open web browser and navigate to localhost address: http://127.0.0.1:8000/ | ||
|
||
### In case of problems with starting the project: | ||
1. Check the env-template file and update the local .env file if necessary | ||
2. Run `poetry install` | ||
|
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,16 @@ | ||
# Enviroment .env file template,, | ||
# In django project install: pip install python-decouple | ||
# ## Decouple import in settings.py from decouple import config | ||
|
||
# Your Django app secret key without '' or " ", in Django settings.py should be as follow: | ||
# SECRET_KEY = config('SECRET_KEY') | ||
SECRET_KEY=secret-key | ||
|
||
# Debug state, in Django settings.py should be as follow: | ||
# DEBUG = config('DEBUG') | ||
DEBUG=True | ||
|
||
# Allowed Hosts in Django settings.py should be as follow: | ||
# ALLOWED_HOSTS = json.loads(config('ALLOWED_HOSTS')) | ||
ALLOWED_HOSTS='["127.0.0.1", "192.168.99.100", "localhost"]' | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Empty file.
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,3 @@ | ||
def test_blank() -> None: | ||
assert True, "just for verification of the config. Remove later on." | ||
|
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Roadmap | ||
- Users management | ||
- registration | ||
- login via email - follow: https://akademiait.com.pl/zrozumiec-django-uzytkownicy-jak-stworzyc-wlasny-model-uzytkownika-z-logowaniem-po-adresie-email/ | ||
- password recovery | ||
- discuss next steps and design models |