From b8efc21e62b6ecb50cf8a0edd93ad0fd99ce051d Mon Sep 17 00:00:00 2001 From: Tomer Nosrati Date: Sun, 14 Jan 2024 03:10:14 +0200 Subject: [PATCH] Removed duplicated code from .github/workflows/python-package.yml --- .github/workflows/linter.yml | 1 + .github/workflows/python-package.yml | 144 +++++---------------------- 2 files changed, 27 insertions(+), 118 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ed8795d6e..58e14c915 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -4,6 +4,7 @@ on: [pull_request] jobs: check: + name: ${{ matrix.check }} check runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1e21ef236..84ce05055 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: pytest-celery on: @@ -21,155 +18,66 @@ on: - "tox.ini" permissions: - contents: read # to fetch code (actions/checkout) + contents: read jobs: - Unit: + Tests: + name: ${{ matrix.test-type }} (Python ${{ matrix.python-version }}) runs-on: ${{ matrix.os }} - strategy: fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: ["ubuntu-latest"] + test-type: ["Unit", "Integration", "Smoke"] steps: - - name: Fetch Docker Images - run: | - docker pull redis:latest - docker pull rabbitmq:latest - docker pull memcached:latest + - name: Checkout branch + uses: actions/checkout@v4 - name: Install apt packages if: startsWith(matrix.os, 'ubuntu-') run: | sudo apt update - sudo apt install -y libmemcached-dev - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox-gh-actions - - - name: Install Poetry - if: startsWith(matrix.os, 'ubuntu-') - uses: snok/install-poetry@v1.3.4 - - - name: Install tox - run: | - poetry install --with ci - - name: Run tox for "${{ matrix.python-version }}-unit" - timeout-minutes: 5 - run: | - tox --verbose --verbose -e "${{ matrix.python-version }}-unit" - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - fail_ci_if_error: true # optional (default = false) - verbose: true # optional (default = false) - - Integration: - needs: - - Unit - if: needs.Unit.result == 'success' - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - os: ["ubuntu-latest"] - - steps: - - name: Fetch Docker Images - run: | - docker pull redis:latest - docker pull rabbitmq:latest - docker pull memcached:latest - - - name: Install apt packages - if: startsWith(matrix.os, 'ubuntu-') - run: | - sudo apt update - sudo apt install -y libmemcached-dev - - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: 'pip' cache-dependency-path: '**/setup.py' + - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install tox-gh-actions - name: Install Poetry - if: startsWith(matrix.os, 'ubuntu-') uses: snok/install-poetry@v1.3.4 - - name: Install tox - run: | - poetry install --with ci + - name: Install CI dependencies with Poetry + run: poetry install --only ci - - name: Run tox for "${{ matrix.python-version }}-integration" - timeout-minutes: 15 + - name: Run Unit Tests + if: matrix.test-type == 'Unit' run: | - tox --verbose --verbose -e "${{ matrix.python-version }}-integration" -- -n auto --reruns 2 --rerun-except AssertionError + tox --verbose --verbose -e py${{ matrix.python-version }}-unit + id: unit-tests - Smoke: - needs: - - Integration - if: needs.Integration.result == 'success' - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - os: ["ubuntu-latest"] - - steps: - - name: Fetch Docker Images + - name: Run Integration Tests + if: matrix.test-type == 'Integration' && needs.unit-tests.result == 'success' run: | - docker pull redis:latest - docker pull rabbitmq:latest - docker pull memcached:latest + tox --verbose --verbose -e py${{ matrix.python-version }}-integration -- -n auto --reruns 2 --rerun-except AssertionError + id: integration-tests - - name: Install apt packages - if: startsWith(matrix.os, 'ubuntu-') + - name: Run Smoke Tests + if: matrix.test-type == 'Smoke' && needs.integration-tests.result == 'success' run: | - sudo apt update - sudo apt install -y libmemcached-dev - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install tox-gh-actions - - - name: Install Poetry - if: startsWith(matrix.os, 'ubuntu-') - uses: snok/install-poetry@v1.3.4 - - - name: Install tox - run: | - poetry install --with ci + tox --verbose --verbose -e py${{ matrix.python-version }}-smoke -- -n auto --reruns 2 --rerun-except AssertionError - - name: Run tox for "${{ matrix.python-version }}-smoke" - timeout-minutes: 15 - run: | - tox --verbose --verbose -e "${{ matrix.python-version }}-smoke" -- -n auto --reruns 2 --rerun-except AssertionError + - name: Upload coverage reports to Codecov + if: matrix.test-type == 'unit' + uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: true + verbose: true