From 5c3c504496a4613b28702248a27ed6370fbea13a Mon Sep 17 00:00:00 2001 From: prezakhani <13303554+Pouyanpi@users.noreply.github.com> Date: Sat, 26 Oct 2024 12:56:51 +0200 Subject: [PATCH] update workflows --- .github/workflows/_test.yml | 6 +++--- .github/workflows/build-wheel.yml | 31 +++++++++++++++++++++++++++---- .github/workflows/full-tests.yml | 2 +- .github/workflows/pr-tests.yml | 11 +++++++---- .github/workflows/test-wheel.yml | 7 +++---- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index d13bffd3..f706269e 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -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 diff --git a/.github/workflows/build-wheel.yml b/.github/workflows/build-wheel.yml index 8394be5b..0465c063 100644 --- a/.github/workflows/build-wheel.yml +++ b/.github/workflows/build-wheel.yml @@ -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 @@ -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 diff --git a/.github/workflows/full-tests.yml b/.github/workflows/full-tests.yml index be32906b..659aec2a 100644 --- a/.github/workflows/full-tests.yml +++ b/.github/workflows/full-tests.yml @@ -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 diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index c90d284a..2fa60325 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -1,6 +1,4 @@ name: PR Tests -env: - PYTHON_VERSION: 3.11 on: pull_request: @@ -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 }} diff --git a/.github/workflows/test-wheel.yml b/.github/workflows/test-wheel.yml index 98f03594..964427c9 100644 --- a/.github/workflows/test-wheel.yml +++ b/.github/workflows/test-wheel.yml @@ -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: @@ -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