Skip to content

Commit 0d8a131

Browse files
CI: Add test workflow for action
* Add simplest example package to tests so that it can be built for upload to Anaconda cloud as a test of the action. - Use setuptools as the build backend over something more obvious like hatchling given the simple nature of the test-package given that anaconda-client v1.12.0 doesn't understand valid metadata from PEP 518 build backends other than setuptools. c.f. anaconda/anaconda-client#676 * Add CI GitHub Action workflow to test the functionality of the action as shown in the README.
1 parent a2ba178 commit 0d8a131

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
# Run weekly at 1:23 UTC
9+
schedule:
10+
- cron: '23 1 * * 0'
11+
workflow_dispatch:
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
test:
19+
name: "test upload via action"
20+
runs-on: ubuntu-latest
21+
if: github.repository == 'scientific-python/upload-nightly-action'
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: '3.x'
30+
31+
- name: Install python-build and twine
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install build twine
35+
python -m pip list
36+
37+
- name: Build a wheel and a sdist
38+
run: |
39+
PYTHONWARNINGS=error,default::DeprecationWarning python -m build --outdir ./dist tests/test_package
40+
41+
- name: Verify the distribution
42+
run: twine check --strict dist/*
43+
44+
- name: List contents of sdist
45+
run: python -m tarfile --list dist/test-package-*.tar.gz
46+
47+
- name: List contents of wheel
48+
run: python -m zipfile --list dist/test_package-*.whl
49+
50+
- name: Test upload
51+
uses: ./
52+
with:
53+
artifacts_path: dist
54+
anaconda_nightly_upload_token: ${{ secrets.UPLOAD_TOKEN }}
55+
56+
cleanup:
57+
runs-on: ubuntu-latest
58+
needs: [test]
59+
# Set required workflow secrets in the environment for additional security
60+
# https://github.com/scientific-python/upload-nightly-action/settings/environments
61+
environment:
62+
name: remove-old-wheels
63+
64+
steps:
65+
- name: Install micromamba and anaconda-client
66+
uses: mamba-org/setup-micromamba@v1
67+
with:
68+
environment-name: remove-wheels
69+
create-args: >-
70+
python=3.11
71+
anaconda-client
72+
73+
- name: Remove test package upload
74+
shell: bash -l {0}
75+
run: |
76+
anaconda --token ${{ secrets.ANACONDA_TOKEN }} remove \
77+
--force \
78+
"scientific-python-nightly-wheels/test-package"

tests/test_package/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test README

tests/test_package/pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "test-package"
7+
version = "0.0.1"
8+
authors = [
9+
{ name="Scientifc Python Developers", email="[email protected]" },
10+
]
11+
description = "Test project for testing GitHub Action"
12+
readme = "README.md"
13+
requires-python = ">=3.8"

tests/test_package/src/test_package/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)