diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr-integration-tests.yaml similarity index 65% rename from .github/workflows/pr.yaml rename to .github/workflows/pr-integration-tests.yaml index 00d0325e2..89f4ddeaf 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr-integration-tests.yaml @@ -1,4 +1,4 @@ -name: Pull Request - Integration Tests +name: Integration Tests on: pull_request: types: [opened, edited, synchronize, reopened, ready_for_review] @@ -11,27 +11,30 @@ jobs: runs-on: ubuntu-latest steps: #---------------------------------------------- - # check-out repo and install poetry + # Check out repo #---------------------------------------------- - name: Check out repository uses: actions/checkout@v3 #---------------------------------------------- + # Get docker compose + #---------------------------------------------- + - name: Initialize Docker Compose + uses: isbang/compose-action@v1.5.1 + #---------------------------------------------- # Get changed files #---------------------------------------------- - name: Get changed files id: changed-files uses: tj-actions/changed-files@v40 - - name: Initialize Docker Compose - uses: isbang/compose-action@v1.5.1 #---------------------------------------------- - # Run integration Tests + # Get changed plugins #---------------------------------------------- - - name: Run integration tests - id: integration-tests + - name: Get changed plugins + id: changed-plugins 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. + # Collects all the plugin names that have changes. + # If there is 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") @@ -44,8 +47,15 @@ jobs: done done + echo "changed-plugins=${changed_dirs[*]}" >> $GITHUB_OUTPUT - for dir in ${changed_dirs[*]}; do + #---------------------------------------------- + # Get changed plugins + #---------------------------------------------- + - name: Run Integration Tests + id: integration-tests + run: | + for dir in ${{ steps.changed-plugins.outputs.changed-plugins }}; do echo "Running integration tests for $dir" cd $dir/integration docker compose build diff --git a/.github/workflows/pr-linting-and-unit-tests.yaml b/.github/workflows/pr-linting-and-unit-tests.yaml new file mode 100644 index 000000000..7ff010aac --- /dev/null +++ b/.github/workflows/pr-linting-and-unit-tests.yaml @@ -0,0 +1,91 @@ +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 + #---------------------------------------------- + # 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" + #---------------------------------------------- + # Get changed files + #---------------------------------------------- + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v40 + #---------------------------------------------- + # Get changed plugins + #---------------------------------------------- + - name: Get changed plugins + id: changed-plugins + run: | + + # Collects all the plugin names that have changes. + # If there is 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 "changed-plugins=${changed_dirs[*]}" >> $GITHUB_OUTPUT + #---------------------------------------------- + # Install dependencies + #---------------------------------------------- + - name: Install dependencies + id: install-dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: | + for dir in ${{ steps.changed-plugins.outputs.changed-plugins }}; do + cd $dir + poetry install --no-interaction --no-root + cd .. + done + #---------------------------------------------- + # Lint plugins + #---------------------------------------------- + - name: Lint plugins + id: lint-plugins + run: | + for dir in ${{ steps.changed-plugins.outputs.changed-plugins }}; do + cd $dir + poetry run ruff check . + cd .. + done + #---------------------------------------------- + # Unit tests + #---------------------------------------------- + - name: Unit test plugins + id: unit-tests + run: | + for dir in ${{ steps.changed-plugins.outputs.changed-plugins }}; do + cd $dir + poetry run pytest + cd .. + done diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml deleted file mode 100644 index 324380b2a..000000000 --- a/.github/workflows/push.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: Prepare -on: - push: - branches: - - "**" - -jobs: - lint: - name: "Code quality checks" - runs-on: ubuntu-latest - steps: - #---------------------------------------------- - # check-out repo and install poetry - #---------------------------------------------- - - name: Check out repository - uses: actions/checkout@v3 - - 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 ./*/; 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 diff --git a/redis_events/redis_events/v1_0/services/relay/relay.py b/redis_events/redis_events/v1_0/services/relay/relay.py index 23d0299a2..b12cbf030 100644 --- a/redis_events/redis_events/v1_0/services/relay/relay.py +++ b/redis_events/redis_events/v1_0/services/relay/relay.py @@ -119,7 +119,7 @@ async def run(self): logging.exception(f"Unexpected redis client exception: {err}") async def start(self): - """Construct the aiohttp application.""" + """Construct the http application.""" app = web.Application() app.add_routes([web.get("/", self.message_handler)]) runner = web.AppRunner(app)