Migration to SQL and fixes #3039
Workflow file for this run
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: PR checks | |
on: pull_request | |
env: | |
ACTIONS_RUNNER_DEBUG: true | |
SECRET_KEY: test | |
ENV: ci | |
FRONTEND_DOMAIN: http://localhost | |
MONGO_AUTH_USERNAME: root | |
MONGO_AUTH_PASSWORD: rootPassXXX | |
MONGO_APP_DATABASE: binbot | |
MONGO_KAFKA_DATABASE: kafka | |
MONGO_AUTH_DATABASE: admin | |
MONGO_HOSTNAME: data_db | |
MONGO_PORT: 27017 | |
POSTGRES_USER: "postgres" | |
POSTGRES_PASSWORD: "postgres" | |
POSTGRES_DB: "postgres" | |
jobs: | |
push_to_registry: | |
name: Test and deploy binbot | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_DB: postgres | |
ports: | |
- 5432/tcp | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
data_db: | |
image: mongo:7.0 | |
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@v4 | |
- name: Build image | |
run: docker build --tag binbot . | |
- name: Check port | |
run: echo ${{ job.services.postgres.ports[5432] }} | |
- name: Run docker container | |
env: | |
MONGO_HOSTNAME: ${{ env.MONGO_HOSTNAME }} | |
MONGO_PORT: ${{ env.MONGO_PORT }} | |
MONGO_APP_DATABASE: ${{ env.MONGO_APP_DATABASE }} | |
MONGO_KAFKA_DATABASE: ${{ env.MONGO_KAFKA_DATABASE }} | |
MONGO_AUTH_USERNAME: ${{ env.MONGO_AUTH_USERNAME }} | |
MONGO_AUTH_PASSWORD: ${{ env.MONGO_AUTH_PASSWORD }} | |
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} | |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
run: docker run --network host --name binbot binbot | |
- name: Test front-end | |
run: curl --head --fail --retry-delay 5 --retry 3 --retry-connrefused http://localhost | |
- name: Test back-end | |
run: curl --head --fail --retry-delay 5 --retry 3 --retry-connrefused http://0.0.0.0: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 | |
- 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 | |
deploy_cronjobs: | |
name: Deploy cronjobs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Build image | |
run: docker build --tag binbot_cronjobs -f Dockerfile.cronjobs . | |
- name: Test run script | |
run: | | |
docker run --network host --name binbot_cronjobs \ | |
-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_cronjobs | |
- name: Tag image | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
run: | | |
docker commit binbot_cronjobs carloswufei/binbot_cronjobs & | |
docker tag binbot_cronjobs carloswufei/binbot_cronjobs | |
- 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_cronjobs | |
python-tests: | |
name: Python code tests | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: api | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
# Setup Python (faster than using Python container) | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install pipenv | |
run: | | |
python3 -m pip install pipenv | |
- name: Install dependencies | |
run: | | |
pipenv install --dev --system --deploy --ignore-pipfile --clear | |
pipenv install httpx coverage | |
- name: Run tests | |
run: coverage run -m pytest . | |
python-linting: | |
name: Python code linting | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: api | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
# Setup Python (faster than using Python container) | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install pipenv | |
run: python3 -m pip install pipenv | |
- name: Install dependencies | |
run: | | |
pipenv install --dev --system --deploy --ignore-pipfile --clear | |
pipenv install httpx | |
- name: Run linters | |
run: | | |
pipenv run ruff check . | |
pipenv run mypy . | |
frontend-tests: | |
name: React app tests | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: terminal | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm run test |