Skip to content

Commit 36b0b4c

Browse files
committed
Updated tests and workflows
1 parent 28c6f7c commit 36b0b4c

17 files changed

+755
-141
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/codecov.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ name: codecov.io
22

33
# Controls when the workflow will run
44
on:
5-
# Triggers the workflow on push or pull request events but only for the master branch
6-
push:
7-
branches: [ main ]
8-
pull_request:
9-
branches: [ main ]
10-
11-
# Allows you to run this workflow manually from the Actions tab
12-
workflow_dispatch:
5+
workflow_call:
136

147
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
158
jobs:
@@ -21,12 +14,12 @@ jobs:
2114
# Steps represent a sequence of tasks that will be executed as part of the job
2215
steps:
2316
- name: Checkout
24-
uses: actions/checkout@v4
17+
uses: actions/checkout@v5
2518

26-
- name: Set up Python '3.10'
27-
uses: actions/setup-python@v5
19+
- name: Set up Python
20+
uses: actions/setup-python@v6
2821
with:
29-
python-version: '3.10'
22+
python-version: '3.x'
3023

3124
- name: Install dependencies
3225
run: |
@@ -40,4 +33,4 @@ jobs:
4033

4134
# codecov
4235
- name: "Upload coverage to Codecov"
43-
uses: codecov/codecov-action@v2
36+
uses: codecov/codecov-action@v5
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
1-
name: Build Documentation
1+
name: Publish Documentation
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
10-
workflow_dispatch:
4+
workflow_call:
115

