Skip to content

Commit

Permalink
Use hatch envs and clean up workflows (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Oct 13, 2022
1 parent 0ebbc0b commit e1af67d
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 106 deletions.
11 changes: 0 additions & 11 deletions .github/actions/common/action.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
check_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup
uses: ./.github/actions/common

- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install Dependencies
shell: bash
run: |
pip install -e .
- name: Check Release
uses: ./.github/actions/check-release
with:
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ jobs:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup
uses: ./.github/actions/common

- name: Install the Extra Python dependencies
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install Dependencies
shell: bash
run: |
sudo apt-get install pandoc
pip install pypandoc
pip install -e .
pip install pandoc
- name: Generate the Changelog
env:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
prep_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install Dependencies
shell: bash
run: |
pip install -e .
- name: Prep Release
id: prep-release
uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ jobs:
publish_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install Dependencies
shell: bash
run: |
pip install -e .
- name: Populate Release
id: populate-release
uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
Expand Down
82 changes: 24 additions & 58 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches: ["main"]
pull_request:

defaults:
run:
shell: bash -eux {0}

jobs:
# Run "pre-commit run --all-files --hook-stage=manual"
pre-commit:
Expand All @@ -28,7 +32,6 @@ jobs:
check-links:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
Expand All @@ -42,35 +45,34 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.10"]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup
uses: ./.github/actions/common

- name: Install the Test dependencies
run: |
pip install -e .[test] codecov
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Run the tests with coverage on Ubuntu
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python -m pytest -vv --cov jupyter_releaser --cov-branch --cov-report term-missing:skip-covered
hatch run cov:test
pip install codecov
codecov
- name: Run the tests on Windows and macOS
- name: Run the tests on Windows and MacOS
if: ${{ matrix.os != 'ubuntu-latest' }}
run: |
python -m pytest -vv -s
run: hatch run test:test -s

- name: Verify the Generate Changelog Action
if: ${{ matrix.os == 'ubuntu' }}
env:
generate-changelog:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RH_REPOSITORY: jupyter-server/jupyter_releaser
RH_SINCE: v0.10.2
RH_UNTIL: v0.10.3
run: |
set -eux
pip install -e .
python -m jupyter_releaser.actions.generate-changelog
cat CHANGELOG_ENTRY.md
# Check for version entry contents
Expand All @@ -85,55 +87,19 @@ jobs:
python -m jupyter_releaser.actions.generate-changelog
cat CHANGELOG_ENTRY.md
- name: Coverage
run: |
codecov
docs:
runs-on: ubuntu-20.04
timeout-minutes: 10
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup
uses: ./.github/actions/common

- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
activate-environment: jupyter_releaser_documentation
environment-file: docs/environment.yml
python-version: "3.10"
auto-activate-base: false

- name: Cache conda
uses: actions/cache@v2
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{
hashFiles('docs/environment.yml') }}

- name: Build docs
run: |
set -eux
pip install .
pushd docs
make html
popd
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- run: hatch run docs:build

