Skip to content

threeal/pipx-install-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Pipx Install Action

Install Python packages using pipx with cache support on GitHub Actions.

Use this project to install Python packages with pipx, especially for tools written in Python that should be installed in isolated environments. After installation, it automatically saves the installed packages to a cache, speeding up installations for subsequent workflow runs.

This project includes two components: a GitHub Action that can be used directly in workflows, and a JavaScript library that provides functions for use in a JavaScript Action.

Key Features

  • Installs Python packages using pipx.
  • Caches Python package installations for reuse in subsequent workflow runs.

Using the GitHub Action

Use the following snippet to include the action in a GitHub workflow:

- name: Install Packages
  uses: threeal/[email protected]
  with:
    packages: a-package another-package

Available Inputs

Name Type Description
packages Multiple strings Names of the Python packages to be installed.

Example Usage

This example demonstrates how to use the Pipx Install Action to install Ruff in a GitHub Actions workflow:

name: Python CI
on:
  push:
jobs:
  build:
    name: Build
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/[email protected]

      - name: Install Ruff
        uses: threeal/[email protected]
        with:
          packages: ruff

      # Add more steps as needed for the workflow

Using the JavaScript Library

Install the JavaScript library using a package manager:

npm install pipx-install-action

The library provides several functions for installing and caching Python packages within GitHub Actions. Refer to the documentation for more information about the functions available in this action and their usage.

Example Usage

This example demonstrates how to use this library to install and cache Ruff in a JavaScript action:

import {
  installPipxPackage,
  restorePipxPackageCache,
  savePipxPackageCache,
} from "pipx-install-action";

const restored = await restorePipxPackageCache("ruff");
if (!restored) {
  await installPipxPackage("ruff");
  await savePipxPackageCache("ruff");
}

The code above first attempts to restore the Ruff package cache. If the cache is unavailable, it installs the package and saves it to the cache for future workflow runs.

License

This project is licensed under the terms of the MIT License.

Copyright © 2024 Alfi Maulana