126
jobs:
13-
build:
14-
7+
publish-documentation:
158
runs-on: ubuntu-latest
16-
179
steps:
18-
- uses: actions/checkout@v4
19-
with:
20-
fetch-tags: true
21-
22-
- name: Set up Python 3.10
23-
uses: actions/setup-python@v5
10+
- uses: actions/checkout@v5
11+
- uses: actions/setup-python@v6
2412
with:
25-
python-version: '3.10'
26-
27-
# Install dependencies
13+
python-version: '3.x'
2814
- name: Upgrade pip, install package, install requirements, build docs
2915
run: |
30-
python -m pip install --upgrade pip
31-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
16+
pip install --upgrade pip
3217
pip install .
3318
if [ -f ./docs/requirements.txt ]; then pip install -r ./docs/requirements.txt; fi
3419
pip install sphinx
3520
sphinx-build docs ./docs/_build/html/
36-
shell: bash
37-
3821
# Create an artifact of the html output.
39-
- uses: actions/upload-artifact@v1
22+
- uses: actions/upload-artifact@v4
4023
with:
4124
name: DocumentationHTML
4225
path: docs/_build/html/
@@ -49,11 +32,9 @@ jobs:
4932
git config --global user.name "${GITHUB_ACTOR}"
5033
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
5134
git clone "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" --branch gh-pages --single-branch gh-pages
52-
5335
cp -r docs/_build/html/* gh-pages/
5436
cd gh-pages
5537
touch .nojekyll
56-
5738
git add .
5839
git commit -m "Update documentation." -a || true
5940
# The above command will fail if no changes were present, so we ignore
@@ -64,4 +45,4 @@ jobs:
6445
branch: gh-pages
6546
directory: gh-pages
6647
github_token: ${{ secrets.GITHUB_TOKEN }}
67-
# ===============================
48+
# ===============================
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Package and Documentation Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release-version:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- id: parse-version
12+
name: Parse release version
13+
run: |
14+
echo "version=${RELEASE_VERSION/v/}" >> "$GITHUB_OUTPUT"
15+
env:
16+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
17+
outputs:
18+
version: ${{ steps.parse-version.outputs.version }}
19+
publish-test-pypi:
20+
uses: ./.github/workflows/pypi.yml
21+
with:
22+
repository_url: https://test.pypi.org/legacy/
23+
secrets:
24+
API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
25+
test-test-pypi:
26+
needs: [release-version, publish-test-pypi]
27+
uses: ./.github/workflows/tests.yml
28+
with:
29+
install_command: "python3 -m pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple mwtab==${{ needs.release-version.outputs.version }}"
30+
publish-pypi:
31+
needs: test-test-pypi
32+
uses: ./.github/workflows/pypi.yml
33+
with:
34+
repository_url: https://upload.pypi.org/legacy/
35+
secrets:
36+
API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
37+
test-pypi:
38+
needs: [release-version, publish-pypi]
39+
uses: ./.github/workflows/tests.yml
40+
with:
41+
install_command: "python3 -m pip install mwtab==${{ needs.release-version.outputs.version }}"
42+
publish-documentation:
43+
needs: test-pypi
44+
uses: ./.github/workflows/documentation.yml
45+
upload-coverage:
46+
needs: test-pypi
47+
uses: ./.github/workflows/codecov.yml

.github/workflows/pull_request.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Pull request
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
pull-request:
14+
uses: ./.github/workflows/tests.yml
15+
with:
16+
install_command: "python3 -m pip install -e ."

.github/workflows/pypi.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
repository_url:
7+
description: The URL of the PyPi distribution
8+
required: true
9+
type: string
10+
secrets:
11+
API_TOKEN:
12+
required: true
13+
14+
jobs:
15+
publish-package:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
- name: Install dependencies
23+
run: |
24+
python3 -m pip install --upgrade pip
25+
python3 -m pip install build
26+
- name: Build package
27+
run: python3 -m build
28+
- name: Publish package to a PyPi distribution
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
with:
31+
password: ${{ secrets.API_TOKEN }}
32+
repository-url: ${{ inputs.repository_url }}

.github/workflows/tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Run Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
install_command:
7+
description: The command for installing the package to test.
8+
required: true
9+
type: string
10+
11+
jobs:
12+
run-tests:
13+
strategy:
14+
matrix:
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
16+
os: [ ubuntu-latest, windows-latest, macOS-latest ]
17+
runs-on: ${{matrix.os}}
18+
steps:
19+
- uses: actions/checkout@v5
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v6
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install testing environment
25+
run: |
26+
python3 -m pip install --upgrade pip
27+
python3 -m pip install pytest pytest-mock pytest-cov deepdiff
28+
- name: Install package
29+
uses: Wandalen/wretry.action@master
30+
with:
31+
command: ${{ inputs.install_command }}
32+
attempt_limit: 10
33+
attempt_delay: 10000
34+
- name: Run tests on package
35+
run: pytest
36+
# - name: Debug with tmate on failure
37+
# if: ${{ failure() }}
38+
# uses: mxschmitt/action-tmate@v3
39+
# with:
40+
# limit-access-to-actor: true

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
name = "mwtab"
77
description = "Parser for mwtab files from the Metabolomics Workbench"
88
readme = "README.rst"
9-
requires-python = ">=3.6"
9+
requires-python = ">=3.8"
1010
keywords = ["mwtab", "metabolomics workbench"]
1111
license = {file = "LICENSE"}
1212
classifiers = [
@@ -15,12 +15,13 @@ classifiers = [
1515
'Intended Audience :: Science/Research',
1616
'License :: OSI Approved :: BSD License',
1717
'Operating System :: OS Independent',
18-
'Programming Language :: Python :: 3.5',
19-
'Programming Language :: Python :: 3.6',
20-
'Programming Language :: Python :: 3.7',
2118
'Programming Language :: Python :: 3.8',
2219
'Programming Language :: Python :: 3.9',
2320
'Programming Language :: Python :: 3.10',
21+
'Programming Language :: Python :: 3.11',
22+
'Programming Language :: Python :: 3.12',
23+
'Programming Language :: Python :: 3.13',
24+
'Programming Language :: Python :: 3.14',
2425
'Topic :: Scientific/Engineering :: Bio-Informatics',
2526
'Topic :: Software Development :: Libraries :: Python Modules',
2627
]

src/mwtab/mwtab.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def _build_block(self, name, lexer):
556556
section.append(token.value)
557557

558558
elif token.key.endswith("_START"):
559-
section_name = token.key
559+
section_name = token.key[0:-6]
560560
data = []
561561

562562
token = next(lexer)
@@ -576,7 +576,7 @@ def _build_block(self, name, lexer):
576576
token_value.pop()
577577

578578
is_header = False
579-
if "BINNED_DATA" in section_name and loop_count < 2:
579+
if "BINNED_DATA" in section_name and 'EXTENDED' not in section_name and loop_count < 2:
580580
if loop_count < 1:
581581
self._raw_binned_headers = token_value
582582
self._raw_samples = self._raw_binned_headers
@@ -1020,7 +1020,7 @@ def _is_json(string, duplicate_keys=False, force=False):
10201020
raise TypeError("Expecting <class 'str'> or <class 'bytes'>, but {} was passed".format(type(string)))
10211021

10221022
if duplicate_keys and isinstance(json_str, DuplicatesDict):
1023-
raise KeyError("Given JSON contains duplicate keys at the highest level.")
1023+
raise KeyError('Given JSON contains duplicate keys at the highest level.')
10241024

10251025
if duplicate_keys:
10261026
for i, ssf_dict in enumerate(json_str['SUBJECT_SAMPLE_FACTORS']):

0 commit comments

Comments
 (0)