From 1cec8c5d57cca0e25ddfbcda5318f24de2285c4a Mon Sep 17 00:00:00 2001 From: John Vouvakis Manousakis Date: Sat, 9 Mar 2024 18:22:41 -0800 Subject: [PATCH] Split the testing and the deployment workflows The deployment workflow still depends on the tests passing. --- .../{test_and_deploy.yaml => deploy.yaml} | 39 ++++--------------- .github/workflows/test.yaml | 30 ++++++++++++++ 2 files changed, 37 insertions(+), 32 deletions(-) rename .github/workflows/{test_and_deploy.yaml => deploy.yaml} (58%) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test_and_deploy.yaml b/.github/workflows/deploy.yaml similarity index 58% rename from .github/workflows/test_and_deploy.yaml rename to .github/workflows/deploy.yaml index e6454d0a..7a9c4b3b 100644 --- a/.github/workflows/test_and_deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -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" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..5cf58822 --- /dev/null +++ b/.github/workflows/test.yaml @@ -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/