From 11eb42e8c02f8125d224ffadadd64b823ae91076 Mon Sep 17 00:00:00 2001 From: Ofek Lev Date: Mon, 27 May 2024 13:44:39 -0400 Subject: [PATCH] Improve CI (#1535) --- .github/workflows/build-distributions.yml | 5 ++- .github/workflows/build-hatch.yml | 29 ++++++++++--- .github/workflows/build-hatchling.yml | 13 +++++- .github/workflows/cli.yml | 53 +++++++++++++++++++++++ .github/workflows/docs-dev.yml | 8 ++-- .github/workflows/docs-release.yml | 8 ++-- .github/workflows/test.yml | 52 +++------------------- 7 files changed, 105 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/cli.yml diff --git a/.github/workflows/build-distributions.yml b/.github/workflows/build-distributions.yml index 052830540..dbc757324 100644 --- a/.github/workflows/build-distributions.yml +++ b/.github/workflows/build-distributions.yml @@ -31,12 +31,15 @@ jobs: with: python-version: ${{ env.DIST_PYTHON_VERSION }} + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install Hatch if: inputs.version # Try to install the specific version of Hatch that was just released until successful run: |- for i in {1..20}; do - pip install hatch==${{ inputs.version }} && break || sleep 5 + uv pip install --system hatch==${{ inputs.version }} && break || sleep 5 done linux: diff --git a/.github/workflows/build-hatch.yml b/.github/workflows/build-hatch.yml index 0071a4aa0..9dddcebaf 100644 --- a/.github/workflows/build-hatch.yml +++ b/.github/workflows/build-hatch.yml @@ -20,7 +20,7 @@ defaults: env: APP_NAME: hatch - PYTHON_VERSION: "3.11" + PYTHON_VERSION: "3.12" PYOXIDIZER_VERSION: "0.24.0" DIST_URL: "https://github.com/pypa/hatch/releases/download" @@ -39,8 +39,16 @@ jobs: with: fetch-depth: 0 + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install tools - run: python -m pip install --upgrade build hatch + run: uv pip install --system build hatch # Windows installers don't accept non-integer versions so we ubiquitously # perform the following transformation: X.Y.Z.devN -> X.Y.Z.N @@ -149,10 +157,13 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install Hatch run: |- - pip install -e . - pip install -e ./backend + uv pip install --system -e . + uv pip install --system -e ./backend - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable @@ -272,8 +283,11 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install PyOxidizer ${{ env.PYOXIDIZER_VERSION }} - run: pip install pyoxidizer==${{ env.PYOXIDIZER_VERSION }} + run: uv pip install --system pyoxidizer==${{ env.PYOXIDIZER_VERSION }} - name: Download staged binaries uses: actions/download-artifact@v4 @@ -355,8 +369,11 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install PyOxidizer ${{ env.PYOXIDIZER_VERSION }} - run: pip install pyoxidizer==${{ env.PYOXIDIZER_VERSION }} + run: uv pip install --system pyoxidizer==${{ env.PYOXIDIZER_VERSION }} - name: Install rcodesign env: diff --git a/.github/workflows/build-hatchling.yml b/.github/workflows/build-hatchling.yml index 28e082bb8..ff36cade4 100644 --- a/.github/workflows/build-hatchling.yml +++ b/.github/workflows/build-hatchling.yml @@ -5,6 +5,9 @@ on: tags: - hatchling-v* +env: + PYTHON_VERSION: "3.12" + jobs: build: name: Build wheels and source distribution @@ -13,8 +16,16 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python ${{ env.PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: Install build dependencies - run: python -m pip install --upgrade build + run: uv pip install --system --upgrade build - name: Build source distribution run: python -m build backend diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml new file mode 100644 index 000000000..3ae261183 --- /dev/null +++ b/.github/workflows/cli.yml @@ -0,0 +1,53 @@ +name: CLI experience + +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +env: + STABLE_PYTHON_VERSION: '3.12' + HYPERFINE_VERSION: '1.18.0' + +jobs: + response-time: + name: CLI responsiveness with latest Python + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ env.STABLE_PYTHON_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.STABLE_PYTHON_VERSION }} + + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install hyperfine + uses: taiki-e/install-action@v2 + with: + tool: hyperfine@${{ env.HYPERFINE_VERSION }} + + - name: Install other tools + run: uv pip install --system --upgrade flit poetry pipenv + + - name: Install ourself + run: | + uv pip install --system . + uv pip install --system ./backend + + - name: Benchmark + run: | + hyperfine -m 100 --warmup 10 -i pipenv + hyperfine -m 100 --warmup 10 poetry + hyperfine -m 100 --warmup 10 -i flit + hyperfine -m 100 --warmup 10 hatch diff --git a/.github/workflows/docs-dev.yml b/.github/workflows/docs-dev.yml index ca8671893..0f897bbd0 100644 --- a/.github/workflows/docs-dev.yml +++ b/.github/workflows/docs-dev.yml @@ -32,13 +32,13 @@ jobs: - name: Validate history run: python scripts/validate_history.py - - name: Ensure latest pip - run: python -m pip install --upgrade pip + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install ourself run: | - pip install -e . - pip install -e ./backend + uv pip install --system -e . + uv pip install --system -e ./backend - name: Configure Git for GitHub Actions bot run: | diff --git a/.github/workflows/docs-release.yml b/.github/workflows/docs-release.yml index b0c08b84f..c6f2f425f 100644 --- a/.github/workflows/docs-release.yml +++ b/.github/workflows/docs-release.yml @@ -30,13 +30,13 @@ jobs: - name: Validate history run: python scripts/validate_history.py - - name: Ensure latest pip - run: python -m pip install --upgrade pip + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install ourself run: | - pip install -e . - pip install -e ./backend + uv pip install --system -e . + uv pip install --system -e ./backend - name: Display full version run: hatch version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e85b47c7e..52cffd015 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,6 @@ concurrency: cancel-in-progress: true env: - STABLE_PYTHON_VERSION: '3.11' PYTHONUNBUFFERED: "1" FORCE_COLOR: "1" @@ -35,13 +34,13 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Ensure latest pip - run: python -m pip install --upgrade pip + - name: Install UV + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install ourself run: | - pip install -e . - pip install -e ./backend + uv pip install --system -e . + uv pip install --system -e ./backend - name: Run static analysis run: hatch fmt --check @@ -70,13 +69,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ env.STABLE_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.STABLE_PYTHON_VERSION }} - - name: Install Hatch - run: pip install hatch + uses: pypa/hatch@install - name: Trigger build for auto-generated files run: hatch build --hooks-only @@ -136,41 +130,6 @@ jobs: - name: Build downstream projects run: python backend/tests/downstream/integrate.py - response-time: - name: CLI responsiveness with latest Python - runs-on: ubuntu-latest - - env: - HYPERFINE_VERSION: '1.12.0' - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ env.STABLE_PYTHON_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.STABLE_PYTHON_VERSION }} - - - name: Install hyperfine - run: | - wget https://github.com/sharkdp/hyperfine/releases/download/v${HYPERFINE_VERSION}/hyperfine_${HYPERFINE_VERSION}_amd64.deb - sudo dpkg -i hyperfine_${HYPERFINE_VERSION}_amd64.deb - - - name: Install other tools - run: pip install --upgrade flit poetry pipenv - - - name: Install ourself - run: | - pip install . - pip install ./backend - - - name: Benchmark - run: | - hyperfine -m 100 --warmup 10 -i pipenv - hyperfine -m 100 --warmup 10 poetry - hyperfine -m 100 --warmup 10 -i flit - hyperfine -m 100 --warmup 10 hatch - # https://github.com/marketplace/actions/alls-green#why check: # This job does nothing and is only used for the branch protection if: always() @@ -178,7 +137,6 @@ jobs: needs: - coverage - downstream - - response-time runs-on: ubuntu-latest