Skip to content

Commit

Permalink
Fix skipped build tests
Browse files Browse the repository at this point in the history
- Always run builds when pushing to the main branch
- Correctly diff watch files for PRs whose source branch is also 'main'
  • Loading branch information
Jake-Carter committed Jan 10, 2024
1 parent bcdd469 commit 3a98ba9
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/Build_Examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
runs-on:
- ubuntu-latest

env:
SOURCE_BRANCH: ${{github.ref_name}}
TARGET_BRANCH: ${{github.event.pull_request.base.ref}}

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
Expand All @@ -34,8 +38,10 @@ jobs:
repository: '${{ github.event.pull_request.head.repo.full_name }}'

- name: Check watch files
id: check_watch
id: check_watch
run: |
echo SOURCE_BRANCH = $SOURCE_BRANCH
echo TARGET_BRANCH = $TARGET_BRANCH
# Determine if we need to run the test
RUN_TEST=0
Expand All @@ -44,6 +50,11 @@ jobs:
RUN_TEST=1
fi
if [[ $SOURCE_BRANCH == "main" ]]; then
echo "Pushed to main, running test"
RUN_TEST=1
fi
# Check for changes made to these files
WATCH_FILES="\
Build_Examples.yml \
Expand All @@ -57,8 +68,16 @@ jobs:
makefile \
Makefile"
# Get the diff from main
CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/origin/main)
if [[ -n $TARGET_BRANCH ]]; then
# We are in a PR. Need to check changes against the target branch.
echo "Comparing PR against target branch: $TARGET_BRANCH"
echo "Adding remote '$GITHUB_SERVER_URL/$GITHUB_REPOSITORY' as 'upstream'"
git remote add upstream $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
echo "Fetching $TARGET_BRANCH"
git fetch upstream $TARGET_BRANCH
echo "diffing files"
CHANGE_FILES=$(git diff --ignore-submodules --name-only remotes/upstream/$TARGET_BRANCH)
fi
echo "Watching these locations and files"
echo $WATCH_FILES
Expand Down

0 comments on commit 3a98ba9

Please sign in to comment.