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

[CHIA-367] Setup pre-commit workflow #145

Merged
merged 14 commits into from
May 20, 2024
82 changes: 82 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: 🚨 pre-commit

on:
pull_request:
push:
branches:
- main

concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true

jobs:
pre-commit:
name: ${{ matrix.os.name }} ${{ matrix.arch.name }} ${{ matrix.python.major_dot_minor }}
runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os:
- name: Linux
matrix: linux
runs-on:
intel: ubuntu-latest
arm: [linux, arm64]
- name: macOS
matrix: macos
runs-on:
intel: macos-12
arm: [macos, arm64]
- name: Windows
matrix: windows
runs-on:
intel: windows-latest
arch:
- name: ARM64
matrix: arm
- name: Intel
matrix: intel
python:
- major_dot_minor: "3.8"
- major_dot_minor: "3.9"
- major_dot_minor: "3.10"
- major_dot_minor: "3.11"
- major_dot_minor: "3.12"
exclude:
- os:
matrix: windows
arch:
matrix: arm

steps:
- name: Clean workspace
uses: Chia-Network/actions/clean-workspace@main

- uses: Chia-Network/actions/git-mark-workspace-safe@main

- name: disable git autocrlf
run: |
git config --global core.autocrlf false

- uses: actions/checkout@v4

- uses: Chia-Network/actions/setup-python@main
with:
python-version: ${{ matrix.python.major_dot_minor }}

- name: Create virtual environment
uses: Chia-Network/actions/create-venv@main
id: create-venv

- name: Activate virtual environment
uses: Chia-Network/actions/activate-venv@main
with:
directories: ${{ steps.create-venv.outputs.activate-venv-directories }}

- shell: bash
run: |
pip install --extra-index https://pypi.chia.net/simple/ --editable .[dev]
pre-commit run --all-files --verbose
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ repos:
types_or: [cython, pyi, python]
args: ['--filter-files']
minimum_pre_commit_version: '2.9.2'
additional_dependencies: [isort==5.10.1]
additional_dependencies: [isort==5.13.2]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -22,12 +22,11 @@ repos:
- id: check-ast
- id: debug-statements
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 24.4.2
hooks:
- id: black
additional_dependencies: ['click<8.1']
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 7.0.0
hooks:
- id: flake8
- repo: local
Expand Down
8 changes: 4 additions & 4 deletions chianft/util/mint.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ async def create_spend_bundles(
did_cr = await self.wallet_client.get_did_info(
coin_id=did["coin_id"], latest=True
)
did_coin_record: Optional[
CoinRecord
] = await self.node_client.get_coin_record_by_name(
bytes32.from_hexstr(did_cr["latest_coin"])
did_coin_record: Optional[CoinRecord] = (
await self.node_client.get_coin_record_by_name(
bytes32.from_hexstr(did_cr["latest_coin"])
)
)
assert did_coin_record is not None
did_coin = did_coin_record.coin
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
]

dev_dependencies = [
"pre-commit==3.7.0",
"pylint==3.1.0",
"pytest==8.2.0",
"pytest-asyncio==0.23.6",
Expand All @@ -20,6 +19,8 @@
"mypy==1.10.0",
"black==24.4.2",
"types-setuptools==69.5.0.20240423",
"pre-commit==3.5.0; python_version < '3.9'",
"pre-commit==3.7.0; python_version >= '3.9'",
]

setup(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mint.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_metadata(filename: str, mint_total: int, has_targets: bool) -> str:
metadata.append(sample)
with open(filename, "w", newline="") as f:
writer = csv.writer(f)
writer.writerows([header] + metadata)
writer.writerows([header, *metadata])
return filename


Expand Down
Loading