From 5c66fe9e4daecc20ccd61b00ae6bfc5c97098311 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Sat, 25 Jun 2022 23:44:42 -0500 Subject: [PATCH] CI: Remove old scipy-wheels-nightly uploads to ensure space Remove all but the last "${N_LATEST_UPLOADS}" package version uploads to the matplotlib scipy-wheels-nightly index to ensure space. To do this, rely on the output form of `anaconda show` to be able to filter on the item delimiter character sequence for each version currently uploaded. As an explicit example: ``` $ anaconda show scipy-wheels-nightly/matplotlib Using Anaconda API: https://api.anaconda.org Name: matplotlib Summary: Access: public Package Types: pypi Versions: + 3.6.0.dev2553+g3245d395d9 + 3.6.0.dev2569+g3522217386 + 3.6.0.dev2573+g3eadeacc06 To install this package with pypi run: pip install -i https://pypi.anaconda.org/scipy-wheels-nightly/simple matplotlib ``` shows that by filtering on '+' and then stripping ' + ' one can obtain a newline separated list of all package uploads, where they _most recent_ uploads are listed last. After stripping off the "${N_LATEST_UPLOADS}" lines that correspond to the package versions to keep for testing, the remaining (older) package uploads can be removed with `anaconda remove`. Resolves the space problem in https://github.com/matplotlib/matplotlib Issue 22757 --- .github/workflows/nightlies.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml index 211873ce6189..d8acb3a135c6 100644 --- a/.github/workflows/nightlies.yml +++ b/.github/workflows/nightlies.yml @@ -63,3 +63,23 @@ jobs: --user scipy-wheels-nightly \ --skip-existing \ dist/matplotlib-*.whl + + - name: Remove old uploads to save space + shell: bash + run: | + N_LATEST_UPLOADS=5 + + # Remove all _but_ the last "${N_LATEST_UPLOADS}" package versions + # N.B.: `anaconda show` places the newest packages at the bottom of the output + # of the 'Versions' section and package versions are preceded with a ' + '. + anaconda show scipy-wheels-nightly/matplotlib &> >(grep '+') | \ + sed 's/.* + //' | \ + head --lines "-${N_LATEST_UPLOADS}" > remove-package-versions.txt + + if [ -s remove-package-versions.txt ]; then + while LANG=C IFS= read -r package_version ; do + anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} remove \ + --force \ + "scipy-wheels-nightly/matplotlib/${package_version}" + done