Merge pull request #11 from turboflo/bug-fix #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [development] | |
pull_request: | |
branches: [development] | |
workflow_dispatch: # Manual trigger | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: # Define environment variables here | |
PYTHON_VERSION: "3.11" | |
COVERAGE_THRESHOLD: 20 # Set to 80% in production | |
BRANCH: development | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Cache Poetry dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-poetry- | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Cache virtual environment | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-venv- | |
- name: Install dependencies | |
run: | | |
poetry install --no-interaction --with dev | |
- name: Display installed packages | |
run: | | |
poetry show | |
- name: Investigate Pinecone library | |
run: | | |
echo "Pinecone library content:" | |
cat .venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/pinecone/control/pinecone.py | |
- name: Run unit tests with coverage report | |
run: | | |
poetry run python -m pytest -v --cov=./src --cov-report term-missing:skip-covered tests || echo "Some tests failed, but continuing workflow" | |
- name: Check coverage | |
run: | | |
poetry run coverage report -m | |
COVERAGE=$(poetry run coverage report -m | grep -Po '^TOTAL.*\s(\d+%)$' | awk '{sub("%", "", $NF); print $NF}') | |
echo "Coverage is $COVERAGE%" | |
if [ "$COVERAGE" -lt "${{ env.COVERAGE_THRESHOLD }}" ]; then | |
echo "Warning: Coverage is below ${{ env.COVERAGE_THRESHOLD }}%" | |
fi | |
- name: Python Semantic Release | |
if: github.event_name == 'push' && github.ref == 'refs/heads/development' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
poetry run semantic-release version | |
poetry run semantic-release publish | |
- name: Check if release was created | |
if: github.event_name == 'push' && github.ref == 'refs/heads/development' | |
id: check-release | |
run: | | |
if [ -n "$(git tag --points-at HEAD)" ]; then | |
echo "RELEASE_CREATED=true" >> $GITHUB_ENV | |
else | |
echo "RELEASE_CREATED=false" >> $GITHUB_ENV | |
fi | |
- name: Merge development into main if release created | |
if: github.event_name == 'push' && github.ref == 'refs/heads/development' && env.RELEASE_CREATED == 'true' | |
run: | | |
git checkout main | |
git merge --ff-only ${{ env.BRANCH }} | |
git push origin main |