diff --git a/.github/actions/sync-uv/action.yml b/.github/actions/sync-uv/action.yml new file mode 100644 index 0000000000..8b063855a6 --- /dev/null +++ b/.github/actions/sync-uv/action.yml @@ -0,0 +1,67 @@ +name: 'Sync UV Action' +description: 'Install and sync UV with specified groups and extras' +author: 'Pycord Development ' +inputs: + groups: + description: "Comma-separated list of groups to sync" + required: false + default: '' + extras: + description: "Comma-separated list of extras to sync" + required: false + default: '' + frozen: + description: "Whether to sync with frozen dependencies" + required: false + default: 'true' + no_python_downloads: + description: "Whether to avoid downloading Python versions" + required: false + default: 'true' + +runs: + using: "composite" + steps: + - name: "Install uv" + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + + - name: "Run UV sync" + shell: bash + run: | + cmd_args=("uv" "sync") + + # groups + set +e + if [ -n "${{ inputs.groups }}" ]; then + IFS=',' read -ra PARSED_GROUPS <<< "${{ inputs.groups }}" + for group in "${PARSED_GROUPS[@]}"; do + group=$(echo "$group" | xargs) + if [ -n "$group" ]; then + cmd_args+=("--group" "$group") + fi + done + fi + set -e + echo "Groups: ${PARSED_GROUPS[*]}" + + # extras + set +e + if [ -n "${{ inputs.extras }}" ]; then + IFS=',' read -ra PARSED_EXTRAS <<< "${{ inputs.extras }}" + for extra in "${PARSED_EXTRAS[@]}"; do + extra=$(echo "$extra" | xargs) + if [ -n "$extra" ]; then + cmd_args+=("--extra" "$extra") + fi + done + fi + set -e + echo "Extras: ${PARSED_EXTRAS[*]}" + + echo "Executing: ${cmd_args[*]}" + "${cmd_args[@]}" + env: + UV_NO_PYTHON_DOWNLOADS: ${{ inputs.no_python_downloads == 'true' && '1' || '' }} + UV_FROZEN: ${{ inputs.frozen == 'true' && '1' || '' }} \ No newline at end of file diff --git a/.github/workflows/docs-checks.yml b/.github/workflows/docs-checks.yml index a875ab3083..223e4f4ac4 100644 --- a/.github/workflows/docs-checks.yml +++ b/.github/workflows/docs-checks.yml @@ -40,13 +40,11 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev --group docs + groups: 'dev,docs' - name: "Check Links" env: SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build diff --git a/.github/workflows/docs-localization-download.yml b/.github/workflows/docs-localization-download.yml index 3697464152..5d495b38e5 100644 --- a/.github/workflows/docs-localization-download.yml +++ b/.github/workflows/docs-localization-download.yml @@ -19,13 +19,12 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev --group docs --extra speed --extra voice + groups: 'dev,docs' + extras: 'speed,voice' - name: "Get locales" env: SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build diff --git a/.github/workflows/docs-localization-upload.yml b/.github/workflows/docs-localization-upload.yml index 73dd5c855b..970cf10782 100644 --- a/.github/workflows/docs-localization-upload.yml +++ b/.github/workflows/docs-localization-upload.yml @@ -24,13 +24,12 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev --group docs --extra speed --extra voice + groups: 'dev,docs' + extras: 'speed,voice' - name: "Get locales" env: SPHINXBUILD: ${{ github.workspace }}/.venv/bin/sphinx-build diff --git a/.github/workflows/lib-checks.yml b/.github/workflows/lib-checks.yml index e95c84d133..034a042c50 100644 --- a/.github/workflows/lib-checks.yml +++ b/.github/workflows/lib-checks.yml @@ -40,13 +40,11 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev + groups: 'dev' - name: "Run codespell" run: uv run codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \ @@ -60,13 +58,11 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev + groups: 'dev' - name: "Run ruff linter check" run: uv run ruff check . - name: "Run ruff formatter check" @@ -80,13 +76,11 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev + groups: 'dev' - name: "Setup cache" id: cache-mypy uses: actions/cache@v4 @@ -114,13 +108,10 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev + groups: 'dev' - name: "Run tests" run: uv run tox diff --git a/.github/workflows/sync-guild-features.yml b/.github/workflows/sync-guild-features.yml index d9c04b47fa..7d9ef71488 100644 --- a/.github/workflows/sync-guild-features.yml +++ b/.github/workflows/sync-guild-features.yml @@ -23,13 +23,11 @@ jobs: - name: "Setup Python" uses: actions/setup-python@v6 with: - python-version: "3.14" - - name: "Install uv" - uses: astral-sh/setup-uv@v7 + python-version: "3.13" + - name: "Setup UV" + uses: ./.github/actions/sync-uv with: - enable-cache: true - - name: Sync dependencies - run: uv sync --no-python-downloads --group dev --group ci + groups: 'dev,ci' - name: "Run guild features sync" run: uv run python -m scripts.sync_guild_features env: