From b3a48e2373f0cf46e04a313fb6ac4ac986fb1324 Mon Sep 17 00:00:00 2001 From: bright Date: Sat, 3 May 2025 15:12:01 +0800 Subject: [PATCH 1/3] chore: add ci workflow --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b6658c6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + prepare: + - name: python version + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + with: + version: "0.6.2" + enable-cache: true + + - name: Install dependencies + run: | + uv sync --only-group dev + + - name: Lint + run: uv run ruff check uringloop tests + + - name: Run tests + run: pytest tests/ -v From 749baf0e757478fce24eff1c00f1d0ea573afe7d Mon Sep 17 00:00:00 2001 From: bright Date: Sat, 3 May 2025 16:05:27 +0800 Subject: [PATCH 2/3] chore: ci with cache --- .github/workflows/ci.yml | 101 ++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6658c6..89671be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: ci on: push: @@ -7,24 +7,81 @@ on: branches: [ main ] jobs: - prepare: - - name: python version - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install the latest version of uv - uses: astral-sh/setup-uv@v5 - with: - version: "0.6.2" - enable-cache: true - - - name: Install dependencies - run: | - uv sync --only-group dev - - - name: Lint - run: uv run ruff check uringloop tests - - - name: Run tests - run: pytest tests/ -v + ci: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 # Needed for submodule hashes + + - name: Get system info and liburing commit hash + id: cache-info + run: | + echo "sysinfo=$(uname -a | md5sum | cut -d ' ' -f1)" >> $GITHUB_OUTPUT + echo "liburing_hash=$(cd libs && git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Cache Python dependencies + id: cache-python + uses: actions/cache@v3 + with: + path: | + .venv + ~/.cache/uv + key: ${{ runner.os }}-py-${{ hashFiles('uv.lock') }} + + - name: Cache liburing build + id: cache-liburing + uses: actions/cache@v3 + with: + path: libs/ + key: ${{ steps.cache-info.outputs.os }}-${{ steps.cache-info.outputs.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }} + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Build liburing (if cache miss) + if: steps.cache-liburing.outputs.cache-hit != 'true' + run: | + cd libs + ./configure + make + + - name: Save liburing cache + if: steps.cache-liburing.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: libs/ + key: ${{ steps.cache-info.outputs.os }}-${{ steps.cache-info.outputs.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }} + + - name: Install liburing (always) + run: | + cd libs + sudo make install + + - name: Install UV + uses: astral-sh/setup-uv@v5 + with: + version: "0.6.2" + enable-cache: true + + - name: Install Python dependencies (if cache miss) + if: steps.cache-python.outputs.cache-hit != 'true' + run: uv sync --group dev + + - name: Save Python dependencies cache + if: steps.cache-python.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: | + .venv + ~/.cache/uv + key: ${{ runner.os }}-py-${{ hashFiles('uv.lock') }} + + - name: Lint + run: uv run ruff check uringloop tests + + - name: Run tests + run: uv run pytest tests/ -v From 7651b47b562ff432ac4d4912c280939224b768f5 Mon Sep 17 00:00:00 2001 From: bright Date: Sat, 3 May 2025 16:25:45 +0800 Subject: [PATCH 3/3] chore: action --- .github/actions/prepare/action.yml | 78 ++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 67 ++----------------------- .github/workflows/publish.yml | 27 +++-------- 3 files changed, 87 insertions(+), 85 deletions(-) create mode 100644 .github/actions/prepare/action.yml diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml new file mode 100644 index 0000000..688ff7f --- /dev/null +++ b/.github/actions/prepare/action.yml @@ -0,0 +1,78 @@ +name: "Prepare Build Environment" +description: "Checkout, cache, build liburing, and install Python deps" +runs: + using: "composite" + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Get system info and liburing commit hash + id: cache-info + shell: bash + run: | + echo "sysinfo=$(uname -a | md5sum | cut -d ' ' -f1)" >> $GITHUB_OUTPUT + echo "liburing_hash=$(cd libs && git rev-parse HEAD)" >> $GITHUB_OUTPUT + + - name: Cache Python dependencies + id: cache-python + uses: actions/cache@v3 + with: + path: | + .venv + ~/.cache/uv + key: ${{ runner.os }}-py-${{ hashFiles('uv.lock') }} + + - name: Cache liburing build + id: cache-liburing + uses: actions/cache@v3 + with: + path: libs/ + key: ${{ steps.cache-info.outputs.os }}-${{ steps.cache-info.outputs.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }} + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Build liburing (if cache miss) + if: steps.cache-liburing.outputs.cache-hit != 'true' + shell: bash + run: | + cd libs + ./configure + make + + - name: Save liburing cache + if: steps.cache-liburing.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: libs/ + key: ${{ steps.cache-info.outputs.os }}-${{ steps.cache-info.outputs.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }} + + - name: Install liburing (always) + shell: bash + run: | + cd libs + sudo make install + + - name: Install UV + uses: astral-sh/setup-uv@v5 + with: + version: "0.6.2" + enable-cache: true + + - name: Install Python dependencies (if cache miss) + if: steps.cache-python.outputs.cache-hit != 'true' + shell: bash + run: uv sync --group dev + + - name: Save Python dependencies cache + if: steps.cache-python.outputs.cache-hit != 'true' + uses: actions/cache/save@v3 + with: + path: | + .venv + ~/.cache/uv + key: ${{ runner.os }}-py-${{ hashFiles('uv.lock') }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89671be..0e74288 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,71 +14,10 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - fetch-depth: 0 # Needed for submodule hashes + fetch-depth: 0 - - name: Get system info and liburing commit hash - id: cache-info - run: | - echo "sysinfo=$(uname -a | md5sum | cut -d ' ' -f1)" >> $GITHUB_OUTPUT - echo "liburing_hash=$(cd libs && git rev-parse HEAD)" >> $GITHUB_OUTPUT - - - name: Cache Python dependencies - id: cache-python - uses: actions/cache@v3 - with: - path: | - .venv - ~/.cache/uv - key: ${{ runner.os }}-py-${{ hashFiles('uv.lock') }} - - - name: Cache liburing build - id: cache-liburing - uses: actions/cache@v3 - with: - path: libs/ - key: ${{ steps.cache-info.outputs.os }}-${{ steps.cache-info.outputs.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }} - - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Build liburing (if cache miss) - if: steps.cache-liburing.outputs.cache-hit != 'true' - run: | - cd libs - ./configure - make - - - name: Save liburing cache - if: steps.cache-liburing.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: libs/ - key: ${{ steps.cache-info.outputs.os }}-${{ steps.cache-info.outputs.arch }}-liburing-${{ steps.cache-info.outputs.liburing_hash }} - - - name: Install liburing (always) - run: | - cd libs - sudo make install - - - name: Install UV - uses: astral-sh/setup-uv@v5 - with: - version: "0.6.2" - enable-cache: true - - - name: Install Python dependencies (if cache miss) - if: steps.cache-python.outputs.cache-hit != 'true' - run: uv sync --group dev - - - name: Save Python dependencies cache - if: steps.cache-python.outputs.cache-hit != 'true' - uses: actions/cache/save@v3 - with: - path: | - .venv - ~/.cache/uv - key: ${{ runner.os }}-py-${{ hashFiles('uv.lock') }} + - name: Prepare environment + uses: ./.github/actions/prepare - name: Lint run: uv run ruff check uringloop tests diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 36f2e4b..26e9c7f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,33 +10,18 @@ permissions: jobs: release-build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive # Initializes and fetches submodules - fetch-depth: 0 # Needed for submodule hashes - - - uses: actions/setup-python@v5 + - name: Checkout Repo + uses: actions/checkout@v4 with: - python-version: "3.12" + submodules: recursive + fetch-depth: 0 - - name: Install the liburing - run: | - cd libs - ./configure - make - sudo make install - - - name: Install the latest version of uv - uses: astral-sh/setup-uv@v5 - with: - version: "0.6.2" - enable-cache: true + - name: Prepare environment + uses: ./.github/actions/prepare - name: Build release distributions run: | - uv sync --group dev uv build -v --sdist - name: Upload distributions