Skip to content

Commit

Permalink
Merge pull request #6 from mikesongming/feat/4-github-action-ci
Browse files Browse the repository at this point in the history
wheels.yml on macos passed
  • Loading branch information
mikesongming authored Jun 17, 2022
2 parents ad4bc03 + d627902 commit d34f610
Show file tree
Hide file tree
Showing 38 changed files with 745 additions and 43 deletions.
1 change: 1 addition & 0 deletions .changelog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.gitignore
6 changes: 6 additions & 0 deletions .changelog/news/2.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
A SunEarthAnalyzer API wrapping pybind11 C++ extension and CI/CD facilities.
> - SPA sun position algorithm implemented;
> - Pytest empowered tests;
> - pre-commit hooks, including mypy,isort,black,flake
> - docs ready to gh-deploy by mkdocs, with the material theme
> - tox enabled Devops pipeline
36 changes: 36 additions & 0 deletions .changelog/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% if top_line %}
{{ top_line }}
{{ top_underline * ((top_line)|length)}}
{% elif versiondata.name %}
{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
{{ top_underline * ((versiondata.name + versiondata.version + versiondata.date)|length + 4)}}
{% else %}
{{ versiondata.version }} ({{ versiondata.date }})
{{ top_underline * ((versiondata.version + versiondata.date)|length + 3)}}
{% endif %}
{% for section, _ in sections.items() %}
{%- if section %}{{section}}{% endif -%}

{% if sections[section] %}
{% for category, val in definitions.items() if category in sections[section]%}
### {{ definitions[category]['name'] }}

{% if definitions[category]['showcontent'] %}
{% for text, values in sections[section][category].items() %}
- {{ values|join(', ') }} {{ text }}
{% endfor %}
{% else %}
- {{ sections[section][category]['']|join(', ') }}
{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes.

{% else %}
{% endif %}

{% endfor %}
{% else %}
No significant changes.

{% endif %}
{% endfor %}
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Report a bug
about: Create a bug report to fix an existing issue.
title: ''
labels: ''
labels: 'bug'
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature request
about: Suggest new functionality for this project.
title: ''
labels: ''
labels: 'enhancement'
assignees: ''

---
Expand Down
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/maintenance_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Maintenance report
about: Configuration and Pipeline upgrades
title: ''
labels: 'maintenance'
assignees: ''

---

**Thank you in advance for helping us to improve this library!** Your attention to detail here is greatly appreciated and will help us respond as quickly as possible. To avoid duplicates, please search existing Issues before submitting one here.

By submitting an Issue to this repository, you agree to the terms within the [Code of Conduct](https://github.com/mikesongming/SE-Geometry/blob/master/CODE-OF-CONDUCT.md).

### Describe the configuration and/or pipeline adjustment you'd like to make

> A clear and concise description of what the difference is.
### Describe the ideal solution

> A clear and concise description of what you want to happen.
## Alternatives and current work-arounds

> A clear and concise description of any alternatives you've considered or any work-arounds that are currently in place.
### Additional context

> Add any other context or screenshots about the feature request here.
27 changes: 27 additions & 0 deletions .github/issue-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# enable chatOPs
mode: chatops

# branchName: short
branchName: '${issue.number}-${issue.title[0,64]}'
branches:
- label: bug
prefix: fix/
- label: enhancement
prefix: feat/
- label: maintenance
prefix: maint/
- label: documentation
prefix: doc/
- label: '*'
skip: true

# open PR related to the create branch
openPR: true
copyIssueDescriptionToPR: true
copyIssueLabelsToPR: true
copyIssueAssigneeToPR: true
copyIssueProjectsToPR: true
copyIssueMilestoneToPR: true

# close Issue after merging PR
autoCloseIssue: true
64 changes: 64 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
lables:
- feat
- feature
- enhancement
- title: '💣 Breaking Change'
label: breakthrough
- title: '🐛 Bug Fixes'
labels:
- bug
- fix
- bugfix
- title: '📝 Documentation'
labels:
- doc
- docs
- documentation
- title: '🔨 Maintenance'
labels:
- chore
- maint
- maintenance

include-labels:
- feat
- feature
- enhancement
- breakthrough
- bug
- fix
- bugfix
- doc
- docs
- documentation
- chore
- maint
- maintenance

change-template: '- $TITLE (#$NUMBER)'
change-title-escapes: '\<*_&`@#' # add # and @ to disable mentions, and add ` to disable code blocks.

version-resolver:
major:
labels:
- 'major'
- breakthrough
minor:
labels:
- 'minor'
- 'enhancement'
patch:
labels:
- 'patch'
- 'bug'
- 'maintenance'
default: patch

template: |
## What’s Changed
$CHANGES
20 changes: 20 additions & 0 deletions .github/scripts/extract_sdist_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

LATEST_TAR_GZ=`ls -t dist/*.tar.gz | head -n 1`
if [ -f "$LATEST_TAR_GZ" ]; then
echo "Latest sdist $LATEST_TAR_GZ found."
else
echo "NO sdist found!"
return 1
fi

LATEST_PKG_TAG=`basename $LATEST_TAR_GZ | sed 's/.tar.gz//' | sed 's/_/-/'`

LATEST_PKG_VERSION=`echo $LATEST_PKG_TAG | awk -F '-' '{print $NF}'`

PKG_NAME=`echo $LATEST_PKG_TAG | sed "s/-$LATEST_PKG_VERSION//"`

echo "pkg_sdist=${LATEST_TAR_GZ}" >> $GITHUB_ENV
echo "pkg_tag=${LATEST_PKG_TAG}" >> $GITHUB_ENV
echo "pkg_version=${LATEST_PKG_VERSION}" >> $GITHUB_ENV
echo "pkg_name=${PKG_NAME}" >> $GITHUB_ENV
19 changes: 19 additions & 0 deletions .github/scripts/extract_wheel_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

LINUX_WHEEL=`ls wheelhouse/*.whl | grep manylinux | head -n 1`
if [ -f "$LINUX_WHEEL" ]; then
echo "Linux wheel $LINUX_WHEEL found."
else
echo "NO linux wheel found!"
return 1
fi

LINUX_PKG_TAG=`basename $LINUX_WHEEL | awk -F '-cp' '{print $1}' | sed 's/_/-/'`

LINUX_PKG_VERSION=`echo $LINUX_PKG_TAG | awk -F '-' '{print $NF}'`

LINUX_PKG_NAME=`echo $LINUX_PKG_TAG | sed "s/-$LINUX_PKG_VERSION//"`

echo "pkg_tag=${LINUX_PKG_TAG}" >> $GITHUB_ENV
echo "pkg_version=${LINUX_PKG_VERSION}" >> $GITHUB_ENV
echo "pkg_name=${LINUX_PKG_NAME}" >> $GITHUB_ENV
151 changes: 151 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Build Packages
# Build Source and Wheel Packages

on:
workflow_call:
inputs:
need_wheel:
default: true
required: false
type: boolean
need_sdist:
default: true
required: false
type: boolean
outputs:
pkg_name:
description: name of sdist
value: ${{ jobs.build_sdist.outputs.pkg_name }}
pkg_version:
description: version of sdist
value: ${{ jobs.build_sdist.outputs.pkg_version }}

defaults:
run:
shell: bash

jobs:
build_wheel:
name: 🚀 CIBW (${{matrix.buildplat[0]}}_${{matrix.python}})
if: ${{ inputs.need_wheel }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
fail-fast: false
matrix:
buildplat:
# - [ubuntu-20.04, manylinux_x86_64]
- [macos-11, macosx_x86_64]
# - [macos-12, macosx_x86_64]
# - [windows-2019, win_amd64]
python:
- 'cp310'
steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Build wheel with CIBW
uses: pypa/cibuildwheel@v2.6.0
env:
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
CIBW_TEST_REQUIRES: pytest pytest-cov
CIBW_TEST_COMMAND: pytest -v --no-cov {package}/tests

- name: Upload wheel as Artifact
if: ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: >-
wheel_${{ startsWith(matrix.buildplat[0], 'ubuntu') && 'linux' ||
(
startsWith(matrix.buildplat[0], 'macos') && 'macos' || 'windows'
)
}}
path: wheelhouse/*.whl
retention-days: 3

collect_wheels:
name: 🫘 collect wheels
if: ${{ inputs.need_wheel }}
runs-on: ubuntu-latest
needs: build_wheel
steps:
# - name: Download linux wheel
# uses: actions/download-artifact@v3
# with:
# name: wheel_linux
# path: wheelhouse

- name: Download macos wheel
uses: actions/download-artifact@v3
with:
name: wheel_macos
path: wheelhouse

# - name: Download windows wheel
# uses: actions/download-artifact@v3
# with:
# name: wheel_windows
# path: wheelhouse

- name: Upload collected wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: wheelhouse/*.whl
retention-days: 3

- uses: geekyeggo/delete-artifact@v1
with:
name: |
wheel_macos
# wheel_linux
# wheel_windows
failOnError: false

build_sdist:
name: 📦 build sdist
if: ${{ inputs.need_sdist }}
runs-on: ubuntu-latest
outputs:
pkg_name: ${{ steps.save.outputs.pkg_name }}
pkg_version: ${{ steps.save.outputs.pkg_version }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist Package with Extension
run: |
python -m build -s
- name: Extract sdist package info
run: |
bash .github/scripts/extract_sdist_info.sh
- name: Upload sdist as Artifact
if: ${{ success() }}
uses: actions/upload-artifact@v3
with:
name: sdist
path: ${{ env.pkg_sdist }}
retention-days: 3

- name: Write outputs
id: save
run: |
echo "::set-output name=pkg_name::${{ env.pkg_name }}"
echo "::set-output name=pkg_version::${{ env.pkg_version }}"
Loading

0 comments on commit d34f610

Please sign in to comment.