From 77a73896213d467d31d9c732d4a2dd661fe45a35 Mon Sep 17 00:00:00 2001 From: Amr Kayid Date: Tue, 14 May 2024 22:06:26 +0000 Subject: [PATCH] Update workflow --- .github/workflows/tests.yaml | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..0c49be6 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,57 @@ +name: Unit Tests + +on: [push, pull_request] + +env: + branch_name: ${{ github.head_ref || github.ref_name }} + +jobs: + test: + runs-on: ubuntu-20.04 + permissions: + pull-requests: write + contents: read + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up python + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: 3.11.9 + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.7.1 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + + - name: Load cached venv + uses: actions/cache/restore@v3 + id: cached-poetry-dependencies + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + venv-${{ runner.os }}- + + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + poetry install --no-interaction + + - name: Run tests + run: | + source .venv/bin/activate + poetry run python -m unittest discover -s tests -v + + - name: 💾 Save cache + uses: actions/cache/save@v3 + if: env.branch_name == 'main' + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}