diff --git a/.github/workflows/pytest_account_password_management.yml b/.github/workflows/pytest_account_password_management.yml new file mode 100644 index 0000000..1ac0f47 --- /dev/null +++ b/.github/workflows/pytest_account_password_management.yml @@ -0,0 +1,66 @@ +name: pytest_account_password_management + +on: push + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11.2"] + redis-version: [6] + env: + STAGE: 'stg' + SERVICE_PORT: 1 + DB_HOST: "localhost" + DB_PORT: 5432 + DB_USER: "postgres" + DB_PASSWORD: "password" + DB_DATABASE: "db_test" + DB_POOL_SIZE: 10 + DB_MAX_OVERFLOW: 5 + DB_POOL_RECYCLE: 300 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up PostgreSQL with Postgis 12 + # You may pin to the exact commit or the version. + # uses: ireznik/postgis-action@407eaeebecb5f1907ad19d1c63e2f9e1a441ec72 + uses: ireznik/postgis-action@v12 + with: + # Version of PostgreSQL to use + postgresql version: '15-3.3' + # POSTGRES_DB - name for the default database that is created + postgresql db: $DB_DATABASE + # POSTGRES_USER - create the specified user with superuser power + postgresql user: $DB_USER + # POSTGRES_PASSWORD - superuser password + postgresql password: $DB_PASSWORD + - name: Set PostgreSQL config + run: | + sudo apt-get update + sudo apt-get install --yes --no-install-recommends postgresql-client + sudo -i -u postgres + sudo PGPASSWORD=$DB_PASSWORD -u $DB_USER psql -h $DB_HOST --no-password -c "ALTER DATABASE $DB_DATABASE SET TIMEZONE TO 'ETC/UTC-8';" + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Install dependencies + run: | + poetry install + - name: Set up DB Schema + run: | + source .venv/bin/activate + alembic -c 'projects/account_password_management/alembic.ini' upgrade head + - name: Test with pytest + run: | + source .venv/bin/activate + pytest $PROJECT_PATH diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..529c367 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,37 @@ +name: ruff + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11.2"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + - name: Install dependencies + run: | + poetry add ruff + - name: Changed Files + id: changed-files + uses: tj-actions/changed-files@v40 + with: + files_yaml: | + py: + - '**.py' + - name: Linting the code with ruff + if: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + source .venv/bin/activate + ruff check ${{ steps.changed-files.outputs.all_changed_files }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..bc208cb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: check-added-large-files + - id: check-ast + - id: check-case-conflict + - id: check-json + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + exclude: migrations/ + - repo: local + hooks: + - id: ruff + name: ruff + entry: ruff + args: ['check .'] + language: system + types: [python] + - repo: local + hooks: + - id: pytest_account_password_management + name: pytest_account_password_management + entry: pytest + args: ['projects/account_password_management'] + language: system + stages: [push] + pass_filenames: false + always_run: true diff --git a/poetry.lock b/poetry.lock index 4effebc..94e591f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -90,6 +90,17 @@ files = [ tests = ["pytest (>=3.2.1,!=3.3.0)"] typecheck = ["mypy"] +[[package]] +name = "certifi" +version = "2024.7.4" +description = "Python package for providing Mozilla's CA Bundle." +optional = false +python-versions = ">=3.6" +files = [ + {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, + {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, +] + [[package]] name = "cfgv" version = "3.4.0" @@ -255,6 +266,51 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] +[[package]] +name = "httpcore" +version = "1.0.5" +description = "A minimal low-level HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5"}, + {file = "httpcore-1.0.5.tar.gz", hash = "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61"}, +] + +[package.dependencies] +certifi = "*" +h11 = ">=0.13,<0.15" + +[package.extras] +asyncio = ["anyio (>=4.0,<5.0)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] +trio = ["trio (>=0.22.0,<0.26.0)"] + +[[package]] +name = "httpx" +version = "0.27.0" +description = "The next generation HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"}, + {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"}, +] + +[package.dependencies] +anyio = "*" +certifi = "*" +httpcore = "==1.*" +idna = "*" +sniffio = "*" + +[package.extras] +brotli = ["brotli", "brotlicffi"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] + [[package]] name = "identify" version = "2.6.0" @@ -669,6 +725,24 @@ pluggy = ">=1.5,<2" [package.extras] dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "pytest-asyncio" +version = "0.23.8" +description = "Pytest support for asyncio" +optional = false +python-versions = ">=3.8" +files = [ + {file = "pytest_asyncio-0.23.8-py3-none-any.whl", hash = "sha256:50265d892689a5faefb84df80819d1ecef566eb3549cf915dfb33569359d1ce2"}, + {file = "pytest_asyncio-0.23.8.tar.gz", hash = "sha256:759b10b33a6dc61cce40a8bd5205e302978bbbcc00e279a8b61d9a6a3c82e4d3"}, +] + +[package.dependencies] +pytest = ">=7.0.0,<9" + +[package.extras] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] + [[package]] name = "python-dotenv" version = "1.0.1" @@ -937,4 +1011,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "2528feb00c37df4e7f9e92d951981a25773e95d04b2c8cfb21f637af7d128230" +content-hash = "4611e3ec78412d7c49627704a9f2ee728f58e2a97d773f51310ca8459e07be2a" diff --git a/pyproject.toml b/pyproject.toml index 3f0dbb5..3b1dc8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,8 @@ ruff = "^0.5.6" isort = "^5.13.2" pytest = "^8.3.2" pre-commit = "^3.8.0" +httpx = "^0.27.0" +pytest-asyncio = "^0.23.8" [build-system] requires = ["poetry-core"] @@ -28,4 +30,4 @@ build-backend = "poetry.core.masonry.api" [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] -"env.py" = ["F401"] \ No newline at end of file +"env.py" = ["F401"]