Run pytest #17
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 pytest | |
on: | |
# push: | |
# branches: | |
# - main | |
# - master | |
# paths: | |
# - '**/*.py' | |
# pull_request: | |
# branches: | |
# - main | |
# - master | |
# paths: | |
# - '**/*.py' | |
workflow_dispatch: | |
env: | |
REGISTRY_URL: ${{ vars.REGISTRY_URL }} | |
REGISTRY_USER: ${{ github.repository_owner }} | |
IMAGE: ${{ vars.IMAGE }} | |
PRIV_KEY_B64: ${{ secrets.PRIV_KEY_B64 }} | |
PUB_KEY_B64: ${{ secrets.PUB_KEY_B64 }} | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
# TODO: avoid hardcoding the image name | |
services: | |
server: | |
image: ghcr.io/pythoninthegrass/meetup-bot | |
container: | |
image: python:3.11.9-slim-bullseye | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install system dependencies | |
run: | | |
apt-get -qq update \ | |
&& apt-get -qq install \ | |
--no-install-recommends -y \ | |
curl \ | |
gcc \ | |
git \ | |
python3-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip pytest | |
python -m pip install -r requirements.txt | |
- name: Wait for server to be ready | |
run: | | |
timeout 60s bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' server:3000/healthz)" != "200" ]]; do sleep 5; done' || false | |
- name: Run pytest | |
run: pytest -s | |
env: | |
PRIV_KEY_B64: ${{ env.PRIV_KEY_B64 }} | |
PUB_KEY_B64: ${{ env.PUB_KEY_B64 }} | |
URL: http://server:3000 |