Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add-pre-commit #13

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML

13 changes: 3 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,15 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: prefix-dev/setup-pixi@v0.5.1
with:
pixi-version: "latest"

- name: pixi install
run: |
run: |
pixi install

- name: format
run: pixi run fmt-check

- name: lint
run: pixi run lint-check

- name: run tests
run: |
run: |
pixi run -e test pytest

21 changes: 21 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: pre-commit

on:
push:
branches: [ "main" ]
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
environments: lint
- name: pre-commit
run: pixi run pre-commit-run --color=always --show-diff-on-failure
env:
# As the rust GitHub action is better at the rust jobs it can be skipped in this job.
SKIP: fmt
48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
exclude: (^.pixi/|.snap)
repos:
- repo: local
hooks:
- id: pixi-install
name: pixi-install
entry: pixi install -e lint
language: system
always_run: true
require_serial: true
pass_filenames: false
# pre-commit-hooks
- id: check-yaml
name: check-yaml
entry: pixi run -e lint check-yaml
language: system
types: [yaml]
- id: end-of-file
name: end-of-file
entry: pixi run -e lint end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
- id: trailing-whitespace
name: trailing-whitespace
entry: pixi run -e lint trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]
# Use ruff for python examples
- id: ruff
name: ruff
entry: pixi run -e lint ruff check --fix --exit-non-zero-on-fix --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
- id: ruff-format
name: ruff-format
entry: pixi run -e lint ruff format --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
# typos
- id: typos
name: typos
entry: pixi run -e lint typos --write-changes --force-exclude
language: system
types: [text]
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Compatability tools for Rattler Build
# Compatibility tools for Rattler Build

This repository contains a set of tools to help with the integration of rattler-build into conda-forge.
Mainly by providing an interface that is recognizable for uses used to `conda-build`
2,075 changes: 2,044 additions & 31 deletions pixi.lock

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ ruff = "*"
[feature.test.tasks]
test = "pytest"
snapshot_update = "pytest --snapshot-update"
lint = "ruff check src"
lint-check = "ruff check --check --diff src"
fmt = "ruff format src tests"
fmt-check = "ruff format --check --diff src tests"


[feature.lint.dependencies]
pre-commit = ">=3.7.1,<4"
pre-commit-hooks = ">=4.6.0,<5"
ruff = ">=0.4.8,<0.5"
typos = ">=1.23.1,<2"

[feature.lint.tasks]
pre-commit-install = "pre-commit-install"
pre-commit-run = "pre-commit run"


[environments]
test = ["test"]
lint = { features = ["lint"], no-default-feature = true, solve-group = "default" }
4 changes: 2 additions & 2 deletions src/rattler_build_conda_compat/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ def lint_non_noarch_dont_constrain_python_and_rbase(requirements_section):
for reqs in [filtered_host_reqs, filtered_run_reqs]:
if language not in reqs:
for req in reqs:
splitted = req.split(" ", 1)
if len(splitted) > 1:
split = req.split(" ", 1)
if len(split) > 1:
constraint = req.split(" ", 1)[1]
if constraint.startswith(">") or constraint.startswith("<"):
lints.append(
Expand Down
2 changes: 1 addition & 1 deletion tests/data/recipe_requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ requirements:
then:
- ${{ cdt('xorg-x11-proto-devel') }}
host:
- python
- python