From ba0ff2ebee1ab1b736ba24d0436858d5ac0bac12 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Tue, 11 Apr 2023 11:26:48 -0700 Subject: [PATCH] Move release pipeline to a separate file | chore(release) (#619) I moved the release pipeline out because the tests are sometimes flaky but we may not want them to block the scheduled release. I separated the dev and official releases to use different environments so the official releases can be manually reviewed before uploading to pypi. Updated requirements-dev.txt --- .github/workflows/main.yaml | 52 ---------------- .github/workflows/release.yaml | 107 +++++++++++++++++++++++++++++++++ noxfile.py | 1 + requirements-dev.txt | 10 +-- 4 files changed, 113 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c6fbb62da..a267715f1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -97,55 +97,3 @@ jobs: run: pip install . - name: Build documentation run: python -m sphinx docs dist/html - - release: - needs: [test] - if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs') - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.10'] - steps: - - name: Checkout ONNX Script - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install Python build dependencies - run: | - python -m pip install --upgrade pip build wheel - - name: Build ONNX Script wheel dev version - run: | - python -m build - if: (!startsWith(github.ref, 'refs/tags/v')) - - name: Build ONNX Script wheel release version - run: | - python -m build - if: startsWith(github.ref, 'refs/tags/v') - env: - ONNX_SCRIPT_RELEASE: 1 - - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - - name: Install ONNX Script wheel - run: | - python -m pip install dist/*.whl - - publish: - needs: [release] - runs-on: ubuntu-latest - environment: production - # Publish only when it is a scheduled run (weekly dev builds) or a tag push with version number - if: (github.event_name == 'schedule') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) - steps: - - uses: actions/download-artifact@v3 - with: - name: dist - path: dist - # TODO: Check the tag name matches the VERSION file - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..fb2d43760 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,107 @@ +name: Release + +on: + schedule: + # Run weekly on Mondays and Wednesdays 00:00 + - cron: '00 00 * * MON,WED' + push: + branches: [main, rel-*] + pull_request: + branches: [main, rel-*] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + release: + if: github.event_name != 'pull_request' || startsWith(github.base_ref, 'rel-') || contains(github.event.pull_request.labels.*.name, 'run release CIs') + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + steps: + - name: Checkout ONNX Script + uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Python build dependencies + run: | + python -m pip install --upgrade pip build wheel + - name: Build ONNX Script wheel dev version + run: | + python -m build + if: (!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))) + - name: Build ONNX Script wheel release version + run: | + python -m build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + env: + ONNX_SCRIPT_RELEASE: 1 + - uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + - name: Install ONNX Script wheel + run: | + python -m pip install dist/*.whl + + test-wheel: + needs: [release] + runs-on: ubuntu-latest + steps: + - name: Checkout ONNX Script + uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip wheel + python -m pip install -r requirements-dev.txt + - uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + - name: Install wheel + run: | + python -m pip install dist/*.whl + - name: Run tests + run: | + python -m pytest -v -n auto + + publish-dev: + needs: [release] + runs-on: ubuntu-latest + environment: PyPI Dev + # Publish only when it is a scheduled run (dev builds) + if: github.event_name == 'schedule' && !startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + # TODO: Check the version number is a dev version + - name: Publish dev version to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + + publish-release: + needs: [release] + runs-on: ubuntu-latest + environment: PyPI + # Publish only when it is a tag push with version number + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v3 + with: + name: wheels + path: dist + # TODO: Check the tag name matches the VERSION file + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/noxfile.py b/noxfile.py index 2563a3a8f..1e6b26bc1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -16,6 +16,7 @@ "beartype", "types-PyYAML", "expecttest", + "hypothesis", "packaging", "parameterized", "pytest-cov", diff --git a/requirements-dev.txt b/requirements-dev.txt index dc33a0efb..5f5414192 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,7 @@ -numpy -onnx-weekly setuptools>=61.0.0 ---pre -f https://onnxruntimepackages.z14.web.core.windows.net/onnxruntime-function-experiment.html -ort-function-experiment-nightly +numpy +onnx-weekly==1.14.0.dev20230403 +onnxruntime typing_extensions # Docs site @@ -17,6 +16,7 @@ beartype # Testing expecttest +hypothesis parameterized pytest-cov pytest-randomly @@ -28,4 +28,4 @@ torch>=1.13 # Lint lintrunner -lintrunner_adapters>=0.6.1 +lintrunner_adapters>=0.7.0