diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 13e38149..6b4dabc7 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -9,41 +9,57 @@ jobs: # Define job steps steps: - - name: Set up Python - uses: actions/setup-python@v4 + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + id: setup-python with: - python-version: "3.10" - - - name: Check-out repository - uses: actions/checkout@v3 - - - name: Install poetry + python-version: '3.12' + #---------------------------------------------- + # ----- install & configure poetry ----- + #---------------------------------------------- + - name: Install Poetry uses: snok/install-poetry@v1 - - - name: Install package - run: poetry install - - - name: Format with ruff - run: poetry run ruff format - - - name: Lint with ruff - run: poetry run ruff check --fix - - - name: Run tests - run: | - source .venv/bin/activate - pytest tests/ --cov=chaturbate_poller --cov-report=xml - - - name: Use Codecov to track coverage - uses: codecov/codecov-action@v3 with: - files: ./coverage.xml - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 + virtualenvs-create: true + virtualenvs-in-project: true + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + #---------------------------------------------- + # install your root project, if required + #---------------------------------------------- + - name: Install library + run: poetry install --no-interaction + #---------------------------------------------- + # run test suite and output coverage file + #---------------------------------------------- + - name: Test with pytest + run: poetry run pytest --cov=chaturbate_poller --cov-report=xml + #---------------------------------------------- + # upload coverage stats + # (requires CODECOV_TOKEN in repository secrets) + #---------------------------------------------- + - name: Upload coverage + uses: codecov/codecov-action@v3 with: - token: ${{ secrets.CODECOV_TOKEN }} - slug: MountainGod2/chaturbate_poller + token: ${{ secrets.CODECOV_TOKEN }} # Only required for private repositories + file: ./coverage.xml + fail_ci_if_error: true - name: Build documentation run: poetry run make clean html --directory docs/