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

Minor Fix for branch name check #3979

Merged
merged 1 commit into from
Jan 16, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/branch-name-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- develop
- main
types: [opened, edited]
types: [opened, synchronize, edited]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
43 changes: 8 additions & 35 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down