Skip to content

Commit

Permalink
Merge pull request #58 from piotrnarajowski/wid_pr3
Browse files Browse the repository at this point in the history
wid pr 3
  • Loading branch information
piotrnarajowski authored Jul 23, 2024
2 parents f1bb5a2 + fff6042 commit 8ab6658
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
10 changes: 4 additions & 6 deletions .github/check_for_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ def main():
changed_files = result.stdout.strip().split('\n')
except subprocess.CalledProcessError as e:
print(f"Error running git diff: {e.stderr}")
changed_files = []
sys.exit(1)

# Check if the target directory exists
if not changed_files or all(file == '' for file in changed_files):
print("No changes detected in autopts/wid directory.")
changed_files = []
else:
os.environ['CHANGES_DETECTED'] = '1'
with open('changes_detected.txt', 'w') as f:
f.write(os.environ['CHANGES_DETECTED'])
sys.exit(1)

filenames = []

Expand All @@ -61,6 +57,8 @@ def main():
with open('changed_files_formatted.txt', 'w') as f:
f.write(' '.join(filenames))

sys.exit(0)


if __name__ == "__main__":
main()
22 changes: 5 additions & 17 deletions .github/workflows/run_cron_from_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,20 @@ jobs:
with:
fetch-depth: 2

- name: Print initial CHANGES_DETECTED value
run:
echo "$CHANGES_DETECTED"
echo ${{ env.CHANGES_DETECTED }}

- name: Check for changes in autopts/wid directory
id: check_changes
run: |
python .github/check_for_changes.py
echo ${{ env.CHANGES_DETECTED }}
echo "$CHANGES_DETECTED"
echo "Script exited with code $?"
- name: Set output
id: set_output
if: ${{ steps.check_changes.outcome == 'success' }}
run: |
if [ "$CHANGES_DETECTED" -eq 1 ]; then
echo "$CHANGES_DETECTED"
echo "changed_files=$(cat changed_files_formatted.txt)" >> $GITHUB_OUTPUT
- name: Print changed
run: |
if [ "$CHANGES_DETECTED" -eq 1 ]; then
echo "Changed files: ${{ steps.set_output.outputs.changed_files }}"
echo "changed_files=$(cat changed_files_formatted.txt)" >> $GITHUB_OUTPUT
- name: Post comment on PR
if: env.CHANGES_DETECTED == '1'
if: ${{ steps.check_changes.outcome == 'success' }}
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -53,7 +41,7 @@ jobs:
\#AutoPTS run mynewt ${{ steps.set_output.outputs.changed_files }} --test-case-limit 10
- name: Post comment on PR
if: env.CHANGES_DETECTED == '1'
if: ${{ steps.check_changes.outcome == 'success' }}
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 8ab6658

Please sign in to comment.