Skip to content

refactor(Makefile): use virtual environment variable for python commands #27

refactor(Makefile): use virtual environment variable for python commands

refactor(Makefile): use virtual environment variable for python commands #27

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test-and-lint:
name: Test and Lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install pre-commit
run: |
if [[ ${{ matrix.python-version }} == 3.8 ]]; then
pip install 'pre-commit<3.0.0'
else
pip install 'pre-commit>=3.0.0'
fi
- name: Run linter
run: make lint
- name: Run unit tests
run: make unit-test
- name: Set up Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Run coverage
run: |
make test-coverage
if [ -f coverage_data/coverage.xml ]; then
mkdir -p coverage
cp coverage_data/coverage.xml coverage/
else
echo "Coverage file not found."
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/coverage.xml
integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: test-and-lint
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Cache pip packages
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set up Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Run integration tests
run: make integration-test
build-and-push:
name: Build and Push Docker Image
needs: [test-and-lint, integration-test]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.DOCKER_USERNAME }}/telegram-referral-bot:latest
${{ env.DOCKER_USERNAME }}/telegram-referral-bot:${{ github.sha }}
platforms: |
linux/amd64
linux/arm64