Skip to content

Commit

Permalink
Merge pull request #327 from anaconda-distribution/v0.1.3_attempt2
Browse files Browse the repository at this point in the history
Adds build-matrix to validate on older versions of Python - v0.1.3 patch
  • Loading branch information
schuylermartin45 authored Dec 13, 2023
2 parents 156f898 + 977177a commit e2c12b6
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/actions/setup-env/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
steps:
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
with:
python-version: '3.9'
python-version: ${{ inputs.python-version }}
cache: 'pip'
- name: Cache conda env
id: cache-conda
Expand All @@ -24,9 +24,11 @@ runs:
- name: Create Environment
shell: bash
if: ${{ steps.cache-conda.outputs.cache-hit == false }}
# NOTE: We use `sed` to force a Python version in the `environment.yaml` file
run: |
conda update -n base -c defaults conda
source $CONDA/etc/profile.d/conda.sh
conda init bash
sed -i 's/- python >=3.*$/- python ${{ inputs.python-version }}.*/' environment.yaml
conda env create -f environment.yaml --name anaconda-linter --force
conda run --name anaconda-linter pip install .
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,28 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/setup-env
with:
python-version: "3.11"
# Executes `pre-commit` with the `make` directive to ensure all dependencies are found
- run: |
source $CONDA/bin/activate
conda activate anaconda-linter
make pre-commit
test:
runs-on: ubuntu-latest
name: Test on ${{ matrix.python-version }}
strategy:
matrix:
python-version: ["3.11"] # TODO: Bump this to 3.12 when supported and drop 3.11 (covered in pre-commit)
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: ./.github/actions/setup-env
with:
python-version: ${{ matrix.python-version }}
- run: |
source $CONDA/bin/activate
conda activate anaconda-linter
make test
build-recipe:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -54,6 +71,8 @@ jobs:
repository: AnacondaRecipes/anaconda-linter-feedstock
path: ./feedstock
- uses: ./.github/actions/setup-env
with:
python-version: "3.11"
- name: Run lint
run: |
cp -r ./feedstock/abs.yaml ./feedstock/recipe .
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Note: version releases in the 0.x.y range may introduce breaking changes.

## 0.1.3
- Python 3.11+ will only be supported for now for ease of maintenance
- Improves error and warnings output, loosely following what C compilers tend to with a "report" section
- When the `--fix` option is used, we return the list of rules that have been successfully auto-fixed
- The executable now returns pre-defined POSIX-style return codes
Expand Down
2 changes: 1 addition & 1 deletion anaconda_linter/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@

import networkx as nx
import percy.render.recipe as _recipe
from percy.render._renderer import RendererType
from percy.render.exceptions import EmptyRecipe, JinjaRenderFailure, MissingMetaYaml, RecipeError, YAMLRenderFailure
from percy.render.recipe import RendererType
from percy.render.variants import read_conda_build_config

from anaconda_linter import utils as _utils
Expand Down
4 changes: 2 additions & 2 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ channels:
- defaults

dependencies:
- python >=3.8
- python >=3.11
# build
- setuptools
- pip
- make
# run
- distro-tooling::percy >=0.1.1,<0.2.0
- distro-tooling::percy >=0.1.3
- distro-tooling::anaconda-packaging-utils
- ruamel.yaml
- license-expression
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

# [project]
# name = "anaconda-linter"
# version = "v0.1.1"
# version = "v0.1.3"
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from unittest.mock import mock_open, patch

import pytest
from percy.render.recipe import Recipe, RendererType
from percy.render._renderer import RendererType
from percy.render.recipe import Recipe
from percy.render.variants import Variant, read_conda_build_config

from anaconda_linter import utils
Expand Down
11 changes: 6 additions & 5 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

import pytest
from conftest import check, check_dir
from percy.render._renderer import RendererType
from percy.render.exceptions import RecipeError
from percy.render.recipe import Recipe, RendererType
from percy.render.recipe import Recipe

from anaconda_linter import lint, utils
from anaconda_linter.lint import AutoFixState, Linter, LintMessage, Severity
Expand Down Expand Up @@ -123,16 +124,16 @@ def test_can_auto_fix(linter: lint.Linter):
"""

# This class is auto-fixable as the function has been defined on the child class
class auto_fixable_dummy_rule(lint.LintCheck):
class DummyAutoFixableRule(lint.LintCheck):
def fix(self) -> bool:
return False

# This class is not auto-fixable as it is using the default implementation of `fix()` in the parent class.
class non_auto_fixable_dummy_rule(lint.LintCheck):
class DummyNonAutoFixableRule(lint.LintCheck):
pass

assert auto_fixable_dummy_rule(linter).can_auto_fix()
assert not non_auto_fixable_dummy_rule(linter).can_auto_fix()
assert DummyAutoFixableRule(linter).can_auto_fix()
assert not DummyNonAutoFixableRule(linter).can_auto_fix()


@pytest.mark.parametrize(
Expand Down

0 comments on commit e2c12b6

Please sign in to comment.