Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Pouyanpi committed Oct 26, 2024
1 parent afb7759 commit 5c3c504
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ jobs:
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Install dependencies
run: poetry install --with github-actions
run: poetry install --with dev

- name: Run mypy
run: poetry run mypy
- name: Run pre commit hooks
run: poetry run make pre_commit

- name: Run pytest
run: poetry run pytest -v
31 changes: 27 additions & 4 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ on:
env:
POETRY_VERSION: "1.8.2"
PYTHON_VERSION: "3.11"
RUNNER_OS: "ubuntu-latest"

jobs:
build-wheel:
runs-on: ubuntu-latest
runs-on: ${{ env.RUNNER_OS }}
steps:
- uses: actions/checkout@v4

Expand All @@ -24,10 +25,32 @@ jobs:
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

- name: Install Poetry ${{ env.POETRY_VERSION }}
uses: abatilo/actions-poetry@v2
- name: Get full Python version
id: full-python-version
run: echo "version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")" >> $GITHUB_OUTPUT

- name: Set execute permissions for build script
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | POETRY_VERSION=${{ env.POETRY_VERSION }} python -
- name: Update PATH (Linux and macOS)
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Configure poetry
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v3
id: cache
with:
path: .venv
key: venv-${{ env.RUNNER_OS }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
run: timeout 10s poetry run pip --version || rm -rf .venv

- name: Make build script executable
run: chmod +x ./.github/scripts/build.sh

- name: Build Wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/full-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false

uses: ./.github/workflows/_test.yml
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
name: PR Tests
env:
PYTHON_VERSION: 3.11

on:
pull_request:
Expand All @@ -9,7 +7,12 @@ on:

jobs:
call-tests:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]
fail-fast: false
uses: ./.github/workflows/_test.yml
with:
os: ubuntu-latest
python-version: "3.10"
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
7 changes: 3 additions & 4 deletions .github/workflows/test-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
test-wheel:
needs: build-wheel # Ensures build-wheel job completes successfully
needs: build-wheel
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -31,11 +31,10 @@ jobs:
with:
name: nemoguardrails-${{ env.VERSION }}.whl

# Install the downloaded wheel
- name: Install Wheel
run: |
pip install nemoguardrails-${{ env.VERSION }}-py3-none-any.whl
pip install nemoguardrails-${{ env.VERSION }}-py3-none-any.whl[dev]
pip install --user nemoguardrails-${{ env.VERSION }}-py3-none-any.whl
pip install --user nemoguardrails-${{ env.VERSION }}-py3-none-any.whl[dev]
# Run additional tests as needed
- name: Run Tests
Expand Down

0 comments on commit 5c3c504

Please sign in to comment.