Merge pull request #19 from Xiao75896453/feat/repo/github_action #3
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
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 |