Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update framework #77

Merged
merged 15 commits into from
Jul 19, 2023
43 changes: 34 additions & 9 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
# GitHub Actions

## Building the Conda Package: [conda_build_and_publish.yml](https://github.com/paskino/qt-elements/blob/main/.github/workflows/conda_build_and_publish.yml)
This github action builds and tests the conda package, by using the [conda-package-publish-action](https://github.com/paskino/conda-package-publish-action)
Runs automatically on every commit via [test.yml](./test.yml).

When pushing to main *all* variants are built and tested.
## Testing

When making an [annotated](https://git-scm.com/book/en/v2/Git-Basics-Tagging) tag, *all* variants are built, tested and published to the [paskino conda channel for qt-elements](https://anaconda.org/paskino/eqt/files). This package is noarch.
Runs `pytest`.

When opening or modifying a pull request to main, a single variant is built and tested, but not published. This variant is `python=3.7` and `numpy=1.18`.
## Building

## Building the PyPi Package: [pypi_publish.yml](https://github.com/paskino/qt-elements/blob/main/.github/workflows/pypi_publish.yml)
This github action builds the pypi package, by using the [deploy-pypi action](https://github.com/casperdcl/deploy-pypi).
Runs automatically after tests (above) succeed.

When pushing to main it is built and checked.
Builds binary (`*.whl`) & source (`*.tar.gz`) distributions.

When making an [annotated](https://git-scm.com/book/en/v2/Git-Basics-Tagging) tag, it is built and published to the [PyPi](https://pypi.org/project/eqt/#description).
## Releasing

Runs automatically -- when an annotated tag is pushed -- after builds (above) succeed.

Publishes to [PyPI](https://pypi.org/project/eqt).

:warning: The annotated tag's `title` must be `Version <number without v-prefix>` (separated by a blank line) and the `body` must contain release notes, e.g.:

```bash
git tag v1.33.7 -a
```

```md
Version 1.33.7

<body>
```

The `<body>` will be used in the changelog (below).

### Changelog

See <https://github.com/TomographicImaging/eqt/releases>, or offline:

```bash
git config --global alias.changelog 'for-each-ref --sort=-*authordate --format="# %(contents:subject)%0a%(contents:body)" refs/tags'
git changelog
```
27 changes: 0 additions & 27 deletions .github/workflows/conda_build_and_publish.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/pypi_publish.yml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could rename this and the filename to reflect that it both tests and possibly deploys?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Test
name: Test & Deploy

on:
push:
pull_request:
Comment on lines +3 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to specify the branch (main)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's better not to

jobs:
test:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: py${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.11]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the binaries built be only available for Python 3.7 and 3.11? In such a case, I'd like to be sure that these are available for all Python versions compatible with CIL, which are from 3.8 to 3.10!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, binaries are built for all python versions. CI unit tests are only run for min & max supported versions.

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: pip install -U .[dev]
- run: pytest
deploy:
needs: [test]
name: PyPI Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
id: changes
name: Check annotated tag
run: |
title=$(git for-each-ref --format="%(contents:subject)" ${GITHUB_REF})
body=$(git for-each-ref --format="%(contents:body)" ${GITHUB_REF})
tag="${GITHUB_REF#refs/tags/}"
if test "$title" = "Version ${tag#v}" -a -n "$body"; then
echo "title=$title" >> "$GITHUB_OUTPUT"
echo "body=$body" >> "$GITHUB_OUTPUT"
else
echo "::error title=Missing tag annotation::$tag"
changelog=$(git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD)
cat <<EOF >> "$GITHUB_STEP_SUMMARY"
# Missing tag annotation
## Fix
See <https://github.com/TomographicImaging/eqt/tree/main/.github/workflows#releasing>.
## Suggested body
$changelog
EOF
exit 1
fi
- id: dist
uses: casperdcl/deploy-pypi@v2
casperdcl marked this conversation as resolved.
Show resolved Hide resolved
with:
build: true
password: ${{ secrets.EQT_SECRET_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
skip_existing: true # allow for annotated tag amendments
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
name: Release
run: >
gh release create
--title "${{ steps.changes.outputs.title }}"
--notes "${{ steps.changes.outputs.body }}"
"${GITHUB_REF#refs/tags/}"
dist/${{ steps.dist.outputs.whl }}
dist/${{ steps.dist.outputs.targz }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
eqt/version.py
*.py[cod]
__pycache__/
/eqt/_dist_ver.py
/*.egg*/
/build/
/dist/
/.coverage*
/coverage.xml
/.pytest_cache/
66 changes: 0 additions & 66 deletions CHANGELOG.md

This file was deleted.

Loading