Skip to content

Commit

Permalink
Improve CI (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored May 27, 2024
1 parent 5b4d110 commit 11eb42e
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 63 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build-distributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/build-hatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/build-hatchling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
tags:
- hatchling-v*

env:
PYTHON_VERSION: "3.12"

jobs:
build:
name: Build wheels and source distribution
Expand All @@ -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
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions .github/workflows/docs-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 5 additions & 47 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ concurrency:
cancel-in-progress: true

env:
STABLE_PYTHON_VERSION: '3.11'
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -136,49 +130,13 @@ 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()

needs:
- coverage
- downstream
- response-time

runs-on: ubuntu-latest

Expand Down

0 comments on commit 11eb42e

Please sign in to comment.