Skip to content

Add unit tests to push workflow #1

Add unit tests to push workflow

Add unit tests to push workflow #1

name: Linting and Unit Tests
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
branches:
- "**"
jobs:
linting-and-unit-tests:
name: "Code quality and unit tests"
runs-on: ubuntu-latest
outputs:
changed-plugins: ${{ steps.changed-plugins.outputs.cache-hit }}
steps:
#----------------------------------------------
# Check out repo
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
#----------------------------------------------
# Get changed plugins
#----------------------------------------------

Check failure on line 22 in .github/workflows/pr-linting-and-unit-tests.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/pr-linting-and-unit-tests.yaml

Invalid workflow file

You have an error in your yaml syntax on line 22
- name: Get changed plugins
id: changed-plugins
uses: tj-actions/changed-files@v40
run: /
# This will navigate to each subdirectory and perform integration tests
# If we have a directory that isn't a plugin then it will need to skip it. Currently there is none.
declare -a changed_dirs=()
for dir in ./*/; do
current_folder=$(basename "$dir")
for changed_file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $changed_file == *"$current_folder"* ]]; then
if ! [[ ${changed_dirs[*]} =~ $current_folder ]]; then
changed_dirs+=("$current_folder")
fi
fi
done
done
echo "::set-output name=changed-plugins::${changed_dirs[*]}"
#----------------------------------------------
# Install python and poetry with cache
#----------------------------------------------
- name: Install poetry
run: pipx install poetry
id: setup-poetry
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "poetry"
#----------------------------------------------
# Install dependencies
#----------------------------------------------
- name: Install dependencies
id: install-dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
# This will navigate to each subdirectory and install the dependencies
# If we have a directory that isn't a plugin then it will need to skip it. Currently there is none.
for dir in ${{ steps.changed-plugins.changed-plugins }}; do
cd $dir
poetry install --no-interaction --no-root
cd ..
done
#----------------------------------------------
# Lint plugins
#----------------------------------------------
- name: Lint plugins
id: lint-plugins
run: |
# This will navigate to each subdirectory and perform lint checking
# If we have a directory that isn't a plugin then it will need to skip it. Currently there is none.
for dir in ./*/; do
cd $dir
poetry run ruff check .
cd ..
done
#----------------------------------------------
# Unit tests
#----------------------------------------------
- name: Unit test plugins
id: unit-tests
run: |
# This will navigate to each subdirectory and perform unit tests
# If we have a directory that isn't a plugin then it will need to skip it. Currently there is none.
for dir in ./*/; do
cd $dir
poetry run pytest
cd ..
done