Skip to content

Commit

Permalink
Test whether using a consistent and specific Python version fixes ven…
Browse files Browse the repository at this point in the history
…v issues during CICD.
  • Loading branch information
aholmes committed Mar 27, 2024
1 parent 423f832 commit b5f6826
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
outputs:
cache-key-dependencies: ${{ steps.generate-cache-keys.outputs.cache_key }}
cache-key-run: ${{ steps.generate-cache-keys.outputs.cache_key_run }}
python-version: ${{ steps.install-python.outputs.python-version }}

env:
PYTHON_VERSION: "3.10"
Expand All @@ -61,12 +62,13 @@ jobs:
echo "cache_key_dependencies=$cache_key_dependencies" >> $GITHUB_OUTPUT
echo "cache_key_run=$cache_key_run" >> $GITHUB_OUTPUT
- name: Set up Python ${{ env.PYTHON_VERSION }}
- name: Set up Python ${{ steps.generate-cache-keys.outputs.python-version }}
#if: ${{ success() && (inputs.use_dependency_cache == 'false' || !steps.restore-dependency-cache.outputs.cache-hit) }}
uses: actions/setup-python@v5
id: install_python
id: install-python
with:
python-version: ${{ env.PYTHON_VERSION }}
#run: echo "python-version=${{ steps.install-python.outputs.python-version }}" >> "$GITHUB_OUTPUT"

- name: Install dependencies
#if: ${{ success() && (inputs.use_dependency_cache == 'false' || !steps.restore-dependency-cache.outputs.cache-hit) }}
Expand All @@ -93,14 +95,14 @@ jobs:
- Checkout

env:
PYTHON_VERSION: "3.10"
PYTHON_VERSION: ${{ needs.Checkout.outputs.python-version }}

if: ${{( success() && !cancelled() ) }}

steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
id: install_python
id: install-python
with:
python-version: ${{ env.PYTHON_VERSION }}

Expand Down Expand Up @@ -128,14 +130,14 @@ jobs:
- Checkout

env:
PYTHON_VERSION: "3.10"
PYTHON_VERSION: ${{ needs.Checkout.outputs.python-version }}

if: ${{( success() && !cancelled() ) }}

steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
id: install_python
id: install-python
with:
python-version: ${{ env.PYTHON_VERSION }}

Expand Down Expand Up @@ -176,7 +178,7 @@ jobs:
- Checkout

env:
PYTHON_VERSION: "3.10"
PYTHON_VERSION: ${{ needs.Checkout.outputs.python-version }}

if: ${{( success() && !cancelled() ) }}

Expand All @@ -186,7 +188,7 @@ jobs:
steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
id: install_python
id: install-python
with:
python-version: ${{ env.PYTHON_VERSION }}

Expand Down Expand Up @@ -228,14 +230,14 @@ jobs:
- Checkout

env:
PYTHON_VERSION: "3.10"
PYTHON_VERSION: ${{ needs.Checkout.outputs.python-version }}

if: ${{( success() && !cancelled() ) }}

steps:
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
id: install_python
id: install-python
with:
python-version: ${{ env.PYTHON_VERSION }}

Expand Down
21 changes: 1 addition & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ endif


ACTIVATE_VENV := . $(VENV)/bin/activate
PREFIX_VENV := PATH=$(CURDIR)/$(VENV)/bin:$$PATH
REPORT_VENV_USAGE := echo '\nActivate your venv with `. $(VENV)/bin/activate`'

PACKAGE_INSTALL_DIR := $(VENV)/lib/python*/site-packages/BL_Python
Expand Down Expand Up @@ -82,11 +81,9 @@ _dev_build : _dev_configure
else
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
pip install -e .[dev-dependencies]
# By default, psycopg2 is not installed
# but it should be for development
$(PREFIX_VENV) \
pip install -e src/database[postgres-binary]

rm -rf $(PACKAGE_INSTALL_DIR)
Expand All @@ -103,11 +100,9 @@ _cicd_build : _cicd_configure
else
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
pip install .[dev-dependencies]
# By default, psycopg2 is not installed
# but it should be for CI/CD
$(PREFIX_VENV) \
pip install src/database[postgres-binary]
fi

Expand All @@ -120,10 +115,8 @@ $(PACKAGES) : BL_Python.%: src/%/pyproject.toml $(VENV) $(CONFIGURE_TARGET) $(PY
$(ACTIVATE_VENV)

if [ "$@" = "BL_Python.database" ]; then
$(PREFIX_VENV) \
pip install -e $(dir $<)[postgres-binary]
else
$(PREFIX_VENV) \
pip install -e $(dir $<)
fi

Expand All @@ -137,19 +130,17 @@ SETUP_DEPENDENCIES=$(call dep_to_venv_path,toml/__init__.py) $(call dep_to_venv_
$(call dep_to_venv_path,toml/__init__.py): $(VENV)
$(ACTIVATE_VENV)

$(PREFIX_VENV) pip install toml
pip install toml

$(call dep_to_venv_path,typing_extensions.py): $(VENV)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
pip install typing_extensions

$(PACKAGE_PATHS) : $(VENV) $(SETUP_DEPENDENCIES)
$(PYPROJECT_FILES) : $(VENV) $(SETUP_DEPENDENCIES)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
REWRITE_DEPENDENCIES=$(REWRITE_DEPENDENCIES) \
GITHUB_REF=$(GITHUB_REF) \
GITHUB_WORKSPACE=$(GITHUB_WORKSPACE) \
Expand All @@ -164,20 +155,17 @@ $(VENV) :

$(ACTIVATE_VENV)

$(PREFIX_VENV) \
pip install -U pip


format-isort : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
isort src

format-ruff : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
ruff format --preview --respect-gitignore

format : $(VENV) $(BUILD_TARGET) format-isort format-ruff
Expand All @@ -186,20 +174,17 @@ format : $(VENV) $(BUILD_TARGET) format-isort format-ruff
test-isort : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
isort --check-only src

test-ruff : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
ruff format --preview --respect-gitignore --check

test-pyright : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

ifeq "$(PYRIGHT_MODE)" "pip"
$(PREFIX_VENV) \
pyright
else
ifeq "$(PYRIGHT_MODE)" "npm"
Expand All @@ -215,7 +200,6 @@ test-pyright : $(VENV) $(BUILD_TARGET)
test-bandit : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
bandit -c pyproject.toml \
--format sarif \
--output $(BANDIT_REPORT) \
Expand All @@ -228,10 +212,8 @@ test-bandit : $(VENV) $(BUILD_TARGET)
test-pytest : $(VENV) $(BUILD_TARGET)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
pytest $(PYTEST_FLAGS)

$(PREFIX_VENV) \
coverage html -d coverage

test : CMD_PREFIX=@
Expand All @@ -243,7 +225,6 @@ publish-all : REWRITE_DEPENDENCIES=false
publish-all : reset $(VENV)
$(ACTIVATE_VENV)

$(PREFIX_VENV) \
./publish_all.sh $(PYPI_REPO)


Expand Down

0 comments on commit b5f6826

Please sign in to comment.