From 9ed317bd0513fbf4b82fc0aebeaad6bf2f4b5659 Mon Sep 17 00:00:00 2001 From: Earle Lowe <30607889+emlowe@users.noreply.github.com> Date: Thu, 9 May 2024 08:48:19 -0700 Subject: [PATCH 01/13] Update pre-commit versions to match setup.py --- .pre-commit-config.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3264c6..94e06dd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 From 5a4050e8f30ab5eebda2e38decd8d357e463bf65 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 12:01:28 -0700 Subject: [PATCH 02/13] Add precommit workflow and some source updates --- .github/workflows/pre-commit.yml | 79 ++++++++++++++++++++++++++++++++ chianft/util/mint.py | 8 ++-- tests/test_mint.py | 3 +- 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..fddcf66 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,79 @@ +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 }} + + - shell: bash + run: | + python3 -m venv venv + if [[ ${{ matrix.os.runs-on }} == windows-latest ]]; then + source ./venv/Scripts/activate + else + . ./venv/bin/activate + fi + pip install --extra-index https://pypi.chia.net/simple/ --editable .[dev] + pre-commit run --all-files --verbose diff --git a/chianft/util/mint.py b/chianft/util/mint.py index cd388aa..6142eaf 100644 --- a/chianft/util/mint.py +++ b/chianft/util/mint.py @@ -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 diff --git a/tests/test_mint.py b/tests/test_mint.py index 8abe1da..408cc8c 100644 --- a/tests/test_mint.py +++ b/tests/test_mint.py @@ -43,7 +43,8 @@ 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]) + writer.writerows(metadata) return filename From 87e5ac1cac510b82b6be4e388657ddfbba24fff6 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 12:03:57 -0700 Subject: [PATCH 03/13] Add pre-commit to dev dependency --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index c56a923..dada84b 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,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( From 7162df44473da571e1da8a607d53dc654f5917d3 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 12:06:27 -0700 Subject: [PATCH 04/13] update pip --- .github/workflows/pre-commit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index fddcf66..30aba31 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -75,5 +75,6 @@ jobs: else . ./venv/bin/activate fi + pip install --upgrade pip pip install --extra-index https://pypi.chia.net/simple/ --editable .[dev] pre-commit run --all-files --verbose From cc3ee4427f2b36b47a51b2c6fbba2030927931a8 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 12:15:27 -0700 Subject: [PATCH 05/13] updates --- .github/workflows/pre-commit.yml | 16 +++++++++------- setup.py | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 30aba31..c50e6ba 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -67,14 +67,16 @@ jobs: 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: | - python3 -m venv venv - if [[ ${{ matrix.os.runs-on }} == windows-latest ]]; then - source ./venv/Scripts/activate - else - . ./venv/bin/activate - fi - pip install --upgrade pip pip install --extra-index https://pypi.chia.net/simple/ --editable .[dev] pre-commit run --all-files --verbose diff --git a/setup.py b/setup.py index dada84b..7f46756 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,6 @@ ] dev_dependencies = [ - "pre-commit==3.7.0", "pylint==3.1.0", "pytest==8.2.0", "pytest-asyncio==0.23.6", From 4a0bf4da49063d8d876af4fed8b4a64394a17581 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 12:19:03 -0700 Subject: [PATCH 06/13] trailing whitespace --- .github/workflows/pre-commit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index c50e6ba..4ef0976 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -70,12 +70,12 @@ jobs: - 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] From b18d949761336963ff608f1408c490c30c2054cb Mon Sep 17 00:00:00 2001 From: Earle Lowe <30607889+emlowe@users.noreply.github.com> Date: Thu, 9 May 2024 13:32:12 -0700 Subject: [PATCH 07/13] Adjustments to matric --- .github/workflows/pre-commit.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 4ef0976..03e1290 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -24,12 +24,11 @@ jobs: matrix: linux runs-on: intel: ubuntu-latest - arm: [linux, arm64] - name: macOS matrix: macos runs-on: intel: macos-12 - arm: [macos, arm64] + arm: macos-latest - name: Windows matrix: windows runs-on: From 54b8c47de99ed18ad06a1992efcfca78dd68a893 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 13:35:48 -0700 Subject: [PATCH 08/13] precommit matrix adjustments --- .github/workflows/pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 03e1290..17c81dc 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -46,7 +46,7 @@ jobs: - major_dot_minor: "3.12" exclude: - os: - matrix: windows + matrix: [windows,linux] arch: matrix: arm From 0c76daa73a78f5326a055af6c8ad8d98c0fee515 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 13:40:04 -0700 Subject: [PATCH 09/13] precommit matrix adjustments --- .github/workflows/pre-commit.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 17c81dc..28e5b1c 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -28,7 +28,7 @@ jobs: matrix: macos runs-on: intel: macos-12 - arm: macos-latest + arm: [macos, arm64] - name: Windows matrix: windows runs-on: @@ -46,7 +46,11 @@ jobs: - major_dot_minor: "3.12" exclude: - os: - matrix: [windows,linux] + matrix: windows + arch: + matrix: arm + - os: + matrix: linux arch: matrix: arm From 532ae2327f742dae07e7d4b364d1db9da4893e09 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Thu, 9 May 2024 13:43:57 -0700 Subject: [PATCH 10/13] precommit matrix adjustments --- .github/workflows/pre-commit.yml | 34 +++++--------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 28e5b1c..8c2feef 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -13,46 +13,22 @@ concurrency: jobs: pre-commit: - name: ${{ matrix.os.name }} ${{ matrix.arch.name }} ${{ matrix.python.major_dot_minor }} - runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + name: ${{ matrix.os.runs-on }} ${{ matrix.python.major_dot_minor }} + runs-on: ${{ matrix.os.runs-on }} timeout-minutes: 20 strategy: fail-fast: false matrix: os: - - name: Linux - matrix: linux - runs-on: - intel: ubuntu-latest - - 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 + - runs-on: macos-latest + - runs-on: ubuntu-latest + - runs-on: windows-latest 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 - - os: - matrix: linux - arch: - matrix: arm steps: - name: Clean workspace From 5dc5d39e892e07b9a0741f6b1d2dd3b38480e2b9 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Mon, 13 May 2024 10:42:24 -0700 Subject: [PATCH 11/13] restore standard matrix --- .github/workflows/pre-commit.yml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 8c2feef..acf6441 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -20,15 +20,36 @@ jobs: fail-fast: false matrix: os: - - runs-on: macos-latest - - runs-on: ubuntu-latest - - runs-on: windows-latest + - 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 From bf23fd80fc173fdcafd6e789ab69de3e6f76dcca Mon Sep 17 00:00:00 2001 From: Earle Lowe <30607889+emlowe@users.noreply.github.com> Date: Mon, 13 May 2024 10:51:40 -0700 Subject: [PATCH 12/13] Update tests/test_mint.py Co-authored-by: Kyle Altendorf --- tests/test_mint.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_mint.py b/tests/test_mint.py index 408cc8c..962014d 100644 --- a/tests/test_mint.py +++ b/tests/test_mint.py @@ -43,8 +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]) - writer.writerows(metadata) + writer.writerows([header, *metadata]) return filename From e8fccb68e877c5484c50e8818b1e0ed3d0e693f6 Mon Sep 17 00:00:00 2001 From: Earle Lowe Date: Mon, 13 May 2024 10:53:41 -0700 Subject: [PATCH 13/13] restore standard matrix part 2 --- .github/workflows/pre-commit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index acf6441..4ef0976 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -13,8 +13,8 @@ concurrency: jobs: pre-commit: - name: ${{ matrix.os.runs-on }} ${{ matrix.python.major_dot_minor }} - runs-on: ${{ matrix.os.runs-on }} + 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