test: add integration tests #77
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: Pipeline that validates and tests the source code | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@main | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.14' | |
| cache: 'pip' | |
| - name: Install pre-commit | |
| run: pip install pre-commit | |
| - name: Run pre-commit | |
| run: pre-commit run --all-files | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@main | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.14' | |
| cache: 'pip' | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| - name: Install dependencies | |
| run: poetry install --no-interaction | |
| - name: Run tests | |
| run: poetry run pytest | |
| - name: Run integration tests | |
| env: | |
| BRING_USERNAME: ${{ secrets.BRING_TESTING_USERNAME}} | |
| BRING_PASSWORD: ${{ secrets.BRING_TESTING_PASSWORD}} | |
| BRING_LIST_NAME: Zuhause | |
| run: poetry run pytest tests/test_integration.py | |
| validate-docker-image: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@main | |
| - name: Build Docker image | |
| run: docker build -t mealie-bring-api:test . | |
| - name: Run Docker container and validate successful startup | |
| run: | | |
| readonly TIMEOUT=20 | |
| CONTAINER_ID=$(docker run \ | |
| -e BRING_USERNAME=${{ secrets.BRING_TESTING_USERNAME}} \ | |
| -e BRING_PASSWORD=${{ secrets.BRING_TESTING_PASSWORD}} \ | |
| -e BRING_LIST_NAME=Zuhause \ | |
| -d mealie-bring-api:test) | |
| echo "Started container: ${CONTAINER_ID}" | |
| echo "Waiting up to ${TIMEOUT} seconds for expected output ..." | |
| FOUND=0 | |
| for i in $(seq 1 ${TIMEOUT}); do | |
| LOGS=$(docker logs "${CONTAINER_ID}" 2>&1 || true) | |
| if echo "${LOGS}" | grep -q "Listening on 0.0.0.0:8742"; then | |
| echo "✅ Expected output found!" | |
| FOUND=1 | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| docker stop "${CONTAINER_ID}" >/dev/null | |
| echo "---- Container logs ----" | |
| echo "${LOGS}" | |
| if [ "${FOUND}" -ne 1 ]; then | |
| echo "❌ Expected output not found!" | |
| exit 1 | |
| fi |