From ec54cbb508b1241ef4db032bcf98722d8da4bae1 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 25 Sep 2024 22:46:34 +0200 Subject: [PATCH] feat: add yamlfix --- .github/dependabot.yml | 9 +++++---- .github/workflows/build-wheels.yml | 19 ++++--------------- .github/workflows/code-quality.yml | 9 +-------- .github/workflows/pr-rating.yml | 4 +--- .github/workflows/pytest.yml | 12 +++--------- pyproject.toml | 8 ++++++++ 6 files changed, 22 insertions(+), 39 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8ceeaf03..44cdb3cf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,7 @@ +--- version: 2 updates: -- package-ecosystem: "pip" - directory: "/" - schedule: - interval: "weekly" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 97d03fc1..7d5f289f 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,5 +1,5 @@ +--- name: Build source and wheel packages - on: push: branches: @@ -7,7 +7,6 @@ on: pull_request: branches: - main - jobs: build: strategy: @@ -15,20 +14,16 @@ jobs: matrix: os: [macos-13, macos-14, ubuntu-22.04, ubuntu-24.04] runs-on: ${{ matrix.os }} - steps: - uses: actions/checkout@v4 - - name: Workaround github issue https://github.com/actions/runner-images/issues/7192 if: startsWith(matrix.os, 'ubuntu-') run: sudo echo RESET grub-efi/install_devices | sudo debconf-communicate grub-pc - - name: Set up Python if: startsWith(matrix.os, 'macos') uses: actions/setup-python@v2 with: python-version: 3.12 - - name: Cache dependencies uses: actions/cache@v4 with: @@ -36,38 +31,32 @@ jobs: key: ${{ runner.os }}-build-wheels-${{ hashFiles('pyproject.toml') }} restore-keys: | ${{ runner.os }}-build-wheels- - - name: Install required system packages for macOS if: startsWith(matrix.os, 'macos-') run: | brew update brew tap cuber/homebrew-libsecp256k1 brew install libsecp256k1 - - name: Install required system packages only for Ubuntu Linux if: startsWith(matrix.os, 'ubuntu-') run: | sudo apt-get update sudo apt-get -y upgrade sudo apt-get install -y libsecp256k1-dev - - name: Install Hatch run: | python3 -m venv /tmp/venv /tmp/venv/bin/python3 -m pip install --upgrade hatch - - name: Build source and wheel packages run: | /tmp/venv/bin/python3 -m hatch build - - name: Install the Python wheel run: | /tmp/venv/bin/python3 -m pip install dist/aleph_sdk_python-*.whl - - - name: Install/upgrade `setuptools` + - name: Install `setuptools` on systems where it is missing by default run: /tmp/venv/bin/python3 -m pip install --upgrade setuptools - + if: matrix.os == 'ubuntu-24.04' - name: Import and use the package - run: | + run: |- /tmp/venv/bin/python3 -c "import aleph.sdk" /tmp/venv/bin/python3 -c "from aleph.sdk.chains.ethereum import get_fallback_account; get_fallback_account()" diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 16ec4e91..070aeb9c 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -1,25 +1,20 @@ +--- name: Test code quality - on: push: pull_request: branches: - main - jobs: code-quality: runs-on: ubuntu-24.04 - steps: - uses: actions/checkout@v4 - - name: Workaround github issue https://github.com/actions/runner-images/issues/7192 run: sudo echo RESET grub-efi/install_devices | sudo debconf-communicate grub-pc - - name: Install system dependencies run: | sudo apt-get install -y python3-pip libsecp256k1-dev - - name: Cache dependencies uses: actions/cache@v4 with: @@ -27,11 +22,9 @@ jobs: key: ${{ runner.os }}-code-quality-${{ hashFiles('pyproject.toml') }} restore-keys: | ${{ runner.os }}-code-quality- - - name: Install python dependencies run: | python3 -m venv /tmp/venv /tmp/venv/bin/pip install hatch - - name: Run Hatch lint run: /tmp/venv/bin/hatch run linting:all diff --git a/.github/workflows/pr-rating.yml b/.github/workflows/pr-rating.yml index 1378b687..7d066b77 100644 --- a/.github/workflows/pr-rating.yml +++ b/.github/workflows/pr-rating.yml @@ -1,12 +1,10 @@ +--- name: PR Difficulty Rating Action - permissions: pull-requests: write - on: pull_request: types: [opened, reopened, ready_for_review] - jobs: difficulty-rating: runs-on: ubuntu-latest diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index f1af47c5..407cbdf4 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,5 +1,5 @@ +--- name: Test/Coverage with Python - on: push: pull_request: @@ -10,37 +10,31 @@ on: # in order to catch when unfrozen dependency updates # break the use of the library. - cron: '4 0 * * *' - jobs: tests: strategy: fail-fast: false matrix: - python-version: [ "3.9", "3.10", "3.11", "3.12" ] + python-version: ["3.9", "3.10", "3.11", "3.12"] os: [ubuntu-22.04, ubuntu-24.04] runs-on: ${{ matrix.os }} - steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - run: | sudo apt-get update sudo apt-get install -y python3-pip libsodium-dev - - run: | python3 -m venv /tmp/venv /tmp/venv/bin/python -m pip install --upgrade pip hatch coverage - - run: | /tmp/venv/bin/pip freeze /tmp/venv/bin/hatch run testing:pip freeze /tmp/venv/bin/hatch run testing:test - - run: /tmp/venv/bin/hatch run testing:cov - + if: matrix.python-version == '3.11' - uses: codecov/codecov-action@v4.0.1 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 3fd02d17..237105e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -154,6 +154,7 @@ dependencies = [ "ruff==0.4.8", "isort==5.13.2", "pyproject-fmt==2.2.1", + "yamlfix==1.16.1", ] [tool.hatch.envs.linting.scripts] typing = "mypy --config-file=pyproject.toml {args:} ./src/ ./tests/ ./examples/" @@ -162,12 +163,14 @@ style = [ "black --check --diff {args:} ./src/ ./tests/ ./examples/", "isort --check-only --profile black {args:} ./src/ ./tests/ ./examples/", "pyproject-fmt --check pyproject.toml", + "yamlfix --check .", ] fmt = [ "black {args:} ./src/ ./tests/ ./examples/", "ruff check --fix {args:.} ./src/ ./tests/ ./examples/", "isort --profile black {args:} ./src/ ./tests/ ./examples/", "pyproject-fmt pyproject.toml", + "yamlfix .", "style", ] all = [ @@ -248,3 +251,8 @@ follow_imports = "silent" # Miscellaneous strictness flags # Allows variables to be redefined with an arbitrary type, as long as the redefinition is in the same block and nesting level as the original definition. allow_redefinition = true + + +[tool.yamlfix] +sequence_style = "keep_style" +preserve_quotes = true