-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI workflow for linting, type checking, and testing with multiple…
… Python versions
- Loading branch information
1 parent
d4e0614
commit 7327f65
Showing
4 changed files
with
232 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: 'Prepare environment' | ||
description: 'Prepare environment' | ||
|
||
inputs: | ||
python-version: | ||
description: 'Python version to use' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup PATH | ||
run: echo "/home/runner/.local/bin" >> $GITHUB_PATH | ||
shell: bash | ||
|
||
- name: Install Poetry | ||
run: pipx install poetry==$(head -n 1 .poetry-version) | ||
shell: bash | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
cache: 'poetry' | ||
|
||
- name: Clear Poetry cache | ||
run: poetry cache clear --all pypi | ||
shell: bash | ||
|
||
- name: Install dependencies and package | ||
run: poetry install --no-interaction --no-ansi | ||
shell: bash | ||
|
||
# Setup Node.js for JavaScript tests | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
|
||
# Install Node.js dependencies | ||
- name: Install Node.js dependencies | ||
run: npm install | ||
shell: bash | ||
|
||
# Setup Go for Go language tests | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.21' | ||
cache: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Build Wheels | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build psutil wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
include: | ||
# Linux builds | ||
- os: ubuntu-latest | ||
python-version: '3.10' | ||
- os: ubuntu-latest | ||
python-version: '3.11' | ||
- os: ubuntu-latest | ||
python-version: '3.12' | ||
|
||
# Windows builds | ||
- os: windows-latest | ||
python-version: '3.10' | ||
- os: windows-latest | ||
python-version: '3.11' | ||
- os: windows-latest | ||
python-version: '3.12' | ||
|
||
# macOS builds | ||
- os: macos-latest | ||
python-version: '3.10' | ||
- os: macos-latest | ||
python-version: '3.11' | ||
- os: macos-latest | ||
python-version: '3.12' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install build dependencies | ||
run: | | ||
python -m pip install pip wheel | ||
shell: bash | ||
|
||
- name: Build psutil wheel | ||
run: | | ||
# Create dist directory | ||
mkdir -p dist | ||
# Build psutil wheel | ||
pip wheel psutil==5.8.0 --wheel-dir dist/ | ||
shell: bash | ||
|
||
- name: Upload to GitHub Actions | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: dist-${{ matrix.os }}-py${{ matrix.python-version }} | ||
path: dist/* | ||
|
||
release: | ||
needs: build_wheels | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Download all artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: dist-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- release | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint: | ||
name: Lint with ruff | ||
runs-on: arc-runners-small | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- uses: ./.github/workflows/actions/prepare | ||
with: | ||
python-version: "3.11" | ||
- name: Check files using the ruff formatter | ||
run: | | ||
poetry run ruff check --fix --unsafe-fixes --preview --exit-zero . | ||
poetry run ruff format . | ||
shell: bash | ||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
fetch: false | ||
default_author: github_actions | ||
message: 'Backend: Auto format' | ||
add: '.' | ||
|
||
mypy: | ||
name: Static Type Checking | ||
runs-on: arc-runners-small | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/workflows/actions/prepare | ||
with: | ||
python-version: "3.12" | ||
- name: Mypy | ||
run: poetry run mypy . | ||
shell: bash | ||
|
||
test: | ||
name: Run unit test on ${{ matrix.os }} with Python ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
# Self-hosted runner | ||
- os: [ self-hosted, small ] | ||
python-version: "3.10" | ||
- os: [ self-hosted, small ] | ||
python-version: "3.11" | ||
- os: [ self-hosted, small ] | ||
python-version: "3.12" | ||
|
||
# Windows | ||
- os: windows-latest | ||
python-version: "3.10.11" | ||
- os: windows-latest | ||
python-version: "3.11" | ||
- os: windows-latest | ||
python-version: "3.12" | ||
|
||
# macOS (arm64) | ||
- os: macos-14 | ||
python-version: "3.11" | ||
- os: macos-14 | ||
python-version: "3.12" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/workflows/actions/prepare | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Run Tests | ||
run: poetry run python tests/testing.py | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters