-
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.
This reverts commit 3ff7b7c.
- Loading branch information
Showing
37 changed files
with
1,939 additions
and
628 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
name: Page Analyzer CI | ||
name: Python-check | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
branches: [ dev, main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
|
@@ -11,17 +11,46 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.10" ] | ||
# we want to test our package on several versions of Python | ||
python-version: [3.11] | ||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_USER: test_user | ||
POSTGRES_PASSWORD: test_pass | ||
POSTGRES_DB: test_db | ||
ports: | ||
- 5433:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 3 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
# make depends on poetry | ||
- name: Install dependencies | ||
run: | | ||
pip install poetry | ||
make setup | ||
- name: Run linter | ||
make install | ||
- name: Run linter and pytest | ||
env: | ||
TEST_DATABASE_URL: postgresql:https://test_user:test_pass@localhost:5433/test_db | ||
SECRET_KEY: supersecret | ||
run: | | ||
make lint | ||
make check | ||
- name: Test & publish code coverage | ||
uses: paambaati/[email protected] | ||
if: github.ref_name == 'main' | ||
env: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | ||
TEST_DATABASE_URL: postgresql:https://test_user:test_pass@localhost:5433/test_db | ||
SECRET_KEY: supersecret | ||
with: | ||
coverageCommand: make test-coverage | ||
debug: true |
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,24 +1,37 @@ | ||
setup: install lock | ||
|
||
PORT ?= 8000 | ||
|
||
install: | ||
poetry install | ||
|
||
lock: | ||
poetry lock | ||
test: | ||
poetry run pytest | ||
|
||
lint: | ||
poetry run flake8 page_analyzer | ||
|
||
check: | ||
test-coverage: | ||
poetry run pytest --cov=page_analyzer --cov-report xml | ||
|
||
self_check: | ||
poetry check | ||
|
||
test: | ||
poetry run pytest tests | ||
check: self_check test lint | ||
|
||
build: check | ||
poetry build | ||
|
||
dev: | ||
poetry run flask --app page_analyzer:app run | ||
poetry run flask --app page_analyzer:app --debug run | ||
|
||
PORT ?= 8000 | ||
start: | ||
poetry run gunicorn -w 3 -b 0.0.0.0:$(PORT) page_analyzer:app | ||
poetry run gunicorn -w 5 -b 0.0.0.0:$(PORT) page_analyzer:app | ||
|
||
start-testdb: | ||
docker-compose -f docker-compose.test.yml up -d | ||
|
||
stop-testdb: | ||
docker-compose -f docker-compose.test.yml down | ||
|
||
init_db: | ||
poetry run flask --app page_analyzer:app init-db | ||
|
||
.PHONY: install test lint selfcheck check build dev start start-testdb stop-testdb init_db |
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,53 +1,6 @@ | ||
### Hexlet tests, linter status and CI : | ||
[![Actions Status](https://github.com/GregTMJ/python-project-83/workflows/hexlet-check/badge.svg)](https://github.com/GregTMJ/python-project-83/actions) | ||
[![Page Analyzer CI](https://github.com/GregTMJ/python-project-83/actions/workflows/page_analyzer.yml/badge.svg?branch=main)](https://github.com/Gregtmj/python-project-83/actions/workflows/page_analyzer.yml) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/76d09bb269a5e483ef27/maintainability)](https://codeclimate.com/github/GregTMJ/python-project-83/maintainability) | ||
### Hexlet tests and linter status: | ||
[![Actions Status](https://github.com/KAnanev/python-project-83/workflows/hexlet-check/badge.svg)](https://github.com/KAnanev/python-project-83/actions) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/da7e58734b9be8cb3a0a/maintainability)](https://codeclimate.com/github/KAnanev/Page-analyzer/maintainability) | ||
[![Test Coverage](https://api.codeclimate.com/v1/badges/da7e58734b9be8cb3a0a/test_coverage)](https://codeclimate.com/github/KAnanev/Page-analyzer/test_coverage) | ||
|
||
|
||
## Getting Started | ||
|
||
#### Clone the current repository via command: | ||
```git clone https://github.com/GregTMJ/python-project-83.git``` | ||
|
||
*** | ||
|
||
## Requirements | ||
* python >= 3.8 | ||
* Poetry >= 1.14 | ||
*** | ||
|
||
## Required packages | ||
* Flask ^2.2.2 | ||
* Python-dotenv ^0.21 | ||
* to avoid psycopg problems with different OS, install psycopg2-binary ^2.9.4 | ||
* Every other packages are shown inside pyproject.toml | ||
|
||
*** | ||
|
||
#### Check your pip version with the following command: | ||
```python -m pip --version``` | ||
|
||
#### Make sure that pip is always up-to-date. If not, use the following: | ||
```python -m pip install --upgrade pip``` | ||
|
||
#### Next install poetry on your OS. (the link is below) | ||
[Poetry installation](https://python-poetry.org/docs/) | ||
##### don't forget to init poetry packages with command ```poetry init``` | ||
|
||
### We will be also working with postgreSQL, so make sure that you have installed it on your OS | ||
|
||
*** | ||
|
||
## Makefile | ||
#### For every project should be configured a Makefile to initiate the project without requiring manual commands | ||
#### Current project starts after typing ```make setup``` | ||
#### Inside our ```make setup``` we have 3 commands hidden: | ||
* ``` make install```, which makes poetry install packages from pyproject.toml | ||
* ```make lock```, which locks poetry packages inside poetry.lock | ||
*** | ||
|
||
#### After configuration, you should use ```make dev``` to start your flask app | ||
#### This app is made to analyze certain URLs | ||
|
||
*** | ||
### Make sure than everything works, if you have something to add, remove or update, keep in touch "[email protected]" | ||
Здесь можно посмотреть: [Page analyzer](http:https://page-analyzer-production-6075.up.railway.app). |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3' | ||
services: | ||
test-server: | ||
image: postgres:latest | ||
ports: | ||
- "5433:5432" | ||
environment: | ||
POSTGRES_USER: test_user | ||
POSTGRES_PASSWORD: test_pass | ||
POSTGRES_DB: test_db |
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,3 +1,29 @@ | ||
from page_analyzer.app import app | ||
import os | ||
|
||
__all__ = ('app',) | ||
from dotenv import load_dotenv | ||
from flask import Flask | ||
|
||
load_dotenv() | ||
|
||
|
||
def create_app(test_config=None): | ||
_app = Flask(__name__) | ||
_app.config.from_mapping( | ||
SECRET_KEY=os.getenv('SECRET_KEY'), | ||
DATABASE_URL=os.getenv('DATABASE_URL') | ||
) | ||
|
||
if test_config: | ||
_app.config.from_mapping(test_config) | ||
|
||
from page_analyzer.db import init_app | ||
init_app(_app) | ||
|
||
from page_analyzer import views | ||
_app.register_blueprint(views.bp) | ||
_app.add_url_rule('/', endpoint='index') | ||
|
||
return _app | ||
|
||
|
||
app = create_app() |
Oops, something went wrong.