From c5c274c3418798df5aac2d2ac3c0c93c1087e282 Mon Sep 17 00:00:00 2001 From: Dyakov Roman Date: Sun, 21 Jan 2024 22:46:58 +0300 Subject: [PATCH 1/3] Services start --- .github/workflows/checks.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a077497..f2e85f0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,6 +8,28 @@ jobs: test: name: Unit tests runs-on: ubuntu-latest + env: + DB_DSN: postgresql://postgres@postgres:5432/postgres + + services: + postgres: + image: postgres:15 + env: + POSTGRES_HOST_AUTH_METHOD: trust + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + redis: + image: redis + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: Checkout uses: actions/checkout@v4 @@ -21,18 +43,12 @@ jobs: python -m ensurepip python -m pip install --upgrade pip pip install -r requirements.txt -r requirements.dev.txt - - name: Run postgres - run: | - make db - name: Migrate DB run: | make migrate - - name: Run redis - run: | - make redis - name: Build coverage file run: | - DB_DSN=postgresql://postgres@localhost:5432/postgres pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=print_service tests/ | tee pytest-coverage.txt + pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=print_service tests/ | tee pytest-coverage.txt - name: Print report if: always() run: | From 67975e83dee8af43e8bcd820573e3cc0959b0211 Mon Sep 17 00:00:00 2001 From: Dyakov Roman Date: Sun, 21 Jan 2024 22:49:19 +0300 Subject: [PATCH 2/3] No docker --- .github/workflows/checks.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f2e85f0..e6fa46e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -33,26 +33,30 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up docker - uses: docker-practice/actions-setup-docker@master + - uses: actions/setup-python@v4 with: python-version: '3.11' + - name: Install dependencies run: | python -m ensurepip python -m pip install --upgrade pip pip install -r requirements.txt -r requirements.dev.txt + - name: Migrate DB run: | - make migrate + alembic upgrade head + - name: Build coverage file run: | pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=print_service tests/ | tee pytest-coverage.txt + - name: Print report if: always() run: | cat pytest-coverage.txt + - name: Pytest coverage comment uses: MishaKav/pytest-coverage-comment@main with: @@ -67,17 +71,23 @@ jobs: remove-link-from-badge: false junitxml-path: ./pytest.xml junitxml-title: Summary + + linting: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v2 with: python-version: 3.11 + - uses: isort/isort-action@master with: requirementsFiles: "requirements.txt requirements.dev.txt" + - uses: psf/black@stable + - name: Comment if linting failed if: ${{ failure() }} uses: thollander/actions-comment-pull-request@v2 From 9d0d77153006d848d7f90ee21c879381a2182667 Mon Sep 17 00:00:00 2001 From: Dyakov Roman Date: Sun, 21 Jan 2024 22:53:23 +0300 Subject: [PATCH 3/3] Open ports --- .github/workflows/checks.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index e6fa46e..993de41 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -9,11 +9,14 @@ jobs: name: Unit tests runs-on: ubuntu-latest env: - DB_DSN: postgresql://postgres@postgres:5432/postgres + DB_DSN: postgresql://postgres@localhost:5432/postgres + REDIS_DSN: redis://localhost:6379/0 services: postgres: image: postgres:15 + ports: + - 5432:5432 env: POSTGRES_HOST_AUTH_METHOD: trust options: >- @@ -24,6 +27,8 @@ jobs: redis: image: redis + ports: + - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s