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

wid pr 3 #58

Merged
merged 1 commit into from
Jul 23, 2024
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
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
Loading