Skip to content

Commit

Permalink
Split the testing and the deployment workflows
Browse files Browse the repository at this point in the history
The deployment workflow still depends on the tests passing.
  • Loading branch information
ioannis-vm committed Mar 10, 2024
1 parent 123849e commit 1cec8c5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,54 +1,29 @@
name: Run tests and, if successful, deploy to PyPI
name: Deploy to PyPI if Tests Pass

on:
push:
branches:
- main
workflow_run:
workflows: ["Run Tests"]
branches: [main]
types:
- completed

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.9']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements_dev.txt
python -m pip install openseespy
python -m pip install -e .
- name: flake8
run: flake8 src
- name: Unit tests
run: python -m pytest --doctest-modules src/osmg/

deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Check the current version on PyPi
id: version_step_pypi
run: |
python -m pip install requests
latest=$(python src/osmg/get_latest_pypi_version.py)
echo "Latest Version found on PyPi: $latest"
echo "PYPI_VERSION=$latest" >> $GITHUB_ENV
- name: Check the current version on setup.cfg
id: version_step_setupcfg
run: |
version=$(grep '^version' setup.cfg | awk -F= '{print $2}' | tr -d '[:space:]')
echo "Version found in setup.cfg: $version"
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Tests

on:
push:
branches:
- main

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.9']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements_dev.txt
python -m pip install openseespy
python -m pip install -e .
- name: flake8
run: flake8 src
- name: Unit tests
run: python -m pytest --doctest-modules src/osmg/

0 comments on commit 1cec8c5

Please sign in to comment.