Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”– From dev β†’ Bump version: v1.0.3-dev into test #4

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.0.2
current_version = 1.0.3
commit = True
tag = False

1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
INPUT_DIR=input
OUTPUT_DIR=output
LANGS=["English","Spanish","French","German"]
OPENAI_MODEL="gpt-3.5-turbo"
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## [1.0.2] - 2024-11-16

### Other Changes

- πŸ”– From prod β†’ Bump version: v1.0.2-prod into main (#3)
- πŸ”– From test β†’ Bump version: v1.0.2-test into prod (#2)
- πŸ”– From dev β†’ Bump version: v1.0.2-dev into test (#1)
- πŸ”– Bump version: 1.0.1 β†’ 1.0.2
- πŸ”§ chore(core): test workflow [patch candidate]
- πŸ”§ chore(core): fixed folder
- πŸ”§ chore(core): fixed workflows
- πŸ”§ chore(core): fixed workflows
- ✨ feat(core): added main scripts translator
- Initial commit
212 changes: 89 additions & 123 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,48 @@
# πŸ“„ GitHub CI/CD Template
# πŸ—ΊοΈ Langding

![CI/CD](https://img.shields.io/badge/CI/CD-Pipeline-blue)
![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=fff)
![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg)
![Build Status](https://github.com/JuanVilla424/github-cicd-template/actions/workflows/ci.yml/badge.svg?branch=main)
![Status](https://img.shields.io/badge/Status-Stable-green.svg)
![Python](https://img.shields.io/badge/Python-3.11%2B-blue.svg)
![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)

Welcome to the **GitHub CI/CD Template** repository! This project provides a robust and flexible CI/CD pipeline setup using GitHub Actions, tailored for project using Python for backend, node frontend, docker-compose or Dockerfile. Leverage this template to automate your development workflow, from testing and building to deployment and monitoring.

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.pngkey.com%2Fpng%2Ffull%2F178-1787243_github-icon-png.png&f=1&nofb=1&ipt=913bc5d745baa725efe14b20bdf6ca3f91044c2be909e8504cc79f13dc0b1729&ipo=images" width="112" alt="CI/CD">
Langding is an AI-driven landing page auto-translation tool. It reads HTML files, extracts text content, translates it into multiple languages using OpenAI's GPT models, and generates translated HTML files. This tool is useful for quickly localizing web pages into different languages.

## πŸ“š Table of Contents

- [Features](#-features)
- [Getting Started](#-getting-started)
- [Prerequisites](#-prerequisites)
- [Installation](#-installation)
- [Environment Setup](#-environment-setup)
- [Pre-Commit Hooks](#-pre-commit-hooks)
- [Extra Steps](#-extra-steps)
- [Installation](#-installation)
- [Configuration](#-configuration)
- [Usage](#-usage)
- [Contributing](#-contributing)
- [Initialization](#-initialization)
- [Environment Variables](#-environment-variables)
- [Logging](#-logging)
- [License](#-license)
- [Contact](#-contact)

## 🌟 Features

- **Automated Testing:** Run tests automatically on each push and pull request.
- **Continuous Deployment:** Deploy your application seamlessly to your chosen platform.
- **Code Quality Checks:** Enforce coding standards with linting and formatting tools.
- **Build Optimization:** Optimize build processes for faster deployment cycles.
- **Notifications:** Receive updates and alerts on pipeline status via email or chat integrations.

## πŸš€ Getting Started

### πŸ“‹ Prerequisites
## ✨ Features

**Before you begin, ensure you have met the following requirements**:
- **Automated Translation**: Translates HTML content into multiple languages using OpenAI's GPT models.
- **Template Generation**: Creates HTML templates with placeholders for easy text replacement.
- **Multi-language Support**: Supports translation into any language specified.
- **Logging**: Detailed logging with rotating file handlers for easy debugging and monitoring.
- **Configuration**: Easily configurable via environment variables and command-line arguments.

- **GitHub Account:** You need a GitHub account to use GitHub Actions.
- **Python 3.12+:** Ensure Python is installed on your local machine.
- **Git:** Install [Git](https://git-scm.com/) to clone the repository.
- **NVM:** (Optional) Node.js installation environment versions control
- **Node.js 22.x+**: (Optional) (Required to Push) Used as lint orchestration manager in pre-commit and pre-push
## πŸ› οΈ Installation

### πŸ”¨ Installation

1. **Clone the Repository**
1. **Clone the Repository:**

```bash
git clone https://github.com/JuanVilla424/github-cicd-template.git
git clone https://github.com/JuanVilla424/langding.git
cd langding
```

2. Navigate to the Project Directory
```bash
cd github-cicd-template
```

### πŸ”§ Environment Setup

**Mandatory: Setting Up a Python Virtual Environment**

Setting up a Python virtual environment ensures that dependencies are managed effectively and do not interfere with other projects.

1. **Create a Virtual Environment**
2. **Create a Virtual Environment**

```bash
cd langding
python -m venv venv
```

2. **Activate the Virtual Environment**
3. **Activate the Virtual Environment**

On Unix or MacOS:

@@ -90,19 +62,24 @@ Setting up a Python virtual environment ensures that dependencies are managed ef
powershell.exe -ExecutionPolicy Bypass -File .\venv\Scripts\Activate.ps1
```

3. **Upgrade pip**
4. **Upgrade pip**

```bash
pip install --upgrade pip
```

4. **Install Dependencies**
5. **Set up your OpenAI API key**:

Obtain your API key from OpenAI and set it as an environment variable:

```bash
export OPENAI_API_KEY='your-api-key-here'
```

6. **Install Dependencies**

```bash
pip install -r requirements.txt
pip install poetry
poetry lock
poetry install
```

- Deactivate the Virtual Environment
@@ -113,107 +90,96 @@ Setting up a Python virtual environment ensures that dependencies are managed ef
deactivate
```

5. **Docker Extra Steps**: Install Scoop and then install hadolint using scoop, refer to [Extra Steps](#-extra-steps)
## βš™οΈ Configuration

### πŸ›Έ Pre-Commit Hooks
**Environment Variables**:

**Install and check pre-commit hooks**: MD files changes countermeasures, python format, python lint, yaml format, yaml lint, version control hook, changelog auto-generation
Create a .env file in the project root directory and populate it with the following variables:

```bash
pre-commit install
pre-commit install -t pre-commit
pre-commit install -t pre-push
pre-commit autoupdate
pre-commit run --all-files
INPUT_DIR=input
OUTPUT_DIR=output
LANGS=["English","Spanish","French","German"]
OPENAI_MODEL="gpt-3.5-turbo"
```

### πŸ“Œ Extra Steps

1. **Docker**:
- Descriptions:
- INPUT_DIR: Directory containing input HTML files.
- OUTPUT_DIR: Directory to save output files.
- LANGS: List of languages to translate into.
- OPENAI_MODEL: OpenAI model target.

- Using MacOs or Linux:
```bash
brew install hadolint
```
- On Windows **as non-admin user**:
```bash
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
scoop install halint
```
## πŸš€ Usage

## πŸ› οΈ Usage
### πŸ“¦ Initialization

**To utilize the CI/CD pipeline, follow these steps**:
1. Prepare Input HTML Files:
Place your HTML files that you want to translate into the input directory (or your specified input directory).

1. **Configure GitHub Actions**
2. Configure Settings:
Ensure your environment variables are set, or prepare to pass configurations via command-line arguments.

- Navigate to the .github/workflows/ directory.
- Customize the ci.yml file according to your project's requirements.
- Customize the python.yml file to format and lint python code.
- Customize the node.yml file to format and lint node.js code if you are hosting frontend.
- Customize the release-controller file to add or remove **[backend, frontend, docker deployment, database]**
### Translating HTML Files

2. **Set Up Secrets**
Run the main script:

- Go to your GitHub repository settings.
- Navigate to Secrets and add necessary secrets like CODECOV_KEY, etc.

3. **Triggering the Pipeline**
```bash
python __init__.py
```

- Push to Branches: Pushing code to dev, test, prod, or main branches will trigger the pipeline.
- Pull Requests: Opening or updating pull requests will run tests and checks.
This will process all HTML files in the input directory and generate translated versions in the output directory.

4. **Monitoring Pipeline Status**
- Check the Actions tab in your GitHub repository to monitor the status of your workflows.
- Integrate notifications with Slack, Email, or other communication tools for real-time updates.
### Command-Line Arguments

## 🀝 Contributing
You can customize the behavior using the following arguments:

**Contributions are welcome! To contribute to this repository, please follow these steps**:
`--input-dir: Specify the input directory containing HTML files.`

1. **Fork the Repository**
```bash
python main.py --input-dir path/to/your/input
```

2. **Create a Feature Branch**
`--output-dir: Specify the output directory for the translated files.`

```bash
git checkout -b feature/your-feature-name
```
```bash
python main.py --output-dir path/to/your/output
```

3. **Commit Your Changes**
`--languages: List of languages to translate into.`

```bash
git commit -m "feat(<scope>): your feature commit message - lower case"
```
```bash
python main.py --languages Spanish Italian Japanese
```

4. **Push to the Branch**
`--log-level: Set the logging level (INFO or DEBUG).`

```bash
git push origin feature/your-feature-name
```
```bash
python main.py --log-level DEBUG
```

5. **Open a Pull Request into** `dev` **branch**
### πŸ“ Example Usage

Please ensure your contributions adhere to the Code of Conduct and Contribution Guidelines.
```bash
python __init__.py --input-dir input_html --output-dir translated_html --languages Spanish,German --log-level INFO
```

### πŸ› οΈ Adding a New Workflow
### πŸ“œ Environment Variables

1. **Create a New Workflow File**
Ensure all required environment variables are set in the .env file:

```bash
touch .github/workflows/new-workflow.yml
```
Global Variables
INPUT_DIR: Directory containing input HTML files.
OUTPUT_DIR: Directory to save output files.
LANGS: List of languages to translate into.
OPENAI_MODEL: OpenAI Model Target.

2. **Define the Workflow**
## πŸ“Š Logging

Customize the workflow according to your needs, using existing workflows as references.
Logs are maintained in crypto_controller.log with rotating file handlers to prevent excessive file sizes.

3. **Commit and Push**
```bash
git add .github/workflows/new-workflow.yml
git commit -m "chore(core): added new workflow - lower case"
git push origin feature/your-feature-name
```
Log Levels:
INFO: General operational messages.
DEBUG: Detailed diagnostic information.

## πŸ“« Contact

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langding"
version = "1.0.2"
version = "1.0.3"
description = "Langding is an AI driven landing auto-translate site."
authors = ["B <g46327wsj1.marbling129@passinbox.com>"]
license = "GLPv3"