Skip to content

Commit

Permalink
Merge pull request #474 from shangyian/release-management
Browse files Browse the repository at this point in the history
Align dependency management + workflows for publishing and releasing
  • Loading branch information
shangyian authored Apr 27, 2023
2 parents 109447d + a6aa216 commit da3abc6
Show file tree
Hide file tree
Showing 24 changed files with 4,394 additions and 2,188 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/python-package.yml

This file was deleted.

85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release
on:
workflow_dispatch:
inputs:
library:
type: choice
description: Which library to bump
required: true
options:
- server
- client
bump:
type: choice
description: Hatch version bump rule
required: true
options:
- release
- major
- minor
- patch
- alpha
- beta
- rc
- post
- dev

jobs:
publish:
strategy:
fail-fast: false
matrix:
python-version: ['3.10']
runs-on: 'ubuntu-latest'
defaults:
run:
working-directory: ${{ github.event.inputs.library == 'server' && '.' || './client/python' }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- uses: pdm-project/setup-pdm@v3
name: Setup PDM
with:
python-version: ${{ matrix.python-version }}
architecture: x64
prerelease: true
enable-pep582: true

- name: Configure Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Bump release version with poetry and tag
run: |
hatch version ${{ github.event.inputs.bump }}
export NEW_VERSION=v$(hatch version)
export LIBRARY=${{ github.event.inputs.library }}
git commit -am "Bumping $LIBRARY to version $NEW_VERSION"
git tag -a $NEW_VERSION -m $NEW_VERSION
git push origin $NEW_VERSION
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}

- name: Publish to pypi
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
run: |
hatch build
hatch publish
- name: Create Github release
run: |
gh release create $(hatch version) --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/test-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run tests for DJ

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']

defaults:
run:
working-directory: './client/python'

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: pdm-project/setup-pdm@v3
name: Setup PDM
with:
python-version: ${{ matrix.python-version }}
architecture: x64
prerelease: true
enable-pep582: true
- name: Install dependencies
run: pdm install
- name: Linters
run: |
pdm run pre-commit run --all-files
- name: Test DJ ${{ matrix.library }} with pytest
run: |
export module=${{ matrix.library == 'server' && 'dj' || 'datajunction' }}
pdm run pytest --cov-fail-under=100 --cov=$module -vv tests/ --doctest-modules $module --without-integration --without-slow-integration
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run tests for DJ

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10']
library: ['client', 'server']

defaults:
run:
working-directory: ${{ matrix.library == 'server' && '.' || './client/python' }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: pdm-project/setup-pdm@v3
name: Setup PDM
with:
python-version: ${{ matrix.python-version }}
architecture: x64
prerelease: true
enable-pep582: true
- name: Install dependencies
run: pdm install
- name: Linters
run: |
pdm run pre-commit run --all-files
- name: Test DJ ${{ matrix.library }} with pytest
run: |
export module=${{ matrix.library == 'server' && 'dj' || 'datajunction' }}
pdm run pytest --cov-fail-under=100 --cov=$module -vv tests/ --doctest-modules $module --without-integration --without-slow-integration
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ ENV/

# MacOS
.DS_Store
.pdm-python
File renamed without changes.
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ docker-build:
docker-run:
docker compose up

test: pyenv
pytest --cov=dj --cov-report=html -vv tests/ --doctest-modules dj --without-integration --without-slow-integration ${PYTEST_ARGS}
test:
pdm run pytest --cov=dj --cov-report=html -vv tests/ --doctest-modules dj --without-integration --without-slow-integration ${PYTEST_ARGS}

integration: pyenv
pytest --cov=dj -vv tests/ --doctest-modules dj --with-integration --with-slow-integration
integration:
pdm run pytest --cov=dj -vv tests/ --doctest-modules dj --with-integration --with-slow-integration

clean:
pyenv virtualenv-delete dj
Expand All @@ -30,16 +30,16 @@ spellcheck:
codespell -L froms -S "*.json" dj docs/*rst tests templates

check:
pre-commit run --all-files
pdm run pre-commit run --all-files

version:
@poetry version $(v)
@git add pyproject.toml
@git commit -m "v$$(poetry version -s)"
@git tag v$$(poetry version -s)
@hatch version $(v)
@git add __about__.py
@git commit -m "Bumping to v$$(hatch version)"
@git tag v$$(hatch version)
@git push
@git push --tags
@poetry version
@hatch version

release:
@poetry publish --build
@hatch publish --build
1 change: 1 addition & 0 deletions client/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ MANIFEST
.venv*/
.conda*/
.python-version
.pdm-python
4 changes: 2 additions & 2 deletions client/python/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
check:
poetry run pre-commit run --all-files
pdm run pre-commit run --all-files

test:
poetry run pytest tests/ ${PYTEST_ARGS} --cov datajunction --cov-report term-missing --verbose
pdm run pytest --cov=datajunction --cov-report=html -vv tests/ --doctest-modules datajunction --without-integration --without-slow-integration ${PYTEST_ARGS}

version:
@poetry version $(v)
Expand Down
2 changes: 2 additions & 0 deletions client/python/__pypackages__/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Loading

0 comments on commit da3abc6

Please sign in to comment.