From f1ba8db653f41b0722d7fd0a52e6ef744413a235 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 10 Jul 2024 12:50:07 -0400 Subject: [PATCH] Format CI workflows --- .github/workflows/audit-check.yml | 2 +- .github/workflows/benchmark.yml | 157 +++++----- .github/workflows/build-crate-and-npm.yml | 90 +++--- .github/workflows/build-test.yml | 340 +++++++++++----------- 4 files changed, 294 insertions(+), 295 deletions(-) diff --git a/.github/workflows/audit-check.yml b/.github/workflows/audit-check.yml index 81cf42616..332799198 100644 --- a/.github/workflows/audit-check.yml +++ b/.github/workflows/audit-check.yml @@ -2,7 +2,7 @@ name: Security audit on: pull_request: branches: - - '**' + - "**" jobs: security_audit: diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 90786580e..cf1ad22fd 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -1,4 +1,3 @@ - name: Tests on: @@ -6,10 +5,10 @@ on: branches: - main tags: - - '**' + - "**" pull_request: branches: - - '**' + - "**" jobs: tests: @@ -19,56 +18,56 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest, windows-latest] - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/checkout@v4 + with: + fetch-depth: 1 - - uses: chia-network/actions/setup-python@main - name: Install Python ${{ matrix.python-version }} - with: - python-version: ${{ matrix.python-version }} + - uses: chia-network/actions/setup-python@main + name: Install Python ${{ matrix.python-version }} + with: + python-version: ${{ matrix.python-version }} - - name: Update pip - run: | + - name: Update pip + run: | python -m pip install --upgrade pip - - name: Set up rust - uses: dtolnay/rust-toolchain@stable + - name: Set up rust + uses: dtolnay/rust-toolchain@stable - - name: setup venv - run: | - python -m venv venv + - name: setup venv + run: | + python -m venv venv - - uses: chia-network/actions/activate-venv@main + - uses: chia-network/actions/activate-venv@main - - name: Install dependencies - run: | - python -m pip install maturin - rustup target add x86_64-unknown-linux-musl - python -m pip install pytest pytest-xdist - python -m pip install mypy - python -m pip install black + - name: Install dependencies + run: | + python -m pip install maturin + rustup target add x86_64-unknown-linux-musl + python -m pip install pytest pytest-xdist + python -m pip install mypy + python -m pip install black - - name: Build - run: | - python -m pip install clvm_tools colorama blspy chia-blockchain==2.1.2 clvm==0.9.8 - maturin develop --release -m wheel/Cargo.toml + - name: Build + run: | + python -m pip install clvm_tools colorama blspy chia-blockchain==2.1.2 clvm==0.9.8 + maturin develop --release -m wheel/Cargo.toml - - name: python mypy - run: | - mypy --ignore-missing-imports tests + - name: python mypy + run: | + mypy --ignore-missing-imports tests - - name: python black - run: | - black --check tests - black --check wheel/generate_type_stubs.py + - name: python black + run: | + black --check tests + black --check wheel/generate_type_stubs.py - - name: python tests - run: | - pytest tests + - name: python tests + run: | + pytest tests generator-benchmarks: name: Generator performance @@ -76,47 +75,47 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10', '3.11'] + python-version: ["3.10", "3.11"] steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/checkout@v4 + with: + fetch-depth: 1 - - uses: chia-network/actions/setup-python@main - name: Install Python ${{ matrix.python-version }} - with: - python-version: ${{ matrix.python-version }} + - uses: chia-network/actions/setup-python@main + name: Install Python ${{ matrix.python-version }} + with: + python-version: ${{ matrix.python-version }} - - name: Set up rust - uses: dtolnay/rust-toolchain@stable + - name: Set up rust + uses: dtolnay/rust-toolchain@stable - - name: setup venv - run: | - python -m venv venv + - name: setup venv + run: | + python -m venv venv - - uses: chia-network/actions/activate-venv@main + - uses: chia-network/actions/activate-venv@main - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install maturin colorama clvm_tools - rustup target add x86_64-unknown-linux-musl + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install maturin colorama clvm_tools + rustup target add x86_64-unknown-linux-musl - - name: Build - run: | - maturin develop --release -m wheel/Cargo.toml + - name: Build + run: | + maturin develop --release -m wheel/Cargo.toml - - name: test generators - run: | - cd tests - ./test-generators.py + - name: test generators + run: | + cd tests + ./test-generators.py - - name: Run cost checks - run: | - cd tests - ./generate-programs.py - ./run-programs.py + - name: Run cost checks + run: | + cd tests + ./generate-programs.py + ./run-programs.py benchmarks: name: rust benchmarks @@ -125,13 +124,13 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/checkout@v4 + with: + fetch-depth: 1 - - name: Set up rust - uses: dtolnay/rust-toolchain@stable + - name: Set up rust + uses: dtolnay/rust-toolchain@stable - - name: cargo bench - run: | - cargo bench --workspace --exclude chia_rs + - name: cargo bench + run: | + cargo bench --workspace --exclude chia_rs diff --git a/.github/workflows/build-crate-and-npm.yml b/.github/workflows/build-crate-and-npm.yml index 45c16ca10..3b9d79d2f 100644 --- a/.github/workflows/build-crate-and-npm.yml +++ b/.github/workflows/build-crate-and-npm.yml @@ -5,10 +5,10 @@ on: branches: - main tags: - - '**' + - "**" pull_request: branches: - - '**' + - "**" jobs: build_crate: @@ -18,54 +18,54 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: Set up rusts - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy + - name: Set up rusts + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy - - name: fmt - run: cargo fmt -- --files-with-diff --check - - name: clippy - run: cargo clippy - - name: tests - run: cargo test && cargo test --release - - name: build - run: cargo build --release + - name: fmt + run: cargo fmt -- --files-with-diff --check + - name: clippy + run: cargo clippy + - name: tests + run: cargo test && cargo test --release + - name: build + run: cargo build --release - - name: Upload crate artifacts - uses: actions/upload-artifact@v4 - with: - name: crate - path: ./target/package/*-*.crate + - name: Upload crate artifacts + uses: actions/upload-artifact@v4 + with: + name: crate + path: ./target/package/*-*.crate - - name: install wasm-pack - run: cargo install wasm-pack --locked + - name: install wasm-pack + run: cargo install wasm-pack --locked - - name: wasm-pack build and pack - run: cd wasm && wasm-pack build && wasm-pack pack + - name: wasm-pack build and pack + run: cd wasm && wasm-pack build && wasm-pack pack - - name: Upload npm pkg artifacts - uses: actions/upload-artifact@v4 - with: - name: npm-pkg - path: ./wasm/pkg/*-*.tgz + - name: Upload npm pkg artifacts + uses: actions/upload-artifact@v4 + with: + name: npm-pkg + path: ./wasm/pkg/*-*.tgz - - name: publish to crates.io if tagged - if: startsWith(github.event.ref, 'refs/tags') - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }} - run: | - cargo install cargo-workspaces --locked - cargo ws publish --publish-as-is + - name: publish to crates.io if tagged + if: startsWith(github.event.ref, 'refs/tags') + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }} + run: | + cargo install cargo-workspaces --locked + cargo ws publish --publish-as-is - # this has not been tested, so probably needs to be debugged next time a tag is created - - name: publish to npmjs.com if tagged - if: startsWith(github.event.ref, 'refs/tags') - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.node_auth_token }} - package: wasm/pkg/package.json + # this has not been tested, so probably needs to be debugged next time a tag is created + - name: publish to npmjs.com if tagged + if: startsWith(github.event.ref, 'refs/tags') + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.node_auth_token }} + package: wasm/pkg/package.json diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 34e081ed8..006c20dfb 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -3,12 +3,12 @@ name: build - check - upload on: push: branches: - - main + - main release: types: [published] pull_request: branches: - - '**' + - "**" concurrency: # SHA is added to the end if on `main` to let all main workflows run @@ -42,8 +42,8 @@ jobs: runs-on: intel: [windows-latest] python: - - major-dot-minor: '3.8' - cibw-build: 'cp38-*' + - major-dot-minor: "3.8" + cibw-build: "cp38-*" by-arch: arm: manylinux-version: 2_28 @@ -53,9 +53,9 @@ jobs: manylinux-version: 2_28 docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64 rustup-target: x86_64-unknown-linux-musl - matrix: '3.8' - - major-dot-minor: '3.9' - cibw-build: 'cp39-*' + matrix: "3.8" + - major-dot-minor: "3.9" + cibw-build: "cp39-*" by-arch: arm: manylinux-version: 2_28 @@ -65,9 +65,9 @@ jobs: manylinux-version: 2_28 docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64 rustup-target: x86_64-unknown-linux-musl - matrix: '3.9' - - major-dot-minor: '3.10' - cibw-build: 'cp310-*' + matrix: "3.9" + - major-dot-minor: "3.10" + cibw-build: "cp310-*" by-arch: arm: manylinux-version: 2_28 @@ -77,9 +77,9 @@ jobs: manylinux-version: 2_28 docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64 rustup-target: x86_64-unknown-linux-musl - matrix: '3.10' - - major-dot-minor: '3.11' - cibw-build: 'cp311-*' + matrix: "3.10" + - major-dot-minor: "3.11" + cibw-build: "cp311-*" by-arch: arm: manylinux-version: 2_28 @@ -89,9 +89,9 @@ jobs: manylinux-version: 2_28 docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64 rustup-target: x86_64-unknown-linux-musl - matrix: '3.11' - - major-dot-minor: '3.12' - cibw-build: 'cp312-*' + matrix: "3.11" + - major-dot-minor: "3.12" + cibw-build: "cp312-*" by-arch: arm: manylinux-version: 2_28 @@ -101,7 +101,7 @@ jobs: manylinux-version: 2_28 docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64 rustup-target: x86_64-unknown-linux-musl - matrix: '3.12' + matrix: "3.12" arch: - name: ARM @@ -123,115 +123,115 @@ jobs: matrix: arm steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 - - uses: Chia-Network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} - - name: Update pip - run: | + - name: Update pip + run: | python -m pip install --upgrade pip - - name: Set up rust - uses: dtolnay/rust-toolchain@stable + - name: Set up rust + uses: dtolnay/rust-toolchain@stable - - name: Install dependencies - run: | + - name: Install dependencies + run: | python -m pip install maturin - - name: Build MacOs with maturin on Python ${{ matrix.python }} - if: matrix.os.matrix == 'macos' - env: - MACOSX_DEPLOYMENT_TARGET: '11.0' - run: | - python${{ matrix.python.major-dot-minor }} -m venv venv - . venv/bin/activate - maturin build -i python --release -m wheel/Cargo.toml - - - name: Build Linux with maturin on Python ${{ matrix.python }} - if: matrix.os.matrix == 'ubuntu' - run: | - docker run --rm --pull always \ - -v ${{ github.workspace }}:/ws --workdir=/ws \ - ${{ matrix.python.by-arch[matrix.arch.matrix].docker-url }} \ - bash -exc '\ - yum -y install openssl-devel && \ - source $HOME/.cargo/env && \ - rustup target add ${{ matrix.python.by-arch[matrix.arch.matrix].rustup-target }} && \ - python${{ matrix.python.major-dot-minor }} -m venv /venv && \ - . /venv/bin/activate && \ - pip install --upgrade pip && \ - pip install maturin && \ - CC=gcc maturin build --release --manylinux ${{ matrix.python.by-arch[matrix.arch.matrix].manylinux-version }} -m wheel/Cargo.toml \ - ' - - - name: Build Windows with maturin on Python ${{ matrix.python }} - if: matrix.os.matrix == 'windows' - env: - CC: 'clang' - CFLAGS: "-D__BLST_PORTABLE__" - run: | - py -${{ matrix.python.major-dot-minor }} -m venv venv - . .\venv\Scripts\Activate.ps1 - maturin build -i python --release -m wheel/Cargo.toml - - - uses: Chia-Network/actions/create-venv@main - id: create-venv - - - uses: Chia-Network/actions/activate-venv@main - with: - directories: ${{ steps.create-venv.outputs.activate-venv-directories }} - - - name: Install chia_rs wheel - run: | - pip install --no-index --find-links target/wheels/ chia_rs - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-${{ matrix.os.name }}-${{ matrix.python.major-dot-minor }}-${{ matrix.arch.name }} - path: ./target/wheels/ + - name: Build MacOs with maturin on Python ${{ matrix.python }} + if: matrix.os.matrix == 'macos' + env: + MACOSX_DEPLOYMENT_TARGET: "11.0" + run: | + python${{ matrix.python.major-dot-minor }} -m venv venv + . venv/bin/activate + maturin build -i python --release -m wheel/Cargo.toml + + - name: Build Linux with maturin on Python ${{ matrix.python }} + if: matrix.os.matrix == 'ubuntu' + run: | + docker run --rm --pull always \ + -v ${{ github.workspace }}:/ws --workdir=/ws \ + ${{ matrix.python.by-arch[matrix.arch.matrix].docker-url }} \ + bash -exc '\ + yum -y install openssl-devel && \ + source $HOME/.cargo/env && \ + rustup target add ${{ matrix.python.by-arch[matrix.arch.matrix].rustup-target }} && \ + python${{ matrix.python.major-dot-minor }} -m venv /venv && \ + . /venv/bin/activate && \ + pip install --upgrade pip && \ + pip install maturin && \ + CC=gcc maturin build --release --manylinux ${{ matrix.python.by-arch[matrix.arch.matrix].manylinux-version }} -m wheel/Cargo.toml \ + ' + + - name: Build Windows with maturin on Python ${{ matrix.python }} + if: matrix.os.matrix == 'windows' + env: + CC: "clang" + CFLAGS: "-D__BLST_PORTABLE__" + run: | + py -${{ matrix.python.major-dot-minor }} -m venv venv + . .\venv\Scripts\Activate.ps1 + maturin build -i python --release -m wheel/Cargo.toml + + - uses: Chia-Network/actions/create-venv@main + id: create-venv + + - uses: Chia-Network/actions/activate-venv@main + with: + directories: ${{ steps.create-venv.outputs.activate-venv-directories }} + + - name: Install chia_rs wheel + run: | + pip install --no-index --find-links target/wheels/ chia_rs + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-${{ matrix.os.name }}-${{ matrix.python.major-dot-minor }}-${{ matrix.arch.name }} + path: ./target/wheels/ check-typestubs: name: Check chia_rs.pyi runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 - - uses: Chia-Network/actions/setup-python@main + - uses: Chia-Network/actions/setup-python@main - - name: check generated chia_rs.pyi - run: | - python wheel/generate_type_stubs.py - git diff --exit-code + - name: check generated chia_rs.pyi + run: | + python wheel/generate_type_stubs.py + git diff --exit-code build-tools: name: build chia-tools runs-on: ubuntu-latest steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 - - name: cargo build - run: | - cd crates/chia-tools - cargo build + - name: cargo build + run: | + cd crates/chia-tools + cargo build build-sdist: name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} @@ -246,35 +246,35 @@ jobs: arm: [Linux, ARM64] intel: [ubuntu-latest] python: - - major-dot-minor: '3.8' - matrix: '3.8' + - major-dot-minor: "3.8" + matrix: "3.8" arch: - name: Intel matrix: intel steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 - - uses: Chia-Network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} - - name: Build source distribution - run: | - pip install maturin - maturin sdist -m wheel/Cargo.toml + - name: Build source distribution + run: | + pip install maturin + maturin sdist -m wheel/Cargo.toml - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-sdist-${{ matrix.os.name }}-${{ matrix.python.major-dot-minor }}-${{ matrix.arch.name }} - path: ./target/wheels/ + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-sdist-${{ matrix.os.name }}-${{ matrix.python.major-dot-minor }}-${{ matrix.arch.name }} + path: ./target/wheels/ fmt: runs-on: ubuntu-latest @@ -287,13 +287,13 @@ jobs: - name: Install rust uses: dtolnay/rust-toolchain@stable with: - components: rustfmt, clippy + components: rustfmt, clippy - name: fmt run: | - cargo fmt --all -- --files-with-diff --check - cd wheel - cargo fmt -- --files-with-diff --check + cargo fmt --all -- --files-with-diff --check + cd wheel + cargo fmt -- --files-with-diff --check clippy: runs-on: ubuntu-latest @@ -305,12 +305,12 @@ jobs: - name: workspace run: | - cargo clippy --workspace --all-features --all-targets + cargo clippy --workspace --all-features --all-targets fuzz_targets: runs-on: ubuntu-latest env: - CARGO_PROFILE_RELEASE_LTO: false + CARGO_PROFILE_RELEASE_LTO: false steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly @@ -394,7 +394,7 @@ jobs: env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} with: - path-to-lcov: './lcov.info' + path-to-lcov: "./lcov.info" upload: name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} @@ -415,48 +415,48 @@ jobs: arm: [Linux, ARM64] intel: [ubuntu-latest] python: - - major-dot-minor: '3.9' - matrix: '3.9' + - major-dot-minor: "3.9" + matrix: "3.9" arch: - name: Intel matrix: intel steps: - - name: Clean workspace - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: Chia-Network/actions/setup-python@main - with: - python-version: ${{ matrix.python.major-dot-minor }} - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - merge-multiple: true - pattern: packages-* - path: ./dist - - - name: Set Env - uses: Chia-Network/actions/setjobenv@main - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: publish (PyPi) - if: env.RELEASE == 'true' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: dist/ - skip-existing: true - - - name: publish (Test PyPi) - if: env.PRE_RELEASE == 'true' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - packages-dir: dist/ - skip-existing: true + - name: Clean workspace + uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + pattern: packages-* + path: ./dist + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: publish (PyPi) + if: env.RELEASE == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ + skip-existing: true + + - name: publish (Test PyPi) + if: env.PRE_RELEASE == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + packages-dir: dist/ + skip-existing: true