Skip to content

Commit

Permalink
Move build system to rye (#98)
Browse files Browse the repository at this point in the history
## Description

Use [`rye`](https://rye-up.com) for build, test and publishing system
  • Loading branch information
hugsy authored Jul 30, 2024
1 parent 4cad30a commit 78e4676
Show file tree
Hide file tree
Showing 83 changed files with 440 additions and 1,398 deletions.
156 changes: 84 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@ on:
env:
NAME: cemu
REPO: hugsy/cemu
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
VERSION: 0.8
VERSION: 0.8.0

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os: [windows-2019, ubuntu-22.04, macos-13]
python-version: ['3.10', '3.11', '3.12']
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
outputs:
windows-latest-3-10: ${{ join(steps.*.outputs.windows-latest-3-10,'') }}
windows-latest-3-11: ${{ join(steps.*.outputs.windows-latest-3-11,'') }}
windows-latest-3-12: ${{ join(steps.*.outputs.windows-latest-3-12,'') }}
ubuntu-latest-3-10: ${{ join(steps.*.outputs.ubuntu-latest-3-10,'') }}
ubuntu-latest-3-11: ${{ join(steps.*.outputs.ubuntu-latest-3-11,'') }}
ubuntu-latest-3-12: ${{ join(steps.*.outputs.ubuntu-latest-3-12,'') }}
macos-latest-3-10: ${{ join(steps.*.outputs.macos-latest-3-10,'') }}
macos-latest-3-11: ${{ join(steps.*.outputs.macos-latest-3-11,'') }}
macos-latest-3-12: ${{ join(steps.*.outputs.macos-latest-3-12,'') }}
windows-2019-3-10: ${{ join(steps.*.outputs.windows-2019-3-10,'') }}
windows-2019-3-11: ${{ join(steps.*.outputs.windows-2019-3-11,'') }}
windows-2019-3-12: ${{ join(steps.*.outputs.windows-2019-3-12,'') }}
ubuntu-22.04-3-10: ${{ join(steps.*.outputs.ubuntu-22.04-3-10,'') }}
ubuntu-22.04-3-11: ${{ join(steps.*.outputs.ubuntu-22.04-3-11,'') }}
ubuntu-22.04-3-12: ${{ join(steps.*.outputs.ubuntu-22.04-3-12,'') }}
macos-13-3-10: ${{ join(steps.*.outputs.macos-13-3-10,'') }}
macos-13-3-11: ${{ join(steps.*.outputs.macos-13-3-11,'') }}
macos-13-3-12: ${{ join(steps.*.outputs.macos-13-3-12,'') }}

steps:
- uses: actions/checkout@v4
Expand All @@ -42,56 +41,67 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: "Install Pre-requisite"
uses: eifinger/setup-rye@v4
with:
version: 'latest'

- name: "Install Pre-requisite (Linux)"
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-22.04'
shell: bash
run: |
sudo apt update
sudo apt upgrade -y
sudo apt install -y build-essential libegl1 libgl1-mesa-glx python3-dev python3-pip python3-wheel python3-setuptools
- name: "Install Pre-requisite (macOS)"
if: matrix.os == 'macos-latest'
run: |
env
- name: "Install Pre-requisite (Windows)"
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
env
- name: Build artifact
shell: bash
run: |
mkdir build
mkdir build/bin
python --version
python -m pip --version
python -m pip install --upgrade pip setuptools wheel
python -m pip install --user --upgrade .[all]
- name: "Post build Cemu (Windows)"
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Copy-Item $env:APPDATA\Python\Python*\Scripts\cemu.exe build\bin\
- name: "Post build Cemu (Linux)"
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
cp -v ~/.local/bin/cemu build/bin/
- name: "Post build Cemu (macOS)"
if: matrix.os == 'macos-latest'
shell: bash
run: |
cp -v ~/.local/bin/cemu build/bin/ || cp -v /Users/runner/Library/Python/${{ matrix.python-version }}/bin/cemu build/bin/
- name: "Run tests"
run: |
python -m pytest tests/
sudo apt install -y build-essential libegl1 libgl1-mesa-glx
# - name: "Install Pre-requisite (macOS)"
# if: matrix.os == 'macos-13'
# run: |
# env

# - name: "Install Pre-requisite (Windows)"
# if: matrix.os == 'windows-2019'
# shell: pwsh
# run: |
# env

- run: rye fmt
- run: rye lint
- run: rye test
- run: rye build --wheel --out ./build


# - name: Build artifact
# shell: bash
# run: |
# mkdir build
# mkdir build/bin
# python --version
# python -m pip --version
# python -m pip install --upgrade pip setuptools wheel
# python -m pip install --user --upgrade .[all]

# - name: "Post build Cemu (Windows)"
# if: matrix.os == 'windows-2019'
# shell: pwsh
# run: |
# Copy-Item $env:APPDATA\Python\Python*\Scripts\cemu.exe build\bin\

# - name: "Post build Cemu (Linux)"
# if: matrix.os == 'ubuntu-22.04'
# shell: bash
# run: |
# cp -v ~/.local/bin/cemu build/bin/

# - name: "Post build Cemu (macOS)"
# if: matrix.os == 'macos-13'
# shell: bash
# run: |
# cp -v ~/.local/bin/cemu build/bin/ || cp -v /Users/runner/Library/Python/${{ matrix.python-version }}/bin/cemu build/bin/

# - name: "Run tests"
# run: |
# python -m pytest tests/

- name: Publish artifact
id: publish_artifact
Expand All @@ -102,38 +112,40 @@ jobs:

- name: Populate the successful output (Windows)
id: output_success_windows
if: ${{ matrix.os == 'windows-latest' && success() }}
if: ${{ matrix.os == 'windows-2019' && success() }}
shell: pwsh
run: |
$pyVersion = "${{ matrix.python-version }}" -replace "\.", "-"
echo "${{ matrix.os }}-$pyVersion=✅ ${{ matrix.os }} ${{ matrix.python-version }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Populate the successful output (Other)
id: output_success_other
if: ${{matrix.os != 'windows-latest' && success() }}
if: ${{matrix.os != 'windows-2019' && success() }}
shell: bash
run: |
pyVersion="$(echo -n ${{ matrix.python-version }} | tr . -)"
echo "${{ matrix.os }}-${pyVersion}=✅ ${{ matrix.os }} ${{ matrix.python-version }}" >> $GITHUB_OUTPUT
- name: Populate the failure output (Windows)
id: output_failure_windows
if: ${{matrix.os == 'windows-latest' && failure() }}
if: ${{matrix.os == 'windows-2019' && failure() }}
shell: pwsh
run: |
$pyVersion = "${{ matrix.python-version }}" -replace "\.", "-"
echo "${{ matrix.os }}-${pyVersion}=❌ ${{ matrix.os }} ${{ matrix.python-version }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Populate the failure output (Other)
id: output_failure_other
if: ${{matrix.os != 'windows-latest' && failure() }}
if: ${{matrix.os != 'windows-2019' && failure() }}
shell: bash
run: |
pyVersion="$(echo -n ${{ matrix.python-version }} | tr . -)"
echo "${{ matrix.os }}-$pyVersion=❌ ${{ matrix.os }} ${{ matrix.python-version }}" >> $GITHUB_OUTPUT
notify:
runs-on: 'ubuntu-latest'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
runs-on: 'ubuntu-22.04'
needs: build
steps:
- name: Send Discord notification
Expand All @@ -142,7 +154,7 @@ jobs:
RUN_URL: "https://github.com/${{ env.REPO }}/actions/runs/${{ github.run_id }}"
BRANCH_URL: "https://github.com/${{ env.REPO }}/tree/${{ github.ref_name }}"
AUTHOR_URL: "https://github.com/${{ github.actor }}"
uses: sarisia/actions-status-discord@v1.14.0
uses: sarisia/actions-status-discord@v1.14.5
with:
nodetail: true
title: 🚧 🚧 Summary of Build `${{ github.sha }}` for `${{ env.REPO }}` 🚧 🚧
Expand All @@ -152,15 +164,15 @@ jobs:
● Branch [`${{ github.ref_name }}`](${{ env.BRANCH_URL }})
● [Detail Page](${{ env.RUN_URL }})
${{ needs.build.outputs.windows-latest-3-10 }}
${{ needs.build.outputs.windows-latest-3-11 }}
${{ needs.build.outputs.windows-latest-3-12 }}
${{ needs.build.outputs.ubuntu-latest-3-10 }}
${{ needs.build.outputs.ubuntu-latest-3-11 }}
${{ needs.build.outputs.ubuntu-latest-3-12 }}
${{ needs.build.outputs.macos-latest-3-10 }}
${{ needs.build.outputs.macos-latest-3-11 }}
${{ needs.build.outputs.macos-latest-3-12 }}
${{ needs.build.outputs.windows-2019-3-10 }}
${{ needs.build.outputs.windows-2019-3-11 }}
${{ needs.build.outputs.windows-2019-3-12 }}
${{ needs.build.outputs.ubuntu-22.04-3-10 }}
${{ needs.build.outputs.ubuntu-22.04-3-11 }}
${{ needs.build.outputs.ubuntu-22.04-3-12 }}
${{ needs.build.outputs.macos-13-3-10 }}
${{ needs.build.outputs.macos-13-3-11 }}
${{ needs.build.outputs.macos-13-3-12 }}
color: 0x0000ff
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: "Discord Notification"
on: [pull_request, issues]
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}


jobs:
notify:
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Publish CEmu to PyPI
on:
workflow_dispatch:
push:
branches:
- main


jobs:
publish:
Expand All @@ -15,24 +18,31 @@ jobs:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Requirements
run: |
python -m pip install --upgrade build wheel
- name: "Install Pre-requisite"
uses: eifinger/setup-rye@v4
with:
version: 'latest'

- run: rye build --wheel --out ./publish

- name: Build
run: |
python -m build
# - name: Requirements
# run: |
# python -m pip install --upgrade build wheel

# - name: Build
# run: |
# python -m build

- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
print-hash: true

packages-dir: publish/
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ __pycache__
.coverage*
build
dist
/.idea
/.venv
.idea
.venv
CEmu.egg-info
htmlcov
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: '23.3.0'
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
Loading

0 comments on commit 78e4676

Please sign in to comment.