From 278a75caedf00cdcd39912a3a90023a357c3addc Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Mon, 26 Jul 2021 17:58:43 -0700 Subject: [PATCH] adding poetry and caching to actions build --- .github/workflows/github-actions.yml | 49 +++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 3203fac..bb25101 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -4,22 +4,55 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Set up Python 3.9 uses: actions/setup-python@v2 with: python-version: 3.9 - - name: Install dependencies + + - name: Get full Python version + id: full-python-version + shell: bash + run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") + + - name: Bootstrap poetry + shell: bash run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements_dev.txt + curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py \ + | python - -y + + - name: Update PATH + if: ${{ matrix.os != 'Windows' }} + shell: bash + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Configure poetry + shell: bash + run: poetry config virtualenvs.in-project true + + - name: Set up cache + uses: actions/cache@v2 + id: cache + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Ensure cache is healthy + if: steps.cache.outputs.cache-hit == 'true' + shell: bash + run: timeout 10s poetry run pip --version || rm -rf .venv + + - name: Install dependencies + shell: bash + run: poetry install + - name: Run precommit run: | pre-commit run --all-files - - name: Test with unittest - run: | - python -m unittest tests/*.py + + - name: Test with pytest + shell: bash + run: poetry run test