Skip to content

Stable maintenance #2273

Stable maintenance

Stable maintenance #2273

Workflow file for this run

name: PR checks
on: pull_request
env:
ACTIONS_RUNNER_DEBUG: true
SECRET_KEY: test
ENV: ci
FLASK_DIRECTORY: /api/
FLASK_DOMAIN: http://localhost
FRONTEND_DOMAIN: http://localhost
MONGO_AUTH_USERNAME: root
MONGO_AUTH_PASSWORD: rootPassXXX
MONGO_APP_DATABASE: binbot
MONGO_AUTH_DATABASE: admin
MONGO_HOSTNAME: db
MONGO_PORT: 27017
jobs:
push_to_registry:
name: Test and deploy binbot
runs-on: ubuntu-latest
services:
db:
image: mongo
options: >-
--health-cmd mongosh
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MONGO_INITDB_ROOT_USERNAME: ${{ env.MONGO_AUTH_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ env.MONGO_AUTH_PASSWORD }}
ports:
- 27017:27017
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Build image
run: docker build --tag binbot .
- name: Test app
run: |
docker run --network host --name binbot \
-e MONGO_HOSTNAME=${{ env.MONGO_HOSTNAME }} \
-e MONGO_PORT=${{ env.MONGO_PORT }} \
-e MONGO_APP_DATABASE=${{ env.MONGO_APP_DATABASE }} \
-e MONGO_AUTH_USERNAME=${{ env.MONGO_AUTH_USERNAME }} \
-e MONGO_AUTH_PASSWORD=${{ env.MONGO_AUTH_PASSWORD }} \
-e ENV=ci -d binbot
curl --head --fail --retry-delay 5 --retry 3 --retry-connrefused http://localhost
- name: Test api
run: |
docker run --name binbot_api -p 8008:8006 \
-e MONGO_HOSTNAME=${{ env.MONGO_HOSTNAME }} \
-e MONGO_PORT=${{ env.MONGO_PORT }} \
-e MONGO_APP_DATABASE=${{ env.MONGO_APP_DATABASE }} \
-e MONGO_AUTH_USERNAME=${{ env.MONGO_AUTH_USERNAME }} \
-e MONGO_AUTH_PASSWORD=${{ env.MONGO_AUTH_PASSWORD }} \
-e ENV=ci -d binbot
curl --head --fail --retry-delay 10 --retry 3 --retry-all-errors http://localhost:8008
- name: Tag image
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker commit binbot_api carloswufei/binbot &
docker tag binbot carloswufei/binbot
- name: Push to Docker Hub
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push carloswufei/binbot
deploy_streaming:
name: Deploy streaming
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Build image
run: docker build --tag binbot_streaming -f Dockerfile.streaming .
- name: Test run script
run: |
docker run --network host --name binbot_streaming \
-e MONGO_HOSTNAME=${{ env.MONGO_HOSTNAME }} \
-e MONGO_PORT=${{ env.MONGO_PORT }} \
-e MONGO_APP_DATABASE=${{ env.MONGO_APP_DATABASE }} \
-e MONGO_AUTH_USERNAME=${{ env.MONGO_AUTH_USERNAME }} \
-e MONGO_AUTH_PASSWORD=${{ env.MONGO_AUTH_PASSWORD }} \
-e PYTHONUNBUFFERED=TRUE \
-e ENV=ci -d binbot_streaming
docker logs binbot_streaming
- name: Tag image
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker commit binbot_streaming carloswufei/binbot_streaming &
docker tag binbot_streaming carloswufei/binbot_streaming
- name: Push to Docker Hub
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push carloswufei/binbot_streaming
python_tests:
name: Python code tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
# Setup Python (faster than using Python container)
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10.8"
- name: Install pipenv
run: |
python3 -m pip install --upgrade pipenv wheel
- name: Install dependencies
run: |
pipenv install --dev --system --deploy --ignore-pipfile --clear
working-directory: api
- name: Run tests
run: pipenv run pytest -v
working-directory: api