From 2d394edc42e9eee3f54b92940b456cba1a56187a Mon Sep 17 00:00:00 2001 From: Mahdi Haghverdi Date: Tue, 20 Feb 2024 11:19:34 +0330 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b50787e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,62 @@ +name: testing app +run-name: Test the app +on: + pull_request: + types: [opened, reopened] + push: + branches: + - main + +env: + TEST_DATABASE_URL: postgresql+asyncpg://postgres:postgres@localhost:5432 + API_VERSION: 'v1' + SECRET_KEY: 'd76db401004b334d0d79bc041f6c6f54c5f495ef4dc228f500eab4df532248ac' + ALGORITHM: 'HS256' + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12"] + + services: + postgres: + image: postgres + + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres + + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: all ltree to postgres + run: | + PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d postgres -tc "create extension if not exists ltree;" + + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Install Poetry + run: curl -sSL https://install.python-poetry.org | python3 - + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + + - name: Install dependencies + run: poetry install --no-ansi --no-interaction --with dev + + - name: Test + run: poetry run pytest --cov=src -v