From 6d3d6fdc71de72ff659c586ee8e363e41d0f3ef9 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 30 Mar 2022 02:52:36 -0500 Subject: [PATCH 1/2] CI: Add nightly upload of wheels to Anaconda Cloud Add nightlies.yml GitHub Action workflow that uses the gh CLI API to download the 'wheels' artifact from the latest completed build of the cibuildwheel workflow from the 'main' branch. This is done by getting the fields 'event', 'status', and 'databaseId' from the output of `gh run list` as JSON and then using jq to filter for 'push' events (which correspond to merged PRs to the 'main' branch) that have completed runs. This is then sorted by the databaseIds in descending order to get the latest completed build run number. Then the 'wheels' artifact can be downloaded. The downloaded wheels are then uploaded to the scipy-wheels-nightly Anaconda Cloud organization (https://anaconda.org/scipy-wheels-nightly) using the anaconda-client CLI API. --- .github/workflows/nightlies.yml | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/nightlies.yml diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml new file mode 100644 index 000000000000..438fe26cb1ce --- /dev/null +++ b/.github/workflows/nightlies.yml @@ -0,0 +1,64 @@ +name: Upload nightly wheels to Anaconda Cloud + +on: + # Run daily at 1:23 UTC to upload nightly wheels to Anaconda Cloud + schedule: + - cron: '23 1 * * *' + # Run on demand with workflow dispatch + workflow_dispatch: + +jobs: + upload_nightly_wheels: + name: Upload nightly wheels to Anaconda Cloud + runs-on: ubuntu-latest + if: github.repository_owner == 'matplotlib' + + steps: + - name: Install Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + + # c.f. https://github.com/actions/download-artifact/issues/3#issuecomment-1017141067 + - name: Download wheel artifacts from last build on 'main' + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PROJECT_REPO="matplotlib/matplotlib" + BRANCH="main" + WORKFLOW_NAME="cibuildwheel.yml" + ARTIFACT_NAME="wheels" + + gh run --repo "${PROJECT_REPO}" \ + list --branch "${BRANCH}" \ + --workflow "${WORKFLOW_NAME}" \ + --json event,status,databaseId > runs.json + # Filter on 'push' events to main (merged PRs) that have completed + jq --compact-output \ + '[ .[] | select(.event == "push") | select(.status == "completed") ]' \ + runs.json > pushes.json + # Get id of latest build of wheels + RUN_ID=$( + jq --compact-output \ + 'sort_by(.databaseId) | reverse | .[0].databaseId' pushes.json + ) + gh run --repo "${PROJECT_REPO}" \ + download "${RUN_ID}" --name "${ARTIFACT_NAME}" + + mkdir dist + mv *.whl dist/ + ls -l dist/ + + - name: Install anaconda-client + run: | + python -m pip install --upgrade pip setuptools wheel + # c.f. https://github.com/Anaconda-Platform/anaconda-client/issues/540 + python -m pip install git+https://github.com/Anaconda-Server/anaconda-client + python -m pip list + + - name: Upload wheels to Anaconda Cloud as nightlies + run: | + anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} upload \ + --user scipy-wheels-nightly \ + dist/matplotlib-*.whl From 7dda3c6451dc88cecf2a434bc01710054c55bb92 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 30 Mar 2022 11:22:38 -0500 Subject: [PATCH 2/2] DOC: Add instructions on installing nightly build wheels Describe that the wheels are available on the scipy-wheels-nightly Anaconda Cloud organization (https://anaconda.org/scipy-wheels-nightly) and that a user should use --index-url to install from this package index. --- doc/users/installing/index.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/users/installing/index.rst b/doc/users/installing/index.rst index 10431d0cd465..a2ce7cea6790 100644 --- a/doc/users/installing/index.rst +++ b/doc/users/installing/index.rst @@ -80,6 +80,20 @@ you can install Matplotlib via your package manager, e.g.: .. _install_from_source: +========================== +Installing a nightly build +========================== + +Matplotlib makes nightly development build wheels available on the +`scipy-wheels-nightly Anaconda Cloud organization +`_. +These wheels can be installed with ``pip`` by specifying scipy-wheels-nightly +as the package index to query: + +.. code-block:: sh + + python -m pip install --upgrade --index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple matplotlib + ====================== Installing from source ======================