Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/6395 create readmemd files #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Test Python

This GitHub Action runs tests for Python applications and provides a reusable testing environment.

## Description

This Action runs tests for Python projects that can be executed on a specified operating system and Python version. It also supports optional installation of FFMPEG and setting up caching for dependencies.

## Inputs

| Name | Description | Required | Default |
| ----------------- | ------------------------------------------------- | -------- | ------- |
| `test_path` | The path to the files or directories to be tested | Yes | None |
| `os` | The operating system on which to run the tests | Yes | None |
| `py-version` | The Python version to use for the tests | Yes | None |
| `ffmpeg-required` | Indicates whether FFMPEG should be installed | Yes | None |

## Usage

Create a workflow file (e.g., `.github/workflows/test.yml`) and use this Action as follows:

```yaml
name: Test Python Application

on:
push:
branches:
- main

jobs:
test:
runs-on: ${{ inputs.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Test Python
uses: platomo/test-python-app-action@main
with:
test_path: "src/"
os: "ubuntu-latest"
py-version: "3.9"
ffmpeg-required: true
```

## Workflow Steps

1. **Checkout Repository**: Checks out the code from the repository.
2. **Install FFMPEG** (optional): Installs FFMPEG if `ffmpeg-required` is set to `true`.
3. **Set up Python**: Configures the specified Python version and enables `pip` caching.
4. **Install Python Dependencies**: Installs required dependencies based on `requirements.txt` and `requirements-dev.txt` files (if available).
5. **Linting**: Checks the code format with `flake8`.
6. **Static Type Checking**: Performs type checking with `mypy`.
7. **Run Tests**: Executes tests using `pytest` and generates coverage for the specified `test_path`.

## Required Permissions

This Action requires access to the source code to perform tests, linting, and type checking.
9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ inputs:
py-version:
description: "The python version to run the tests on"
required: true


ffmpeg-required:
description: "Bool to check if FFMPEG needs to be installed"
required: true

runs:
using: composite
Expand All @@ -23,7 +24,7 @@ runs:
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py-version }}
cache: 'pip'
cache: "pip"
- name: Install Python dependencies
shell: bash
run: |
Expand All @@ -44,4 +45,4 @@ runs:
mypy .
- name: Run pytest
shell: bash
run: pytest --cov=${{ inputs.test_path }} tests/
run: pytest --cov=${{ inputs.test_path }} tests/