From 74474534bc8df1a667bc0aa226ee761ed1a99cfc Mon Sep 17 00:00:00 2001 From: "luqazino@gmail.com" Date: Mon, 16 Jan 2023 14:16:55 +0100 Subject: [PATCH] Minor Fix for branch name check --- .github/workflows/branch-name-check.yml | 2 +- .github/workflows/unit-test.yml | 43 +++++-------------------- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/.github/workflows/branch-name-check.yml b/.github/workflows/branch-name-check.yml index 9a0f5f364abb..87ac7fdd36a6 100644 --- a/.github/workflows/branch-name-check.yml +++ b/.github/workflows/branch-name-check.yml @@ -5,7 +5,7 @@ on: branches: - develop - main - types: [opened, edited] + types: [opened, synchronize, edited] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index eca182bbca06..08ab8472086b 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,12 +20,10 @@ concurrency: jobs: check-files-changed: - name: Check for changes to python files and the openbb_terminal folder + name: Check for changes runs-on: ubuntu-latest if: github.event.pull_request.merged != true outputs: - python-changes: ${{ steps.python-changes.outputs.python-changes }} - folder-changes: ${{ steps.folder-changes.outputs.folder-changes }} check-changes: ${{ steps.check-changes.outputs.check-changes }} steps: - name: Checkout @@ -36,48 +34,23 @@ jobs: # to be able to push to GitHub. persist-credentials: false - # Check for changes to Python files to avoid running tests unnecessarily - - name: python file check - id: python-changes - run: | - # Extract the source and target branches for the PR - source_branch=$(jq -r .pull_request.head.ref "$GITHUB_EVENT_PATH") - target_branch=$(jq -r .pull_request.base.ref "$GITHUB_EVENT_PATH") - - # Check for changes to Python code to avoid running tests unnecessarily - if git diff --name-only origin/$target_branch HEAD | grep -E "\.py$"; then - echo "python-changes=true" >> $GITHUB_OUTPUT - else - echo "python-changes=false" >> $GITHUB_OUTPUT - fi - - # Check for changes to the openbb_terminal folder to avoid running tests unnecessarily - - name: Check for changes to the openbb_terminal folder - id: folder-changes + # Check for changes to python files, lockfiles and the openbb_terminal folder + - name: Check for changes to files to trigger unit test + id: check-changes run: | source_branch=$(jq -r .pull_request.head.ref "$GITHUB_EVENT_PATH") target_branch=$(jq -r .pull_request.base.ref "$GITHUB_EVENT_PATH") - if git diff --name-only origin/$target_branch HEAD | grep -E "openbb_terminal\/.*"; then - echo "folder-changes=true" >> $GITHUB_OUTPUT - else - echo "folder-changes=false" >> $GITHUB_OUTPUT - fi - - # combine the two checks into one - - name: Check for changes to python files or the openbb_terminal folder - id: check-changes - run: | - if [ ${{ steps.python-changes.outputs.python-changes }} == 'true' ] || [ ${{ steps.folder-changes.outputs.folder-changes }} == 'true' ]; then + if git diff --name-only origin/$target_branch HEAD | grep -E ".py$|openbb_terminal\/.*|pyproject.toml|poetry.lock|requirements.txt|requirements-full.txt"; then echo "check-changes=true" >> $GITHUB_OUTPUT else echo "check-changes=false" >> $GITHUB_OUTPUT fi - - name: Show Output result for python-changes + - name: Show output of previous step run: | - echo "python-changes=${{ steps.python-changes.outputs.python-changes }}" - echo "folder-changes=${{ steps.folder-changes.outputs.folder-changes }}" + # echo "python-changes=${{ steps.python-changes.outputs.python-changes }}" + # echo "folder-changes=${{ steps.folder-changes.outputs.folder-changes }}" echo "check-changes=${{ steps.check-changes.outputs.check-changes }}" base-test: