Skip to content

Commit

Permalink
Gzip reading and compression abstraction (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Sep 5, 2023
1 parent 5adf26f commit ff390c1
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 255 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# Continous Integration Workflows

This package implements different workflows for CI.
This package implements different workflows for CI, based on our organisation's common workflows.
They are organised as follows.

### Documentation

The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful).
It runs on `ubuntu-latest` and our lowest supported Python version, `Python 3.7`.

### Testing Suite

Tests are ensured in the `tests` workflow, which triggers on all pushes.
It runs on a matrix of all supported operating systems (ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, windows-latest and macos-latest) for all supported Python versions (currently `3.7`, `3.8`, `3.9` and `3.10`).
It runs on a matrix of all supported operating systems for all supported Python versions.

### Test Coverage

Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`.
It runs on `ubuntu-latest` & the lowest supported Python version (`Python 3.7`), and reports the coverage results of the test suite to `CodeClimate`,

It reports the coverage results of the test suite to `CodeClimate`.

### Regular Testing

A `cron` workflow triggers every Monday at 3am (UTC time) and runs the full testing suite, on all available operating systems and supported Python versions.
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically detected.
It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included.

### Publishing

Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the Github repository.
It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful.
Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the GitHub repository.
It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful.
64 changes: 4 additions & 60 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Runs all tests and pushes coverage report to codeclimate
name: Coverage

defaults:
run:
shell: bash

on: # Runs on all push events to master branch and any push related to a pull request
push:
branches:
Expand All @@ -13,59 +9,7 @@ on: # Runs on all push events to master branch and any push related to a pull r

jobs:
coverage:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix: # only lowest supported Python on latest ubuntu
os: [ubuntu-latest]
python-version: [3.7]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel

- name: Install package
run: python -m pip install '.[test]'

- name: Set up env for CodeClimate (push)
run: |
echo "GIT_BRANCH=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
if: github.event_name == 'push'

- name: Set up env for CodeClimate (pull_request)
env:
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$PR_HEAD_SHA" >> $GITHUB_ENV
if: github.event_name == 'pull_request'

- name: Prepare CodeClimate binary
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter;
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Run all tests
run: python -m pytest --cov-report xml --cov=sdds

- name: Push Coverage to CodeClimate
if: ${{ success() }} # only if tests were successful
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: ./cc-test-reporter after-build
uses: pylhc/.github/.github/workflows/coverage.yml@master
with:
src-dir: sdds
secrets: inherit
42 changes: 6 additions & 36 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,13 @@
# Runs all tests on master everyday at 10 am (UTC time)
# Runs all tests on master on Mondays at 3 am (UTC time)
name: Cron Testing

defaults:
run:
shell: bash

on: # Runs on master branch on Mondays at 3am UTC time
on:
schedule:
- cron: '* 3 * * mon'

jobs:
tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04,, ubuntu-22.04, macos-latest, windows-latest]
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
python-version: [3.7, 3.8, 3.9, "3.10", 3.x] # crons should always run latest python hence 3.x

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel

- name: Install package
run: python -m pip install '.[test]'

- name: Run all tests
run: python -m pytest
tests:
uses: pylhc/.github/.github/workflows/cron.yml@master
with:
extra-dependencies: test
47 changes: 5 additions & 42 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,14 @@
# Build documentation
# The build is uploaded as artifact if the triggering event is a push for a pull request
# The build is published to github pages if the triggering event is a push to the master branch (PR merge)
name: Build and upload documentation

defaults:
run:
shell: bash

on: # Runs on any push event to master
on: # Runs on any push event in a PR or any push event to master
pull_request:
push:
branches:
- 'master'

jobs:
documentation:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix: # only lowest supported Python on latest ubuntu
os: [ubuntu-latest]
python-version: [3.7]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel

- name: Install package
run: python -m pip install '.[doc]'

- name: Build documentation
run: python -m sphinx -b html doc ./doc_build -d ./doc_build

- name: Upload documentation to gh-pages
if: ${{ success() }}
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: doc_build
uses: pylhc/.github/.github/workflows/documentation.yml@master
43 changes: 2 additions & 41 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@
# Publishes to PyPI upon creation of a release
name: Upload Package to PyPI

defaults:
run:
shell: bash

on: # Runs everytime a release is added to the repository
release:
types: [created]

jobs:
deploy:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix: # only lowest supported Python on latest ubuntu
os: [ubuntu-latest]
python-version: [3.7]


steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Upgrade pip, setuptools, wheel, build and twine
run: python -m pip install --upgrade pip setuptools wheel build twine

- name: Build and check build
run: |
python -m build
twine check dist/*
- name: Publish
if: ${{ success() }}
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
uses: pylhc/.github/.github/workflows/publish.yml@master
secrets: inherit
41 changes: 8 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
# Runs all tests
name: Tests
name: All Tests

defaults:
run:
shell: bash

on: [push] # Runs on all push events to any branch

on: # Runs on any push event to any branch except master (the coverage workflow takes care of that)
push:
branches-ignore:
- 'master'

jobs:
tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, macos-latest, windows-latest]
# Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser
python-version: [3.7, 3.8, 3.9, "3.10"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/setup.py'

- name: Get full Python version
id: full-python-version
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Upgrade pip, setuptools and wheel
run: python -m pip install --upgrade pip setuptools wheel

- name: Install package
run: python -m pip install '.[test]'

- name: Run basic tests
run: python -m pytest
uses: pylhc/.github/.github/workflows/tests.yml@master
with:
extra-dependencies: test
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SDDS-Files Changelog

## Version 0.4
- Added:
- Support for reading gzipped compressed file and arbitrary compression formats if the opener abstraction is provided.

## Version 0.3
- Added:
- little endian support.
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def about_package(init_posixpath: pathlib.Path) -> dict:
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -113,7 +113,7 @@ def about_package(init_posixpath: pathlib.Path) -> dict:
'collapse_navigation': False,
'display_version': True,
'logo_only': True,
'navigation_depth': 2,
'navigation_depth': 3,
}

html_logo = '_static/img/omc_logo.svg'
Expand Down
5 changes: 4 additions & 1 deletion doc/modules/index.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
SDDS Modules
**************************
************

.. automodule:: sdds.classes
:members:
:noindex:


.. automodule:: sdds.reader
:members:
:noindex:


.. automodule:: sdds.writer
:members:
:noindex:


6 changes: 3 additions & 3 deletions sdds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Exposes SddsFile, read_sdds and write_sdds directly in sdds namespace."""
from sdds.writer import write_sdds
from sdds.reader import read_sdds
from sdds.classes import SddsFile
from sdds.reader import read_sdds
from sdds.writer import write_sdds

__title__ = "sdds"
__description__ = "SDDS file handling."
__url__ = "https://github.com/pylhc/sdds"
__version__ = "0.3.1"
__version__ = "0.4.0"
__author__ = "pylhc"
__author_email__ = "pylhc@github.com"
__license__ = "MIT"
Expand Down
Loading

0 comments on commit ff390c1

Please sign in to comment.