Skip to content

Minor tweaks to issue-opening bot #437

Minor tweaks to issue-opening bot

Minor tweaks to issue-opening bot #437

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Run weekly at 1:23 UTC
schedule:
- cron: '23 1 * * 0'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-stale-wheels:
name: "test stale wheel check"
# No secrets needed, so this one can also run on forks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
python-version: '3.14'
- name: Run the tests
run: uv run --with-requirements requirements.txt tests/test_check_stale_wheels.py
test:
name: "test upload via action"
runs-on: ubuntu-latest
if: github.repository == 'scientific-python/upload-nightly-action'
# Pull requests from forks and from Dependabot are not given secrets, so there
# they check that the action refuses to run rather than really uploading
env:
HAS_TOKEN: ${{ secrets.UPLOAD_TOKEN != '' }}
outputs:
uploaded: ${{ steps.record.outputs.uploaded }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# Don't rely on the action's path being in the current directory
with:
path: '_action_path'
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.x'
- name: Install the latest version of uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
- name: Build v0.0.1 wheel and sdist
run: |
uv tool run --from build pyproject-build --installer=uv --outdir ./dist _action_path/tests/test_package
- name: Verify the distribution
run: uv tool run twine check --strict dist/*
- name: List contents of sdist
run: python -m tarfile --list dist/test_package-*.tar.gz
- name: List contents of wheel
run: python -m zipfile --list dist/test_package-*.whl
- name: Test that an upload without a token is refused
id: no_token
if: env.HAS_TOKEN != 'true'
continue-on-error: true
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ''
- name: Check that the upload was refused
if: env.HAS_TOKEN != 'true'
env:
OUTCOME: ${{ steps.no_token.outcome }}
run: |
if [ "${OUTCOME}" != "failure" ]; then
echo "::error::the action did not refuse to upload without a token"
exit 1
fi
- name: Test upload
if: env.HAS_TOKEN == 'true'
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
- name: Test upload that forces removal first
if: env.HAS_TOKEN == 'true'
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
- name: Build v0.0.2 wheel and sdist
if: env.HAS_TOKEN == 'true'
run: |
# Bump version to avoid wheel name conflicts
sed -i 's/0.0.1/0.0.2/g' _action_path/tests/test_package/pyproject.toml
rm ./dist/*
uv tool run --from build pyproject-build --installer=uv --outdir ./dist _action_path/tests/test_package
- name: Test upload with non-main label
if: env.HAS_TOKEN == 'true'
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
anaconda_nightly_upload_labels: test
- name: Build v0.0.3 wheel and sdist
if: env.HAS_TOKEN == 'true'
run: |
# Bump version to avoid wheel name conflicts
sed -i 's/0.0.2/0.0.3/g' _action_path/tests/test_package/pyproject.toml
rm ./dist/*
uv tool run --from build pyproject-build --installer=uv --outdir ./dist _action_path/tests/test_package
- name: Test upload with multiple labels
if: env.HAS_TOKEN == 'true'
uses: ./_action_path/
with:
artifacts_path: dist
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
anaconda_nightly_upload_labels: dev,test
- name: Record whether anything was uploaded
id: record
run: echo "uploaded=${HAS_TOKEN}" | tee -a "${GITHUB_OUTPUT}"
cleanup:
runs-on: ubuntu-latest
needs: [test]
# Nothing to clean up when the uploads were skipped for lack of a token
if: needs.test.outputs.uploaded == 'true'
# Set required workflow secrets in the environment for additional security
# https://github.com/scientific-python/upload-nightly-action/settings/environments
environment:
name: remove-old-wheels
steps:
- name: Set up pixi
uses: prefix-dev/setup-pixi@f00437f565399d418b0acc85936d12c1fb668347 # v0.10.1
with:
run-install: false
- name: Remove test package upload
shell: pixi exec --spec anaconda-client -- bash -e {0}
run: |
anaconda --token ${{ secrets.ANACONDA_TOKEN }} remove \
--force \
"scientific-python-nightly-wheels/test-package"
report-failure:
needs: [test-stale-wheels, test, cleanup]
if: failure() && github.event_name == 'schedule'
permissions:
issues: write
uses: ./.github/workflows/report-failure.yml
with:
title: 'The scheduled CI run is failing'