Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
[CI] Added common action for installing dependencies + canopy
Browse files Browse the repository at this point in the history
This saves a lot of code duplication
  • Loading branch information
igiloh-pinecone committed Oct 29, 2023
1 parent 5221af4 commit db5078d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 100 deletions.
41 changes: 41 additions & 0 deletions .github/actions/install-deps-and-canopy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Install dependencies and canopy
inputs:
python-version:
description: "Python version"
required: true
default: "3.9"
install-canopy:
description: "Whether to install canopy library, or dependencies only"
required: true
default: "true"

runs:
using: "composite"
steps:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: |
.venv
poetry.lock
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('pyproject.toml') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
- name: Install project
if: {{ inputs.install-canopy }} == "true"
run: poetry install --no-interaction
57 changes: 7 additions & 50 deletions .github/workflows/PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: |
.venv
poetry.lock
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
uses: .github/actions/install-deps-and-canopy
with:
python-version: ${{ matrix.python-version }}
install-canopy: false
- name: Run flake8 Check
run: poetry run flake8 .
- name: Run mypy check
Expand All @@ -68,33 +48,10 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: |
.venv
poetry.lock
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
- name: Install project
run: poetry install --no-interaction
uses: .github/actions/install-deps-and-canopy
with:
python-version: ${{ matrix.python-version }}
- name: Run unit tests
run: poetry run pytest --html=report.html --self-contained-html tests/unit
- name: upload pytest report.html
Expand Down
57 changes: 7 additions & 50 deletions .github/workflows/merege_queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: |
.venv
poetry.lock
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
uses: .github/actions/install-deps-and-canopy
with:
python-version: ${{ matrix.python-version }}
install-canopy: false
- name: Run flake8 Check
run: poetry run flake8 .
- name: Run mypy check
Expand All @@ -61,33 +41,10 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
- name: Install dependencies and canopy
uses: .github/actions/install-deps-and-canopy
with:
path: |
.venv
poetry.lock
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
- name: Install project
run: poetry install --no-interaction
python-version: ${{ matrix.python-version }}
- name: Run unit tests
run: poetry run pytest --html=report.html --self-contained-html tests/unit
- name: Set Index Name for System / E2E
Expand Down

0 comments on commit db5078d

Please sign in to comment.