Run tests and (if on main branch) send email digest #1455
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: Run tests and (if on main branch) send email digest | |
on: | |
push: | |
schedule: | |
- cron: '30 4 * * *' # 04:30 every day | |
jobs: | |
test-and-send: | |
name: Run tests and run item finder | |
runs-on: ubuntu-latest | |
env: | |
HOME_POSTCODE: ${{ secrets.HOME_POSTCODE }} | |
OFFICE_POSTCODE: ${{ secrets.OFFICE_POSTCODE }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements_dev.txt | |
- name: Run unit tests | |
run: | | |
pytest ebay_multilocation_item_notifier/tests/unit/ | |
env: | |
PYTEST_ADDOPTS: --color=yes # Force colour output | |
- name: Run integration tests | |
run: | | |
pytest ebay_multilocation_item_notifier/tests/integration/ | |
env: | |
EMAIL_RECIPIENT_ADDRESS: ${{ secrets.EMAIL_RECIPIENT_ADDRESS }} | |
EMAIL_RECIPIENT_NAME: ${{ secrets.EMAIL_RECIPIENT_NAME }} | |
EMAIL_SENDER_ADDRESS: ${{ secrets.EMAIL_SENDER_ADDRESS }} | |
EMAIL_SENDER_NAME: ${{ secrets.EMAIL_SENDER_NAME }} | |
EMAIL_SMTP_HOST: ${{ secrets.EMAIL_SMTP_HOST }} | |
EMAIL_SMTP_PASSWORD: ${{ secrets.EMAIL_SMTP_PASSWORD }} | |
EMAIL_SMTP_USERNAME: ${{ secrets.EMAIL_SMTP_USERNAME }} | |
PYTEST_ADDOPTS: --color=yes # Force colour output | |
- name: Send digest email | |
if: github.ref == 'refs/heads/main' | |
run: | | |
python ebay_multilocation_item_notifier/item_notifier.py | |
env: | |
EMAIL_RECIPIENT_ADDRESS: ${{ secrets.EMAIL_RECIPIENT_ADDRESS }} | |
EMAIL_RECIPIENT_NAME: ${{ secrets.EMAIL_RECIPIENT_NAME }} | |
EMAIL_SENDER_ADDRESS: ${{ secrets.EMAIL_SENDER_ADDRESS }} | |
EMAIL_SENDER_NAME: ${{ secrets.EMAIL_SENDER_NAME }} | |
EMAIL_SMTP_HOST: ${{ secrets.EMAIL_SMTP_HOST }} | |
EMAIL_SMTP_PASSWORD: ${{ secrets.EMAIL_SMTP_PASSWORD }} | |
EMAIL_SMTP_USERNAME: ${{ secrets.EMAIL_SMTP_USERNAME }} | |
keep-repo-active: | |
name: Keep repo active to persist schedule trigger | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: gautamkrishnar/keepalive-workflow@v2 # Uses GitHub API to keep the repository active (in order to persist the GitHub Actions `schedule` trigger) | |
with: | |
time_elapsed: "50" # Default is 45 |