Validate Event Sources #45
This file contains hidden or 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: Validate Event Sources | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 9 * * *' # 9am UTC daily | |
| jobs: | |
| validate-events: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend/scripts | |
| env: | |
| PRODUCTION: '1' | |
| DJANGO_SETTINGS_MODULE: 'config.settings.development' | |
| DATABASE_URL: ${{ secrets.SUPABASE_DB_URL }} | |
| POSTGRES_DB: ${{ secrets.POSTGRES_DB }} | |
| POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
| POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
| POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} | |
| POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }} | |
| SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| pip install --prefer-binary -r ../requirements.txt | |
| - name: Create logs directory | |
| run: mkdir -p logs | |
| - name: Purge old IgnoredPost rows | |
| run: | | |
| python purge_old_ignored_posts.py | |
| - name: Run validation script | |
| run: | | |
| python validate_event_sources.py --school "University of Waterloo" --workers 10 2>&1 | tee logs/validation.log | |
| continue-on-error: false | |
| - name: Upload logs as artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: validation-logs-${{ github.run_number }} | |
| path: | | |
| logs/ | |
| *.log | |
| retention-days: 30 | |
| - name: Check for deleted events | |
| if: always() | |
| run: | | |
| if grep -q "Events deleted:" logs/validation.log; then | |
| DELETED=$(grep "Events deleted:" logs/validation.log | awk '{print $NF}') | |
| echo "::notice::Deleted $DELETED invalid events" | |
| fi |