Skip to content

Commit

Permalink
merge done
Browse files Browse the repository at this point in the history
  • Loading branch information
sannies committed Jan 13, 2025
2 parents d4b093a + 1ab4cba commit 0ee4d43
Show file tree
Hide file tree
Showing 79 changed files with 7,290 additions and 4,635 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @pbs/core-services
34 changes: 34 additions & 0 deletions .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release PyCaption on GitHub

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"

jobs:
call-unit-tests-workflow:
name: Run unit tests
uses: pbs/pycaption/.github/workflows/unit_tests.yml@main
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}

create-release:
name: Release PyCaption on GitHub
needs: call-unit-tests-workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Extract release notes for current version
env:
TAG: ${{ github.ref }}
run: |
sudo apt-get install -y --no-install-recommends pandoc
pandoc docs/changelog.rst -f rst -t gfm -o changelog.md
sed -n "/## ${TAG#refs/tags/}/,/## /p" changelog.md | sed -e "/## /d" >> notes.md
- name: Create release on GitHub
run: gh release create ${{ github.ref }} --notes-file notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish PyCaption to PyPI

on: workflow_dispatch

jobs:
call-unit-tests-workflow:
name: Run unit tests
uses: pbs/pycaption/.github/workflows/unit_tests.yml@main
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}

build-n-publish:
name: Build and publish PyCaption to PyPI
needs: call-unit-tests-workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
python -m pip install --upgrade twine
- name: Build package
run: python -m build
timeout-minutes: 10

- name: Publish package on PyPI
run: python -m twine upload --verbose dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/release_test_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish PyCaption to Test PyPI

on: workflow_dispatch

jobs:
call-unit-tests-workflow:
name: Run unit tests
uses: ./.github/workflows/unit_tests.yml
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}

build-n-publish:
name: Build and publish PyCaption to Test PyPI
needs: call-unit-tests-workflow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
python -m pip install --upgrade twine
- name: Build package
run: python -m build
timeout-minutes: 10

- name: Publish package on Test PyPI
run: python -m twine upload --verbose dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
TWINE_REPOSITORY: "testpypi"
79 changes: 79 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Unit Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_call:
secrets:
SLACK_BOT_TOKEN:
required: true
SLACK_CHANNEL_ID:
required: true
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["py38", "py39", "py310", "py311", "py312"]

steps:
- uses: actions/checkout@v2

- name: Run Test
id: tests
run: |
./run_tests.sh test_${{ matrix.python-version }}
continue-on-error: true

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: test-report-${{ matrix.python-version }}
path: junit.xml

- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report-${{ matrix.python-version }}
path: coverage.xml

- name: Add context info to env
run: |
sudo apt-get install -y --no-install-recommends libxml-xpath-perl
COVERAGE=`xpath -q -e "floor(/coverage/@line-rate * 100)" coverage.xml`
FAILED_AMOUNT=`xpath -q -e "number(/testsuites/testsuite/@failures)" junit.xml`
SKIPPED_AMOUNT=`xpath -q -e "number(/testsuites/testsuite/@skipped)" junit.xml`
PASSED_AMOUNT=`xpath -q -e "/testsuites/testsuite/@tests - $SKIPPED_AMOUNT - $FAILED_AMOUNT" junit.xml`
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
echo "FAILED_AMOUNT=$FAILED_AMOUNT" >> $GITHUB_ENV
echo "PASSED_AMOUNT=$PASSED_AMOUNT" >> $GITHUB_ENV
${{ contains(github.ref, 'tags/') }} \
&& BRANCH='refs/heads/main' \
|| BRANCH=${{ github.head_ref || github.ref }}
echo "BRANCH=${BRANCH#refs/*/}" >> $GITHUB_ENV
- name: Notify if test FAILED
uses: archive/[email protected]
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL_ID }}
slack-text: ":boom: *${{ env.FAILED_AMOUNT }}* Pycaption test(s) failed for Python *${{ matrix.python-version }}* on the *${{ env.BRANCH }}* branch (triggered by *${{ github.actor }}*)"
if: steps.tests.outcome == 'failure' && !github.event.pull_request.head.repo.fork

- name: Mark test failure
run: exit 1
if: steps.tests.outcome == 'failure'

- name: Slack notify tests PASSED
uses: archive/[email protected]
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel: ${{ secrets.SLACK_CHANNEL_ID }}
slack-text: ":rocket: All (*${{ env.PASSED_AMOUNT }}*) Pycaption tests passed for Python *${{ matrix.python-version }}* covering *${{ env.COVERAGE }}%* of code on the *${{ env.BRANCH }}* branch (triggered by *${{ github.actor }}*)"
if: steps.tests.outcome == 'success' && !github.event.pull_request.head.repo.fork
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pip-log.txt
# Unit test / coverage reports
.coverage
.tox
coverage.xml

#Translations
*.mo
Expand All @@ -30,3 +31,13 @@ pip-log.txt

# Sphinx documentation build
docs/_build

# PyCharm files
.idea/

# Environments
env/
venv/

# Pyenv files
.python-version
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: debug-statements

- repo: git://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
args: [
'--exclude=tests/fixtures*',
'--ignore=W503,C901',
'--max-line-length=80',
]
15 changes: 15 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.11"

# Build from the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Explicitly set the version of Python and its requirements
python:
install:
- requirements: docs/requirements.txt
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

Loading

0 comments on commit 0ee4d43

Please sign in to comment.