Skip to content

Commit

Permalink
Add workflows (#16)
Browse files Browse the repository at this point in the history
Adds workflows for GitHub actions:
- draft-release-notes.yml
- release.yml

Renames `build_test.yml` as `build-test.yml`.
Updates `build-test.yml` to execute on dispatch.
Updates developer docs with 'releases' info.
Adds hypo profile for CI

Also updates `.pre-commit-config.yml` with check-yaml and
flake8 pre-commits.
  • Loading branch information
maread99 authored May 25, 2022
1 parent ded4f0b commit c2c9e27
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name-template: 'v$NEXT_PATCH_VERSION 🎈'
tag-template: 'v$NEXT_PATCH_VERSION'
template: |
# What's Changed
$CHANGES
categories:
- title: 'New Features'
label: 'enhancement'
- title: 'Deprecation'
label: 'deprecation'
- title: 'Bug Fixes'
label: 'bug'
- title: 'Documentation'
label: 'documentation'
- title: 'Maintenance'
label: 'maintenance'
- title: 'Testing'
label: 'tests'
- title: 'Under the Bonnet'
label: 'code improvement'
- title: 'Continuous Integration'
label: 'CI'
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build and test

on:
workflow_dispatch:
push:
branches:
- master
Expand Down Expand Up @@ -46,4 +47,4 @@ jobs:
- name: Test with pytest
# fail it if doesn't pass test suite
run: |
pytest
pytest --hypothesis-profile ci
16 changes: 16 additions & 0 deletions .github/workflows/draft-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release Drafter

on:
push:
branches:
- master

# Updates next release notes on any push to master. Label a PR to categorize it
# in accordance with .github/release_drafter.yml.
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Workflow to upload a Python Package using Twine when a release is created
name: Release to PyPI

on:
release:
types: [released]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

# Verify can install from Test PyPI and import package
- name: Verify from Test PyPI
run: |
pip install --extra-index-url https://test.pypi.org/simple market_prices
python -c 'import market_prices;print(market_prices.__version__)'
pip uninstall -y market_prices
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

# Verify can install from PyPI and import package
- name: Verify from PyPI
run: |
pip install market_prices
python -c 'import market_prices;print(market_prices.__version__)'
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-yaml
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand All @@ -7,4 +11,9 @@ repos:
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.8
language_version: python3.8
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings]
29 changes: 29 additions & 0 deletions docs/developers/releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Releases

## Versioning
`market_prices` follows [Semantic Versioning](https://semver.org/). Releases should versioned as "v\<MAJOR>.\<MINOR>.\<PATCH>", for example:
* "v0.8.3"
* *v1.12.3"
* *v2.4.12"

## Draft release notes
Draft release notes for the next release should have been prepared by the [`draft-release-notes.yml` workflow](https://github.com/maread99/market_prices/blob/master/.github/workflows/draft-release-notes.yml). This uses the [Release Drafter action](https://github.com/marketplace/actions/release-drafter).

The latest draft should be at the top of the [releases page](https://github.com/maread99/market_prices/releases).

## Release workflow

### Last pre-release commit
* The last pre-release commit (or a prior commit) should include updating `market_prices.__init__.__version__` with the new version string.
* The last pre-release commit can optionally be tagged with the new version string.

### Cut a release
On publishing a release via GitHub the [`release.yml` workflow](https://github.com/maread99/market_prices/blob/master/.github/workflows/release.yml) will upload the distrubtion files to PyPI.

At the GitHub [releases page](https://github.com/maread99/market_prices/releases):
* The draft release notes should already be at the top of the page. Click the 'Draft a new release' button.
* Tag the release. Either choose the last commit's tag (if it was added) or create a new tag with the version string (this new tag will be attached to last commit).
* Make sure target is selected as 'Master'.
* Revise the draft release notes as requried.
* If the release includes new features, select the checkbox for 'Create a discussion for this release' (otherwise leave unchecked).
* Click the 'Publish Release' button.
9 changes: 7 additions & 2 deletions docs/tutorials_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ Contributions to `market_prices` are certainly welcome. If you are looking to co
* documentation specifications.

[testing.md](./developers/testing.md) :
* Data from yahoo API is unreliable for test suite
* Data from yahoo API is unreliable for test suite.

[releases.md](./developers/releases.md) :
* Versioning.
* Draft release notes.
* Release workflow.

[other_internals.md](./developers/other_internals.md) :
* Considerations for intervals that are not a factor of (sub)session length.
* `daterange.GetterIntraday.daterange_tight`
* `daterange.GetterIntraday.daterange_tight`
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from __future__ import annotations

from collections import abc
import os

from hypothesis import settings, HealthCheck
import exchange_calendars as xcals
import pandas as pd
import pytest
Expand All @@ -14,6 +16,9 @@
# pylint: disable=missing-any-param-doc,redefined-outer-name,
# pylint: unused-argument # `mock_now` has effect in background

settings.register_profile("ci", suppress_health_check=[HealthCheck.too_slow])
settings.load_profile(os.getenv("HYPOTHESIS_PROFILE", "default"))

# pylint: disable=no-member
base_intervals_sample = [
TDInterval.T1,
Expand Down

0 comments on commit c2c9e27

Please sign in to comment.