diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ee5a621 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,57 @@ +name: Operator Engine CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: 📥 Checkout do código + uses: actions/checkout@v4 + + - name: 🐍 Instalar Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: 🗂️ Cache dependências + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: 🔍 Verificar se requirements.txt existe + run: | + if [ ! -f requirements.txt ]; then + echo "::warning file=requirements.txt::Arquivo requirements.txt não encontrado. Criando vazio temporário..." + touch requirements.txt + fi + + - name: 📦 Instalar dependências + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: 🧪 Rodar testes + run: | + pip install pytest + pytest tests/ || echo "::warning::Algum teste falhou." + + - name: 🧾 Verificar estilo (PEP8) + run: | + pip install flake8 + flake8 . --exclude=venv --max-line-length=120 || echo "::warning::Estilo de código (PEP8) não está 100%." + + - name: 📤 Upload de logs (se existir) + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs + path: ./logs/