From 73326f2533cb330d261a3a29723cf296a0278511 Mon Sep 17 00:00:00 2001 From: William Allen Date: Fri, 12 May 2023 17:24:57 -0500 Subject: [PATCH] Re-enabling pre-release logic CI (#361) * Re-enabling pre-release logic CI * Lint fixes * Lint fixes2 --------- Co-authored-by: Harold Brenes --- .github/workflows/build-wheels.yml | 330 +++++++++++++++-------------- setup.py | 4 +- 2 files changed, 172 insertions(+), 162 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 0d20217d7..3c0b3d1e7 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -3,9 +3,9 @@ name: build - check - upload on: push: branches: - - 'main' - tags: - - '**' + - main + release: + types: [published] pull_request: branches: - '**' @@ -19,6 +19,7 @@ jobs: build-wheels: name: Wheel - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + continue-on-error: true strategy: fail-fast: false matrix: @@ -112,6 +113,12 @@ jobs: with: fetch-depth: 0 + - name: Set Env + if: env.RUNNER_ARCH != 'ARM64' + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: Chia-Network/actions/setup-python@main with: python-version: ${{ matrix.python.major-dot-minor }} @@ -202,159 +209,164 @@ jobs: name: packages path: ./dist - # build-sdist: - # name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - # runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - # strategy: - # fail-fast: false - # matrix: - # os: - # - name: Ubuntu - # matrix: ubuntu - # runs-on: - # arm: [Linux, ARM64] - # intel: [ubuntu-latest] - # python: - # - 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@v3 - # with: - # fetch-depth: 0 - - # - uses: Chia-Network/actions/setup-python@main - # with: - # python-version: ${{ matrix.python.major-dot-minor }} - - # - name: Build source distribution - # run: | - # pip install build - # python -m build --sdist --outdir dist . - - # - name: Upload artifacts - # uses: actions/upload-artifact@v3 - # with: - # name: packages - # path: ./dist - - # check: - # name: Check - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - # runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - # strategy: - # fail-fast: false - # matrix: - # os: - # - name: Ubuntu - # matrix: ubuntu - # runs-on: - # arm: [Linux, ARM64] - # intel: [ubuntu-latest] - # python: - # - 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@v3 - # with: - # fetch-depth: 0 - - # - uses: Chia-Network/actions/setup-python@main - # with: - # python-version: ${{ matrix.python.major-dot-minor }} - - # - name: flake8 - # run: | - # pip install flake8 - # flake8 tests setup.py - - # - name: mypy - # run: | - # pip install mypy - # mypy --config-file mypi.ini setup.py tests - - # upload: - # name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} - # runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} - # needs: - # - build-wheels - # - build-sdist - # - check - # strategy: - # fail-fast: false - # matrix: - # os: - # - name: Ubuntu - # matrix: ubuntu - # runs-on: - # arm: [Linux, ARM64] - # intel: [ubuntu-latest] - # python: - # - 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@v3 - # 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@v3 - # with: - # name: packages - # path: ./dist - - # - name: Test for secrets access - # id: check_secrets - # shell: bash - # run: | - # unset HAS_SECRET - # if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi - # echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT - # env: - # SECRET: "${{ secrets.test_pypi_password }}" - - # - name: Install twine - # run: pip install twine - - # - name: Publish distribution to PyPI - # if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET - # env: - # TWINE_USERNAME: __token__ - # TWINE_NON_INTERACTIVE: 1 - # TWINE_PASSWORD: ${{ secrets.pypi_password }} - # run: twine upload --non-interactive --skip-existing --verbose 'dist/*' - - # - name: Publish distribution to Test PyPI - # if: steps.check_secrets.outputs.HAS_SECRET - # env: - # TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ - # TWINE_USERNAME: __token__ - # TWINE_NON_INTERACTIVE: 1 - # TWINE_PASSWORD: ${{ secrets.test_pypi_password }} - # run: twine upload --non-interactive --skip-existing --verbose 'dist/*' + build-sdist: + name: sdist - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - 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@v3 + with: + fetch-depth: 0 + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: Build source distribution + run: | + pip install build + python -m build --sdist --outdir dist . + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: packages + path: ./dist + + check: + name: Check - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - 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@v3 + with: + fetch-depth: 0 + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: flake8 + run: | + pip install flake8 + flake8 tests setup.py + + - name: mypy + run: | + pip install mypy + mypy --config-file mypi.ini setup.py tests + + upload: + name: Upload to PyPI - ${{ matrix.os.name }} ${{ matrix.python.major-dot-minor }} ${{ matrix.arch.name }} + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + needs: + - build-wheels + - build-sdist + - check + strategy: + fail-fast: false + matrix: + os: + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + python: + - 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@v3 + with: + fetch-depth: 0 + + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: Chia-Network/actions/setup-python@main + with: + python-version: ${{ matrix.python.major-dot-minor }} + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: packages + path: ./dist + + - name: Test for secrets access + id: check_secrets + shell: bash + run: | + unset HAS_SECRET + if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi + echo "HAS_SECRET=${HAS_SECRET}" >>$GITHUB_OUTPUT + env: + SECRET: "${{ secrets.test_pypi_password }}" + + - name: Install twine + run: pip install twine + + - name: Publish distribution to PyPI + if: env.RELEASE == 'true' && steps.check_secrets.outputs.HAS_SECRET + env: + TWINE_USERNAME: __token__ + TWINE_NON_INTERACTIVE: 1 + TWINE_PASSWORD: ${{ secrets.pypi_password }} + run: twine upload --non-interactive --skip-existing --verbose 'dist/*' + + - name: Publish distribution to Test PyPI + if: env.PRE_RELEASE == 'true' && steps.check_secrets.outputs.HAS_SECRET + env: + TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ + TWINE_USERNAME: __token__ + TWINE_NON_INTERACTIVE: 1 + TWINE_PASSWORD: ${{ secrets.test_pypi_password }} + run: twine upload --non-interactive --skip-existing --verbose 'dist/*' \ No newline at end of file diff --git a/setup.py b/setup.py index 9a947b714..3eefea11b 100644 --- a/setup.py +++ b/setup.py @@ -195,13 +195,11 @@ def build_extensions(self): ext.extra_link_args = link_opts build_ext.build_extensions(self) - # Copy bladebit_harvester.dll on windows to the target build directory + # Copy bladebit_harvester.dll on windows to the target build directory # in order to package it into the root directory of the wheel if os.getenv("CP_USE_GREEN_REAPER") == "1" and sys.platform == "win32": shutil.copy2("libs/bladebit_harvester.dll", self.build_lib + "/bladebit_harvester.dll") - - if platform.system() == "Windows": setup(