Skip to content
Merged
Show file tree
Hide file tree
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
56 changes: 56 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,34 @@ install_dependencies() {
3. Проверьте совместимость с разными ОС
4. Проверьте, что не сломались существующие функции

### Локальное тестирование

Запустите следующие тесты локально перед отправкой PR:

```bash
# Проверка синтаксиса Bash
bash -n cert_manager.sh

# ShellCheck анализ (требует установки shellcheck)
sudo apt-get install shellcheck # на Ubuntu/Debian
shellcheck -S warning cert_manager.sh

# Базовый функциональный тест
echo "0" | sudo ./cert_manager.sh
```

### Автоматическое тестирование CI/CD

При создании Pull Request автоматически запускаются следующие тесты:

- **ShellCheck** - статический анализ кода Bash
- **Синтаксис** - проверка корректности синтаксиса
- **Безопасность** - сканирование на потенциальные уязвимости
- **Мультиплатформенность** - тесты на Ubuntu, Debian, CentOS, Fedora, Arch, openSUSE
- **Качество кода** - анализ стиля и лучших практик

Все тесты должны пройти успешно перед слиянием PR.

## 📝 Документация

- Обновляйте README.md при изменении функциональности
Expand Down Expand Up @@ -181,6 +209,34 @@ Before submitting PR:
3. Check compatibility with different OS
4. Verify existing functions aren't broken

### Local Testing

Run the following tests locally before submitting PR:

```bash
# Bash syntax check
bash -n cert_manager.sh

# ShellCheck analysis (requires shellcheck installation)
sudo apt-get install shellcheck # on Ubuntu/Debian
shellcheck -S warning cert_manager.sh

# Basic functional test
echo "0" | sudo ./cert_manager.sh
```

### Automated CI/CD Testing

When creating a Pull Request, the following tests run automatically:

- **ShellCheck** - static analysis of Bash code
- **Syntax** - validation of script syntax
- **Security** - scanning for potential vulnerabilities
- **Multi-platform** - tests on Ubuntu, Debian, CentOS, Fedora, Arch, openSUSE
- **Code Quality** - analysis of style and best practices

All tests must pass successfully before PR can be merged.

## 📝 Documentation

- Update README.md when changing functionality
Expand Down
108 changes: 108 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,60 @@ Please enter your selection [0-8]: 8
| `check` | Проверить статус автообновления |
| `setup-renewal` | Настроить автоматическое продление |

## 🧪 Тестирование

Проект включает комплексную систему автоматического тестирования через GitHub Actions:

### Тестовые наборы

1. **Основные тесты** (`test.yml`) - выполняются при каждом push/PR:
- ✅ ShellCheck анализ кода
- ✅ Проверка синтаксиса Bash
- ✅ Тесты базовой функциональности
- ✅ Проверка установки зависимостей
- ✅ Анализ безопасности
- ✅ Проверка документации
- ✅ Интеграционные тесты
- ✅ Тесты производительности

2. **Мультиплатформенные тесты** (`multi-os-test.yml`):
- Ubuntu 20.04, 22.04, 24.04
- Debian 11, 12
- CentOS Stream 8, 9
- AlmaLinux 9
- Rocky Linux 9
- Fedora 38, 39, 40
- Arch Linux
- openSUSE Tumbleweed

3. **Альтернативные тесты** (`alt-os-test.yml`):
- Amazon Linux 2023
- Oracle Linux 8, 9
- Red Hat UBI 8, 9
- Alpine Linux
- BusyBox

4. **Проверка качества кода** (`code-quality.yml`):
- ShellCheck с разными уровнями строгости
- Сканирование безопасности
- Проверка стиля кода
- Анализ зависимостей

### Локальное тестирование

Перед коммитом рекомендуется запустить локальные тесты:

```bash
# Проверка синтаксиса
bash -n cert_manager.sh

# ShellCheck анализ (требует установки shellcheck)
shellcheck -S warning cert_manager.sh

# Базовый функциональный тест
echo "0" | sudo ./cert_manager.sh
```

## 🔧 Примеры использования

### Выпуск обычного сертификата
Expand Down Expand Up @@ -453,6 +507,60 @@ Please enter your selection [0-8]: 8
| `check` | Check auto-renewal status |
| `setup-renewal` | Setup automatic renewal |

## 🧪 Testing

The project includes a comprehensive automated testing system via GitHub Actions:

### Test Suites

1. **Main Tests** (`test.yml`) - run on every push/PR:
- ✅ ShellCheck code analysis
- ✅ Bash syntax validation
- ✅ Basic functionality tests
- ✅ Dependency installation tests
- ✅ Security analysis
- ✅ Documentation checks
- ✅ Integration tests
- ✅ Performance tests

2. **Multi-Platform Tests** (`multi-os-test.yml`):
- Ubuntu 20.04, 22.04, 24.04
- Debian 11, 12
- CentOS Stream 8, 9
- AlmaLinux 9
- Rocky Linux 9
- Fedora 38, 39, 40
- Arch Linux
- openSUSE Tumbleweed

3. **Alternative OS Tests** (`alt-os-test.yml`):
- Amazon Linux 2023
- Oracle Linux 8, 9
- Red Hat UBI 8, 9
- Alpine Linux
- BusyBox

4. **Code Quality Checks** (`code-quality.yml`):
- ShellCheck with different severity levels
- Security scanning
- Code style verification
- Dependency analysis

### Local Testing

Before committing, it's recommended to run local tests:

```bash
# Syntax check
bash -n cert_manager.sh

# ShellCheck analysis (requires shellcheck installation)
shellcheck -S warning cert_manager.sh

# Basic functional test
echo "0" | sudo ./cert_manager.sh
```

## 🔧 Usage Examples

### Issue Regular Certificate
Expand Down
8 changes: 5 additions & 3 deletions cert_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ install_dependencies() {
}

install_acme() {
cd ~
cd ~ || return 1
LOGI "Installing acme.sh..."
curl https://get.acme.sh | sh
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -212,10 +212,12 @@ ssl_cert_issue() {
LOGD "Your domain is: ${domain}, checking it..."

# here we need to judge whether there exists cert already
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
local currentCert
currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')

if [ "${currentCert}" == "${domain}" ]; then
local certInfo=$(~/.acme.sh/acme.sh --list)
local certInfo
certInfo=$(~/.acme.sh/acme.sh --list)
LOGE "System already has certificates for this domain, cannot issue again. Current certificates details:"
LOGI "$certInfo"
exit 1
Expand Down
Loading