Skip to content

Commit

Permalink
Tidy the CI more and add src distributions & pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Finnie committed Aug 3, 2024
1 parent 003c6db commit 7954fd4
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pygom
name: create PyGOM distributions

on:
push:
Expand All @@ -13,60 +13,7 @@ on:
- master
- dev

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] #, macos-13, macos-14]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v4
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v4
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check python version
run: python -c "import sys; print(sys.version)"

- name: Install pip
run: |
python -m pip install --upgrade pip
- name: install PyGOM
run: |
pip install .
- name: Run tests
run: python -m unittest discover --verbose --start-directory tests

build_wheels:
name: Build wheels on ${{ matrix.platform_id }} for Python v${{ matrix.python[1] }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -134,3 +81,38 @@ jobs:
with:
name: cibw-wheels-${{ matrix.platform_id }}-${{ matrix.python[0] }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
# Upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# Testing only at this point
repository-url: https://test.pypi.org/legacy/
67 changes: 67 additions & 0 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: create PyGOM distributions

on:
push:
branches:
- master
- dev
- feature/*
- bugfix/*

pull_request:
branches:
- master
- dev

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] #, macos-13, macos-14]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v4
if: startsWith(runner.os, 'macOS')
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v4
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Check python version
run: python -c "import sys; print(sys.version)"

- name: Install pip
run: |
python -m pip install --upgrade pip
- name: install PyGOM
run: |
pip install .
- name: Run tests
run: python -m unittest discover --verbose --start-directory tests

#TODO: Could also do something about coverage here too

0 comments on commit 7954fd4

Please sign in to comment.