diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b393947..1e7bcb2 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -3,8 +3,11 @@ name: Python CI on: [push, workflow_dispatch] jobs: - install: + build: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 @@ -13,22 +16,24 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Cache pip + - name: Set up cache uses: actions/cache@v2 + id: cache-virtualenv with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + path: ~/.venv + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} - name: Install dependencies + if: steps.cache-virtualenv.outputs.cache-hit != 'true' run: | + python -m venv ~/.venv + source ~/.venv/bin/activate python -m pip install --upgrade pip pip install -r requirements.txt pip install -U pylint pytest lint: - needs: install + needs: build runs-on: ubuntu-latest strategy: matrix: @@ -36,45 +41,33 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - - name: Cache pip + - name: Restore Python virtual environment uses: actions/cache@v2 with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + path: ~/.venv + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} - name: Lint Code - run: pylint $(git ls-files '*.py') + run: | + source ~/.venv/bin/activate + pylint $(git ls-files '*.py') test: - needs: install + needs: build runs-on: ubuntu-latest - env: - ROBOFLOW_API_KEY: ${{ secrets.ROBOFLOW_API_KEY }} strategy: matrix: python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - - name: Cache pip + - name: Restore Python virtual environment uses: actions/cache@v2 with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + path: ~/.venv + key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} - name: Run tests - run: pytest . + run: | + source ~/.venv/bin/activate + pytest .