Add GitHub Action test for data analytics telemetry monitoring #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Analytics Telemetry Check | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
check-for-deprecated-v1-telemetry: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} | |
- name: Get changed files | |
id: changed-files | |
run: | | |
if [[ "${{ github.event_name }}" == 'pull_request' ]]; then | |
echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_ENV | |
else | |
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_ENV | |
fi | |
- name: List changed files | |
run: | | |
for file in ${{ env.changed_files }}; do | |
echo "$file was changed" | |
done | |
- name: Check for deprecated telemetry calls | |
if: success() | |
shell: bash | |
run: | | |
echo "Checking for deprecated telemetry calls" | |
if echo "${{ env.changed_files }}" | grep -qE 'logEvent|logEvents|eventLogger\.log'; then | |
echo "Found log events in the following files:" | |
echo "${{ env.changed_files }}" | grep -E 'logEvent|logEvents|eventLogger\.log' | while read -r file ; do | |
echo "File: $file" | |
grep -En 'logEvent|logEvents|eventLogger\.log' "$file" | while read -r line ; do | |
line_number=$(echo "$line" | cut -d':' -f1) | |
matched_text=$(echo "$line" | cut -d':' -f2-) | |
echo " Line $line_number: $matched_text" | |
done | |
done | |
exit 1 | |
else | |
echo "No log events found in modified files." | |
exit 0 | |
fi |