Universal setup action

pull/388/head
Wyatt Stanke 11 months ago
parent e851966295
commit 3456159e84
No known key found for this signature in database
GPG Key ID: CE6BA5FFF135536D

@ -1,15 +1,20 @@
--- name: "Setup"
name: "Init Environment" description: Setup the environment for the project
description: "Initialize environment for tests" inputs:
python-version:
description: "Python version to use"
required: false
default: "3.10"
runs: runs:
using: "composite" using: "composite"
steps: steps:
- name: Checkout actions - name: Checkout actions
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ inputs.python-version }}
- name: Install and configure Poetry - name: Install and configure Poetry
uses: snok/install-poetry@v1 uses: snok/install-poetry@v1
with: with:
@ -31,3 +36,8 @@ runs:
source .venv/bin/activate source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV echo PATH=$PATH >> $GITHUB_ENV
shell: bash shell: bash
- name: "Install apt dependencies"
run: |
sudo apt-get update
sudo apt-get install -y python3-opencv
shell: bash

@ -17,14 +17,7 @@ jobs:
&& ${{ contains(github.event.pull_request.labels.*.name, 'release') }} && ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Install poetry
run: pipx install poetry==$POETRY_VERSION
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "poetry"
- name: Build project for distribution - name: Build project for distribution
run: poetry build run: poetry build
- name: Check Version - name: Check Version

@ -10,10 +10,7 @@ jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install mkdocs-material - run: pip install mkdocs-material
- run: pip install mkdocs-glightbox - run: pip install mkdocs-glightbox
- run: pip install "mkdocstrings[python]" - run: pip install "mkdocstrings[python]"

@ -5,21 +5,19 @@ jobs:
yaml-lint: yaml-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out source repository - uses: ./.github/library/setup
uses: actions/checkout@v4
- name: yaml Lint - name: yaml Lint
uses: ibiqlik/action-yamllint@v3 uses: ibiqlik/action-yamllint@v3
flake8-lint: flake8-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: flake8 Lint name: flake8 Lint
steps: steps:
- name: Check out source repository - uses: ./.github/library/setup
uses: actions/checkout@v4
- name: Set up Python environment - name: Set up Python environment
uses: py-actions/flake8@v2 uses: py-actions/flake8@v2
ruff-lint: ruff-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: ruff Lint name: ruff Lint
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- uses: chartboost/ruff-action@v1 - uses: chartboost/ruff-action@v1

@ -8,11 +8,7 @@ jobs:
matrix: matrix:
python-version: ["3.10", "3.11", "3.12"] python-version: ["3.10", "3.11", "3.12"]
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip

@ -14,16 +14,7 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest swarms
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
# stop the build if there are Python syntax errors or undefined names # stop the build if there are Python syntax errors or undefined names

@ -16,17 +16,9 @@ jobs:
matrix: matrix:
python-version: ["3.10", "3.11", "3.12"] python-version: ["3.10", "3.11", "3.12"]
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade swarms
python -m pip install flake8 pytest swarms
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8 - name: Lint with flake8
run: | run: |
# stop the build if there are Python syntax errors or undefined names # stop the build if there are Python syntax errors or undefined names

@ -9,15 +9,7 @@ jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package - name: Build package
run: python -m build run: python -m build
- name: Publish package - name: Publish package

@ -14,15 +14,8 @@ jobs:
- "3.10" - "3.10"
- "3.11" - "3.11"
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: "snok/install-poetry@v1"
- name: Install dependencies
run: poetry install --no-root --no-interaction
- name: Run tests - name: Run tests
run: pytest run: pytest

@ -15,10 +15,7 @@ jobs:
name: pytype 3.10 name: pytype 3.10
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Run pytype - name: Run pytype
run: | run: |
python --version python --version
@ -29,10 +26,7 @@ jobs:
name: Check format with black name: Check format with black
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Check format - name: Check format
run: | run: |
python --version python --version

@ -8,15 +8,10 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - uses: ./.github/library/setup
uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: "3.10" python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest
- name: Run unit tests - name: Run unit tests
run: pytest run: pytest

@ -9,16 +9,10 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: ./.github/library/setup
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install -r requirements.txt
pip install pytest pip install pytest
pip install swarms
- name: Run Python unit tests - name: Run Python unit tests
run: pytest run: pytest
- name: Verify that the Docker image for the action builds - name: Verify that the Docker image for the action builds

Loading…
Cancel
Save