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

chore: Migrate CI & CD to GitHub Actions #322

Merged
merged 18 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 0 additions & 158 deletions .github/build.main.yml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# ref: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows

name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
push:
branches:
- main

jobs:

# production build
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

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

- name: Install pypa/build
run: >-
python3 -m
pip install
wheel sdist setuptools_scm
--user

- name: Build a binary wheel and a source tarball
run: python3 setup.py sdist bdist_wheel

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/


# This will be triggered only when a tag is pushed
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/stock-indicators

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:

- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


# This will be triggered everytime when commit is pushed on main branch
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: pypi-test
url: https://test.pypi.org/p/stock-indicators

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:

- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
10 changes: 3 additions & 7 deletions .github/workflows/docs-test-a11y.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Website

on:
pull_request:
branches: [main]
Expand All @@ -10,18 +11,13 @@ env:
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
testing:
test:
name: test a11y
runs-on: ubuntu-latest

steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '16'
uses: actions/checkout@v4

- name: Install Ruby
uses: ruby/setup-ruby@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-test-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:
run: |
htmlproofer _site \
--no-enforce-https \
--ignore-status-codes "0,403,406,408,429,503,999" \
--ignore-status-codes "0,302,403,406,408,429,503,999" \
--swap-urls "https\://python.stockindicators.dev:http\://127.0.0.1:4000" \
--ignore-urls "/fonts.gstatic.com/"
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Stock Indicators for Python

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.8", "3.12"]
dotnet-version: ["6.0.x", "8.0.x"]

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install -r requirements-test.txt

- name: Run Tests
run: |
pytest -vr A tests
16 changes: 6 additions & 10 deletions docs/pages/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ See [GitHub Pages documentation](https://docs.github.com/en/pages/setting-up-a-g
bundle install
bundle exec jekyll serve

# then open site on http://127.0.0.1:4000
# then open site on http://127.0.0.1:4000,
# or use `bundle exec jekyll serve -o -l` to auto-open, livereload
```

When adding or updating indicators:
Expand Down Expand Up @@ -128,22 +129,17 @@ If you want to contribute administratively, do code reviews, or provide general

## Versioning

We use the `GitVersion` tool for [semantic versioning](https://semver.org). It is mostly auto generated in the [Azure DevOps build](https://dev.azure.com/skender/Stock.Indicators/_build?definitionId=26).
We use the `setuptools_scm` tool for [semantic versioning](https://semver.org). It detects the version number from `git tag` in the [GitHub Actions build](https://github.com/DaveSkender/Stock.Indicators.Python/deployments/pypi).

Type | Format | Description
------------ | ------ | -----------
Major | `x.-.-` | A significant deviation with major breaking changes.
Minor | `-.x.-` | A new feature, usually new non-breaking change, such as adding an indicator. Minor breaking changes may occur here and are denoted in the [release notes](https://github.com/DaveSkender/Stock.Indicators.Python/releases).
Patch | `-.-.x` | A small bug fix, chore, or documentation change.
Increment | `-.-.-+x` | Intermediate commits between releases.

This only needs to be done on the merge to `main` when the Pull Request is committed, so your feature branch does not need to include this as it will get squashed anyway.

- Adding `+semver: major` as a PR merge commit message will increment the major x.-.- element
- Adding `+semver: minor` as a PR merge commit message will increment the minor -.x.- element
- Adding `+semver: patch` as a PR merge commit message will increment the minor -.-.x element. Patch element auto-increments, so you'd only need to do this to override the next value.

A Git `tag`, in accordance with the above schema, is introduced automatically after deploying to PyPI and is reflected in the [Releases](https://github.com/DaveSkender/Stock.Indicators.Python/releases).
After one of our repository administrators creates a `git tag` on the `main` branch,
reflecting the new version number, the `PyPI` deployment workflow will start.
After the new package is published, they'll publicly post the [release record](https://github.com/DaveSkender/Stock.Indicators.Python/releases) with [automatically generated notes](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) and other information.

## License

Expand Down
11 changes: 0 additions & 11 deletions gitversion.yml

This file was deleted.

Loading
Loading