From c6f86d66807e1c6b6f992399eedbf34ed422d3e0 Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 15:57:33 +0300 Subject: [PATCH 1/7] add lint step --- .github/workflows/ci.yaml | 45 +++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 30eac90..93879c6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,6 +13,33 @@ on: - master jobs: + lint-ruff-format: + name: Check ruff-format + runs-on: ubuntu-22.04 + steps: + - name: Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: Set up Python 3.x + uses: actions/setup-python@v5.1.1 + id: python + with: + python-version: 3.x + check-latest: true + - name: Restore base Python virtual environment + id: cache-venv + uses: actions/cache/restore@v4.0.2 + with: + path: venv + fail-on-cache-miss: true + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ + needs.info.outputs.pre-commit_cache_key }} + - name: Run ruff-format + run: | + . venv/bin/activate + pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure + env: + RUFF_OUTPUT_FORMAT: github test: name: Tests @@ -65,21 +92,3 @@ jobs: - uses: codecov/codecov-action@v4.0.1 with: token: ${{ secrets.CODECOV_TOKEN }} - - lint: - - name: "Linting & Static Analysis" - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - with: - python-version: "3.x" - architecture: x64 - - - uses: pre-commit/action@v3.0.0 - env: - SKIP: no-commit-to-branch From 024bfbb7e917c256b2d473f7e53f89f91496f716 Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 22:39:51 +0300 Subject: [PATCH 2/7] fix --- .github/workflows/ci.yaml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 93879c6..1372b0b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,15 +25,6 @@ jobs: with: python-version: 3.x check-latest: true - - name: Restore base Python virtual environment - id: cache-venv - uses: actions/cache/restore@v4.0.2 - with: - path: venv - fail-on-cache-miss: true - key: >- - ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ - needs.info.outputs.pre-commit_cache_key }} - name: Run ruff-format run: | . venv/bin/activate From 7588a043f2c7a686efec683f654e1e9b32d224ca Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 22:44:51 +0300 Subject: [PATCH 3/7] fix --- .github/workflows/ci.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1372b0b..8278ae7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,9 +13,35 @@ on: - master jobs: + pre-commit: + name: Prepare pre-commit base + runs-on: ubuntu-22.04 + steps: + - name: Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: Set up Python 3.x + id: python + uses: actions/setup-python@v5.1.1 + with: + python-version: 3.x + check-latest: true + - name: Create Python virtual environment + run: | + python -m venv venv + . venv/bin/activate + python --version + pip install "$(grep '^uv' < requirements_test.txt)" + uv pip install "$(cat requirements_test.txt | grep pre-commit)" + - name: Install pre-commit dependencies + run: | + . venv/bin/activate + pre-commit install-hooks + lint-ruff-format: name: Check ruff-format runs-on: ubuntu-22.04 + needs: + - pre-commit steps: - name: Check out code from GitHub uses: actions/checkout@v4.1.7 @@ -35,6 +61,8 @@ jobs: name: Tests runs-on: ubuntu-latest + needs: + - lint-ruff-format strategy: matrix: @@ -61,6 +89,8 @@ jobs: name: Test Coverage runs-on: ubuntu-latest + needs: + - test steps: - uses: actions/checkout@v3 From 45f35875c0922c95b482f8470626789d6720e532 Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 22:48:20 +0300 Subject: [PATCH 4/7] fix --- requirements_test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements_test.txt b/requirements_test.txt index fdae1e7..4ed4fce 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -36,5 +36,6 @@ toml==0.10.2 tomlkit==0.13.0 types-pytz==2024.1.0.20240417 typing_extensions==4.12.2 +uv==0.2.24 virtualenv==20.26.3 yarl==1.9.4 From d2d4221a8ee9c5eb896552af0f849823a132190b Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 22:58:27 +0300 Subject: [PATCH 5/7] fix --- .github/workflows/ci.yaml | 76 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8278ae7..5eaa147 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,27 +12,76 @@ on: - dev - master +env: + CACHE_VERSION: 9 + DEFAULT_PYTHON: "3.12" + PRE_COMMIT_CACHE: ~/.cache/pre-commit + UV_CACHE_DIR: /tmp/uv-cache + jobs: + info: + name: Collect information & changes data + outputs: + pre-commit_cache_key: ${{ steps.generate_pre-commit_cache_key.outputs.key }} + python_cache_key: ${{ steps.generate_python_cache_key.outputs.key }} + requirements: ${{ steps.core.outputs.requirements }} + python_versions: ${{ steps.info.outputs.python_versions }} + runs-on: ubuntu-22.04 + steps: + - name: Check out code from GitHub + uses: actions/checkout@v4.1.7 + - name: Generate partial Python venv restore key + id: generate_python_cache_key + run: | + echo "key=venv-${{ env.CACHE_VERSION }}-${{ + hashFiles('requirements_test.txt') }} >> $GITHUB_OUTPUT + - name: Generate partial pre-commit restore key + id: generate_pre-commit_cache_key + run: >- + echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{ + hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT + pre-commit: name: Prepare pre-commit base runs-on: ubuntu-22.04 + needs: + - info steps: - name: Check out code from GitHub uses: actions/checkout@v4.1.7 - - name: Set up Python 3.x + - name: Set up Python ${{ env.DEFAULT_PYTHON }} id: python uses: actions/setup-python@v5.1.1 with: - python-version: 3.x + python-version: ${{ env.DEFAULT_PYTHON }} check-latest: true + - name: Restore base Python virtual environment + id: cache-venv + uses: actions/cache@v4.0.2 + with: + path: venv + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ + needs.info.outputs.pre-commit_cache_key }} - name: Create Python virtual environment + if: steps.cache-venv.outputs.cache-hit != 'true' run: | python -m venv venv . venv/bin/activate python --version pip install "$(grep '^uv' < requirements_test.txt)" uv pip install "$(cat requirements_test.txt | grep pre-commit)" + - name: Restore pre-commit environment from cache + id: cache-precommit + uses: actions/cache@v4.0.2 + with: + path: ${{ env.PRE_COMMIT_CACHE }} + lookup-only: true + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ + needs.info.outputs.pre-commit_cache_key }} - name: Install pre-commit dependencies + if: steps.cache-precommit.outputs.cache-hit != 'true' run: | . venv/bin/activate pre-commit install-hooks @@ -41,16 +90,35 @@ jobs: name: Check ruff-format runs-on: ubuntu-22.04 needs: + - info - pre-commit steps: - name: Check out code from GitHub uses: actions/checkout@v4.1.7 - - name: Set up Python 3.x + - name: Set up Python ${{ env.DEFAULT_PYTHON }} uses: actions/setup-python@v5.1.1 id: python with: - python-version: 3.x + python-version: ${{ env.DEFAULT_PYTHON }} check-latest: true + - name: Restore base Python virtual environment + id: cache-venv + uses: actions/cache/restore@v4.0.2 + with: + path: venv + fail-on-cache-miss: true + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ + needs.info.outputs.pre-commit_cache_key }} + - name: Restore pre-commit environment from cache + id: cache-precommit + uses: actions/cache/restore@v4.0.2 + with: + path: ${{ env.PRE_COMMIT_CACHE }} + fail-on-cache-miss: true + key: >- + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ + needs.info.outputs.pre-commit_cache_key }} - name: Run ruff-format run: | . venv/bin/activate From 18e840f0850350bb632f3d73d83cc5f2ba751660 Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 23:01:25 +0300 Subject: [PATCH 6/7] fix --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5eaa147..ffcd65a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ on: - master env: - CACHE_VERSION: 9 + CACHE_VERSION: 1 DEFAULT_PYTHON: "3.12" PRE_COMMIT_CACHE: ~/.cache/pre-commit UV_CACHE_DIR: /tmp/uv-cache From ba78bba8cdf5ce2fa69ce7f16933338895743c55 Mon Sep 17 00:00:00 2001 From: "shai.ungar" Date: Fri, 12 Jul 2024 23:03:17 +0300 Subject: [PATCH 7/7] fix --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ffcd65a..efac490 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: - name: Generate partial Python venv restore key id: generate_python_cache_key run: | - echo "key=venv-${{ env.CACHE_VERSION }}-${{ + echo key=venv-${{ env.CACHE_VERSION }}-${{ hashFiles('requirements_test.txt') }} >> $GITHUB_OUTPUT - name: Generate partial pre-commit restore key id: generate_pre-commit_cache_key