-
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 #19 from Xiao75896453/feat/repo/github_action
feat (repo/GitHub_Action): Add lint and test
- Loading branch information
Showing
5 changed files
with
217 additions
and
2 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,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 |
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,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 }} |
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,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 |
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