check_local_actions:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup
uses: ./.github/actions/common
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: prep-release
uses: ./.github/actions/prep-release
Expand Down
13 changes: 0 additions & 13 deletions docs/environment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/background/theory.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Detailed workflows are available to draft a changelog, draft a release, publish
- Adds a commit that includes the hashes of the dist files
- Creates an annotated version tag in standard format
- If given, bumps the version using the post version spec. he post version
spec can also be given as a setting, [Write Releaser Config Guide](../how_to_guides/write_config.html#automatic-dev-versions).
spec can also be given as a setting, [Write Releaser Config Guide](../how_to_guides/write_config.md).
- Verifies that the SHA of the most recent commit has not changed on the target
branch, preventing a mismatch of release commit.
- Pushes the commits and tag to the target `branch`
Expand Down
4 changes: 2 additions & 2 deletions docs/source/how_to_guides/convert_repo_from_releaser.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Follow the steps below to convert a repository to use Jupyter Releaser for relea

## Prerequisites

See [checklist](#Checklist-for-Adoption) below for details:
See checklist below for details:

- Markdown changelog
- Bump version configuration (if using Python), for example [tbump](https://github.com/dmerejkowsky/tbump)
Expand Down Expand Up @@ -94,7 +94,7 @@ _Note_ The check release action needs `contents: write` [permission](https://doc

- [ ] Set up a fork of `jupyter-releaser` if you have not yet done so.
- [ ] Run through the release process, targeting this repo and the appropriate branch
- [ ] Optionally add [configuration](#Configuration) to the target repository if non-standard options or hooks are needed.
- [ ] Optionally add configuration to the target repository if non-standard options or hooks are needed.
- [ ] If desired, add `check_release` job, changelog, and `tbump` support to other active release branches
- [ ] Try out the `Draft Changelog` and `Draft Release` process against a fork of the target repo first so you don't accidentally push tags and GitHub releases to the source repository.
- [ ] Try the `Publish Release` process using a prerelease version before publishing a final version.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/how_to_guides/convert_repo_from_repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Follow the steps below to convert a repository to use Jupyter Releaser for relea

## Prerequisites

See [checklist](#Checklist-for-Adoption) below for details:
See [hecklist below for details:

- Markdown changelog
- Bump version configuration (if using Python), for example [hatch](https://hatch.pypa.io/latest/)
Expand Down Expand Up @@ -76,7 +76,7 @@ _Note_ The check release action needs `contents: write` [permission](https://doc

- [ ] Copy `prep-release.yml` and `publish-release.yml` from the `example-workflows` folder in this repository.

- [ ] Optionally add [configuration](#Configuration) to the repository if non-standard options or hooks are needed.
- [ ] Optionally add configuration to the repository if non-standard options or hooks are needed.

- [ ] If desired, add `check_release` job, changelog, and `hatch` support to other active release branches

Expand Down
2 changes: 1 addition & 1 deletion jupyter_releaser/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def ensure_mock_github():
import fastapi # noqa
import univcorn # type: ignore # noqa
except ImportError:
run(f"{python} -m pip install fastapi uvicorn")
run(f"'{python}' -m pip install fastapi uvicorn")

proc = subprocess.Popen([python, "-m", "uvicorn", "jupyter_releaser.mock_github:app"])

Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ file = "README.md"
content-type = "text/markdown"

[project.optional-dependencies]
docs = [
"sphinx",
"sphinx-copybutton",
"pip",
"myst-parser",
"pydata_sphinx_theme",
"numpydoc",
"sphinx-click",
]
test = [
"coverage",
"fastapi",
Expand All @@ -59,6 +68,25 @@ jupyter-releaser = "jupyter_releaser.cli:main"
path = "jupyter_releaser/__init__.py"
validate-bump = false

[tool.hatch.envs.docs]
features = ["docs"]
[tool.hatch.envs.docs.scripts]
build = "make -C docs html SPHINXOPTS='-W'"

[tool.hatch.envs.test]
features = ["test"]
[tool.hatch.envs.test.scripts]
test = "python -m pytest -vv {args}"
nowarn = "python -m pytest -vv -W default {args}"

[tool.hatch.envs.cov]
features = ["test"]
dependencies = ["coverage", "pytest-cov"]
[tool.hatch.envs.cov.env-vars]
ARGS = "-vv --cov jupyter_releaser --cov-branch --cov-report term-missing:skip-covered"
[tool.hatch.envs.cov.scripts]
test = "python -m pytest $ARGS --cov-fail-under 80 {args}"

[tool.jupyter-releaser.hooks]
after-populate-release = "bash ./.github/scripts/bump_tag.sh"

Expand Down
8 changes: 4 additions & 4 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: 2
sphinx:
configuration: docs/source/conf.py
conda:
environment: docs/environment.yml
python:
version: "3.8"
version: 3.8
install:
# install jupyter_releaser itself
# install itself with pip install .
- method: pip
path: .
extra_requirements:
- docs

0 comments on commit e1af67d

Please sign in to comment.