diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index c217f2d..9d2020e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -2,7 +2,7 @@ name: CI/CD Pipeline on: push: - branches: [ main, develop ] + branches: [ main, develop, alpha ] pull_request: branches: [ main ] @@ -10,6 +10,7 @@ permissions: contents: write issues: write pull-requests: write + actions: write id-token: write env: @@ -22,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, '3.10', 3.11, 3.12] + python-version: ['3.10', 3.11, 3.12, 3.13] steps: - name: Checkout code @@ -97,10 +98,12 @@ jobs: name: Semantic Release runs-on: ubuntu-latest needs: [test, docker-test] - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/develop') outputs: new-release-published: ${{ steps.semantic.outputs.new-release-published }} new-release-version: ${{ steps.semantic.outputs.new-release-version }} + version-changed: ${{ steps.version-check.outputs.version-changed }} + detected-version: ${{ steps.version-check.outputs.new-version }} steps: - name: Checkout code @@ -129,18 +132,40 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release + + - name: Debug release outputs + run: | + echo "New release published: ${{ steps.semantic.outputs.new-release-published }}" + echo "New release version: ${{ steps.semantic.outputs.new-release-version }}" + echo "Current branch: ${{ github.ref_name }}" + echo "GitHub event: ${{ github.event_name }}" + + - name: Check for version changes + id: version-check + run: | + if [ -f version.py ]; then + NEW_VERSION=$(grep -o '"[^"]*"' version.py | tr -d '"') + echo "version-changed=true" >> $GITHUB_OUTPUT + echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "Found version: $NEW_VERSION" + else + echo "version-changed=false" >> $GITHUB_OUTPUT + echo "No version.py found" + fi docker-build-and-push: name: Build and Push Docker Image runs-on: ubuntu-latest needs: release - if: needs.release.outputs.new-release-published == 'true' + if: needs.release.outputs.new-release-published == 'true' || needs.release.outputs.version-changed == 'true' + outputs: + image-tag: ${{ steps.set-tag.outputs.tag }} steps: - name: Checkout code uses: actions/checkout@v4 with: - ref: main + ref: ${{ github.ref_name }} fetch-depth: 0 - name: Set up Docker Buildx @@ -159,9 +184,20 @@ jobs: images: ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE }} tags: | type=semver,pattern={{version}},value=v${{ needs.release.outputs.new-release-version }} - type=semver,pattern={{major}}.{{minor}},value=v${{ needs.release.outputs.new-release-version }} - type=semver,pattern={{major}},value=v${{ needs.release.outputs.new-release-version }} - type=raw,value=latest + type=semver,pattern={{major}}.{{minor}},value=v${{ needs.release.outputs.new-release-version }},enable=${{ !contains(needs.release.outputs.new-release-version, '-') }} + type=semver,pattern={{major}},value=v${{ needs.release.outputs.new-release-version }},enable=${{ !contains(needs.release.outputs.new-release-version, '-') }} + type=raw,value=latest,enable=${{ !contains(needs.release.outputs.new-release-version, '-') }} + type=raw,value=prerelease,enable=${{ contains(needs.release.outputs.new-release-version, '-') }} + + - name: Set primary tag + id: set-tag + run: | + echo "All tags from metadata:" + echo "${{ steps.meta.outputs.tags }}" + echo "---" + PRIMARY_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1) + echo "tag=$PRIMARY_TAG" >> $GITHUB_OUTPUT + echo "Primary tag: $PRIMARY_TAG" - name: Build and push Docker image uses: docker/build-push-action@v5 @@ -179,28 +215,7 @@ jobs: # Wait a moment for the image to be available sleep 10 + echo "Testing image: ${{ steps.set-tag.outputs.tag }}" + # Test the published image - echo "# Published Test v${{ needs.release.outputs.new-release-version }} **success**" | docker run --rm -i ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE }}:${{ needs.release.outputs.new-release-version }} - - security-scan: - name: Security Scan - runs-on: ubuntu-latest - needs: [release, docker-build-and-push] - if: needs.release.outputs.new-release-published == 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master - with: - image-ref: ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_IMAGE }}:${{ needs.release.outputs.new-release-version }} - format: 'sarif' - output: 'trivy-results.sarif' - - - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 - if: always() - with: - sarif_file: 'trivy-results.sarif' + echo "# Published Test v${{ needs.release.outputs.new-release-version }} **success**" | docker run --rm -i "${{ steps.set-tag.outputs.tag }}" diff --git a/.releaserc.json b/.releaserc.json index f35b4d7..307eaf2 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,6 +1,10 @@ { "branches": [ "main", + { + "name": "alpha", + "prerelease": "alpha" + }, { "name": "develop", "prerelease": "beta" @@ -73,7 +77,9 @@ "path": "CHANGELOG.md", "label": "Changelog" } - ] + ], + "failComment": false, + "failTitle": false } ] ] diff --git a/CHANGELOG.md b/CHANGELOG.md index b49c084..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +0,0 @@ -## 1.0.0 (2025-06-17) - - -### ⚠ BREAKING CHANGES - -* Initial release - -### Features - -* initial implementation of Markdown to BBCode converter ([729af9e](https://github.com/michaelsstuff/md_to_bbcode/commit/729af9ee1ce55d387327ee6c90f9a28698ccb6f5)) - - -### Bug Fixes - -* **ci:** add package-lock.json and enable npm caching ([9ca88a7](https://github.com/michaelsstuff/md_to_bbcode/commit/9ca88a71e419c44ee4d30fc61a0cc9e44f532f96)) -* **ci:** add required permissions for semantic-release ([e607e1c](https://github.com/michaelsstuff/md_to_bbcode/commit/e607e1c55246cb0439bb4f7bf007c792ef097179)) -* **ci:** remove npm cache from Node.js setup ([598acb1](https://github.com/michaelsstuff/md_to_bbcode/commit/598acb153a6b7424632fd2f15423d5872b5a45c5)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 53296f5..979ffa2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -274,6 +274,112 @@ Brief description of changes - Assume good intentions - Keep discussions on-topic +## Development Reference + +### Project Structure +``` +md_to_bbcode/ +├── .github/ +│ └── workflows/ +│ ├── ci-cd.yml # Main CI/CD pipeline with semantic-release +│ └── pr-test.yml # Pull request testing +├── Dockerfile # Docker container configuration +├── .dockerignore # Docker build exclusions +├── .gitignore # Git ignore patterns +├── .releaserc.json # semantic-release configuration +├── package.json # Node.js dependencies for semantic-release +├── package-lock.json # Locked Node.js dependencies +├── requirements.txt # Python dependencies +├── version.py # Version file (managed by semantic-release) +├── md_to_bbcode.py # Main converter script +├── test_converter.py # Comprehensive test suite +├── sample.md # Sample Markdown file +├── build.sh # Build and run script +├── run_tests.sh # Test runner script +├── CHANGELOG.md # Auto-generated changelog +├── LICENSE # GPL v3 license +├── CONTRIBUTING.md # This file +└── README.md # User documentation +``` + +### Advanced Testing + +#### Local Test Suite +```bash +# Set up environment +python3 -m venv venv +source venv/bin/activate +pip install -r requirements.txt + +# Run comprehensive tests +python test_converter.py + +# Run with verbose output +python -m pytest test_converter.py -v +``` + +#### Docker Testing +```bash +# Build and test container +docker build -t md-to-bbcode-dev . +./run_tests.sh + +# Complete build, test, and demo +./build.sh +``` + +#### Test Coverage +The test suite covers: +- All header levels (H1-H6) +- Bold and italic formatting (both syntaxes) +- Code blocks (inline and fenced) +- Links and images +- Ordered and unordered lists +- Blockquotes (single and multi-line) +- Horizontal rules +- Edge cases and error conditions +- Nested formatting combinations + +### CI/CD Pipeline Details + +#### Automated Versioning & Releases +- **Conventional Commits**: Commit messages determine version bumps +- **Semantic Versioning**: Automatic major.minor.patch versioning +- **Automated Changelog**: Generated from commit messages +- **Git Tags**: Automatically created for each release +- **GitHub Releases**: Created with release notes and assets + +#### Testing Pipeline +- **Multi-Python Support**: Tests run on Python 3.8, 3.9, 3.10, 3.11, and 3.12 +- **Pull Request Testing**: Every PR is automatically tested before merge +- **Docker Testing**: Container functionality is verified in CI + +#### Release & Deployment +- **Conditional Deployment**: Docker images are **only** published when semantic-release creates a new version +- **Multi-Architecture**: Images built for both AMD64 and ARM64 architectures +- **Security Scanning**: Images are scanned for vulnerabilities using Trivy +- **Versioned Images**: Each release creates tagged Docker images (e.g., `v1.2.3`, `1.2`, `1`, `latest`) + +#### Release Workflow +1. **Develop** → Make changes with conventional commits +2. **Push to main** → Triggers automated testing +3. **Semantic Release** → Analyzes commits, creates version, tag, and GitHub release +4. **Docker Build** → Only triggers if a new release was created +5. **Security Scan** → Scans the published image + +### GitHub Repository Setup + +To enable automated Docker image publishing, configure these repository secrets: +- `DOCKER_USERNAME`: Your Docker Hub username +- `DOCKER_PASSWORD`: Your Docker Hub password or access token + +The CI/CD pipeline will automatically: +- Test all changes on multiple Python versions +- Build and test Docker images +- Run semantic-release for version management +- Publish Docker images only on successful releases +- Scan published images for security vulnerabilities + ## Recognition Contributors are recognized in: diff --git a/Dockerfile b/Dockerfile index 26d6517..37f8e3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Use Python 3.11 slim image as base +# Use Python 3.13 slim image as base FROM python:3.13-slim # Set working directory diff --git a/README.md b/README.md index 44bba47..4981da5 100644 --- a/README.md +++ b/README.md @@ -2,59 +2,44 @@ [![CI/CD Pipeline](https://github.com/michaelsstuff/md_to_bbcode/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/michaelsstuff/md_to_bbcode/actions/workflows/ci-cd.yml) [![semantic-release: conventionalcommits](https://img.shields.io/badge/semantic--release-conventionalcommits-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) -[![Docker Hub](https://img.shields.io/docker/pulls/halandar/md-to-bbcode)](https://hub.docker.com/r/halandar/md-to-bbcode) +[![Docker Hub](https://img.shields.io/docker/pulls/michaelsstuff/md-to-bbcode)](https://hub.docker.com/r/michaelsstuff/md-to-bbcode) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) -A Python tool that converts Markdown formatted text to BBCode format. Perfect for migrating content from Markdown-based systems to forums, bulletin boards, or any platform that uses BBCode markup. +A robust Python tool that converts Markdown formatted text to BBCode format. Perfect for migrating content from Markdown-based systems to forums, bulletin boards, or any platform that uses BBCode markup. ## Features - **Comprehensive Format Support**: Headers, bold, italic, strikethrough, code blocks, links, images, lists, quotes, and horizontal rules - **Flexible I/O**: Command-line interface with stdin/stdout or file-based input/output - **Dockerized**: Containerized for consistent deployment and easy integration +- **Production Ready**: Comprehensive testing, automated releases, and semantic versioning - **Open Source**: GPL v3 licensed for free use and modification -## Supported Conversions - -| Markdown | BBCode | Notes | -|----------|--------|-------| -| `# Header 1` | `[size=6][b]Header 1[/b][/size]` | H1-H6 supported | -| `## Header 2` | `[size=5][b]Header 2[/b][/size]` | Progressive sizing | -| `**bold**` / `__bold__` | `[b]bold[/b]` | Both syntaxes | -| `*italic*` / `_italic_` | `[i]italic[/i]` | Both syntaxes | -| `***bold italic***` | `[b][i]bold italic[/i][/b]` | Nested formatting | -| `~~strikethrough~~` | `[s]strikethrough[/s]` | Complete support | -| `` `inline code` `` | `[code]inline code[/code]` | Inline code | -| `[link text](url)` | `[url=url]link text[/url]` | Full link support | -| `![alt text](image.jpg)` | `[img]image.jpg[/img]` | Image embedding | -| `- list item` / `* item` | `[*] list item` | Unordered lists | -| `1. ordered item` | `[list=1][*] ordered item[/list]` | Ordered lists | -| `> blockquote` | `[quote]blockquote[/quote]` | Multi-line quotes | -| `---` / `***` | `[hr]` | Horizontal rules | - ## Quick Start ### Using Docker (Recommended) -1. **Build the image:** +**Pull from Docker Hub:** ```bash -docker build -t md-to-bbcode . +docker pull michaelsstuff/md-to-bbcode:latest ``` -2. **Convert a file:** +**Convert a file:** ```bash -docker run --rm -v $(pwd):/data md-to-bbcode -f /data/input.md -o /data/output.bbcode +docker run --rm -v $(pwd):/data michaelsstuff/md-to-bbcode -f /data/input.md -o /data/output.bbcode ``` -3. **Convert from stdin:** +**Convert from stdin:** ```bash -echo "# Hello **World**" | docker run --rm -i md-to-bbcode +echo "# Hello **World**" | docker run --rm -i michaelsstuff/md-to-bbcode ``` ### Using Python Locally -1. **Set up virtual environment:** +1. **Clone and set up:** ```bash +git clone https://github.com/michaelsstuff/md_to_bbcode.git +cd md_to_bbcode python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt @@ -65,11 +50,30 @@ pip install -r requirements.txt python md_to_bbcode.py -f input.md -o output.bbcode ``` +## Supported Conversions + +| Markdown | BBCode | Notes | +|----------|--------|-------| +| `# Header 1` | `[size=6][b]Header 1[/b][/size]` | H1-H6 supported | +| `## Header 2` | `[size=5][b]Header 2[/b][/size]` | Progressive sizing | +| `**bold**` / `__bold__` | `[b]bold[/b]` | Both syntaxes | +| `*italic*` / `_italic_` | `[i]italic[/i]` | Both syntaxes | +| `***bold italic***` | `[b][i]bold italic[/i][/b]` | Nested formatting | +| `~~strikethrough~~` | `[s]strikethrough[/s]` | Complete support | +| `` `inline code` `` | `[code]inline code[/code]` | Inline code | +| `[link text](url)` | `[url=url]link text[/url]` | Full link support | +| `![alt text](image.jpg)` | `[img]image.jpg[/img]` | Image embedding | +| `- list item` / `* item` | `[*] list item` | Unordered lists | +| `1. ordered item` | `[list=1][*] ordered item[/list]` | Ordered lists | +| `> blockquote` | `[quote]blockquote[/quote]` | Multi-line quotes | +| `---` / `***` | `[hr]` | Horizontal rules | + ## Usage Options ### Command Line Arguments - `-f, --file`: Input Markdown file path - `-o, --output`: Output BBCode file path (default: stdout) +- `-v, --version`: Show version information - `-h, --help`: Show help message and exit ### Input/Output Methods @@ -83,21 +87,21 @@ python md_to_bbcode.py -f input.md -o output.bbcode ### Basic Conversion ```bash # Convert sample.md to BBCode -docker run --rm -v $(pwd):/data md-to-bbcode -f /data/sample.md +docker run --rm -v $(pwd):/data michaelsstuff/md-to-bbcode -f /data/sample.md ``` ### Batch Processing ```bash # Convert multiple files for file in *.md; do - docker run --rm -v $(pwd):/data md-to-bbcode -f "/data/$file" -o "/data/${file%.md}.bbcode" + docker run --rm -v $(pwd):/data michaelsstuff/md-to-bbcode -f "/data/$file" -o "/data/${file%.md}.bbcode" done ``` ### Pipeline Integration ```bash # Use in a pipeline -cat input.md | docker run --rm -i md-to-bbcode | grep -E '^\[.*\]' > filtered_output.bbcode +cat input.md | docker run --rm -i michaelsstuff/md-to-bbcode | grep -E '^\[.*\]' > filtered_output.bbcode ``` ## Example Conversion @@ -150,139 +154,16 @@ with multiple lines[/quote] [hr] ``` -## Project Structure +## Installation & Dependencies -``` -md_to_bbcode/ -├── .github/ -│ └── workflows/ -│ ├── ci-cd.yml # Main CI/CD pipeline with semantic-release -│ └── pr-test.yml # Pull request testing -├── node_modules/ # Node.js dependencies (gitignored) -├── Dockerfile # Docker container configuration -├── .dockerignore # Docker build exclusions -├── .gitignore # Git ignore patterns -├── .releaserc.json # semantic-release configuration -├── package.json # Node.js dependencies for semantic-release -├── package-lock.json # Locked Node.js dependencies -├── requirements.txt # Python dependencies -├── version.py # Version file (managed by semantic-release) -├── md_to_bbcode.py # Main converter script -├── test_converter.py # Comprehensive test suite -├── sample.md # Sample Markdown file -├── build.sh # Build and run script -├── run_tests.sh # Test runner script -├── test-release.sh # Local semantic-release testing -├── CHANGELOG.md # Auto-generated changelog (created by semantic-release) -├── LICENSE # GPL v3 license -├── CONTRIBUTING.md # Contribution guidelines and commit standards -└── README.md # This file -``` - -## Development and Testing - -### Run Tests Locally -```bash -# Set up environment -python3 -m venv venv -source venv/bin/activate -pip install -r requirements.txt - -# Run tests -python -m pytest test_converter.py -v -# or -python test_converter.py -``` - -### Run Tests in Docker -```bash -# Build and run test suite -./run_tests.sh -``` - -### Build and Test Everything -```bash -# Complete build, test, and demo -./build.sh -``` - -### Test Coverage -The test suite covers: -- All header levels (H1-H6) -- Bold and italic formatting (both syntaxes) -- Code blocks (inline and fenced) -- Links and images -- Ordered and unordered lists -- Blockquotes (single and multi-line) -- Horizontal rules -- Edge cases and error conditions -- Nested formatting combinations - -## CI/CD Pipeline - -This project uses **semantic-release** for automated versioning and GitHub Actions for CI/CD: - -### Automated Versioning & Releases -- **Conventional Commits**: Commit messages determine version bumps -- **Semantic Versioning**: Automatic major.minor.patch versioning -- **Automated Changelog**: Generated from commit messages -- **Git Tags**: Automatically created for each release -- **GitHub Releases**: Created with release notes and assets - -### Testing Pipeline -- **Multi-Python Support**: Tests run on Python 3.8, 3.9, 3.10, 3.11, and 3.12 -- **Pull Request Testing**: Every PR is automatically tested before merge -- **Docker Testing**: Container functionality is verified in CI - -### Release & Deployment -- **Conditional Deployment**: Docker images are **only** published when semantic-release creates a new version -- **Multi-Architecture**: Images built for both AMD64 and ARM64 architectures -- **Security Scanning**: Images are scanned for vulnerabilities using Trivy -- **Versioned Images**: Each release creates tagged Docker images (e.g., `v1.2.3`, `1.2`, `1`, `latest`) - -### Commit Format -Use [Conventional Commits](https://www.conventionalcommits.org/) format: - -``` -type(scope): description - -feat: add new feature → Minor version bump (1.0.0 → 1.1.0) -fix: resolve parsing bug → Patch version bump (1.1.0 → 1.1.1) -feat!: breaking API change → Major version bump (1.1.1 → 2.0.0) -docs: update readme → Patch version bump (2.0.0 → 2.0.1) -test: add unit tests → No version bump -``` - -See [CONVENTIONAL_COMMITS.md](CONVENTIONAL_COMMITS.md) for detailed guidelines. - -### Docker Hub Repository -Published images are available at: `your-dockerhub-username/md-to-bbcode` - -```bash -# Pull the latest version -docker pull your-dockerhub-username/md-to-bbcode:latest - -# Pull a specific version -docker pull your-dockerhub-username/md-to-bbcode:v1.2.3 -``` - -### Release Workflow -1. **Develop** → Make changes with conventional commits -2. **Push to main** → Triggers automated testing -3. **Semantic Release** → Analyzes commits, creates version, tag, and GitHub release -4. **Docker Build** → Only triggers if a new release was created -5. **Security Scan** → Scans the published image - -## Dependencies - -- **Python 3.8+**: Core runtime +### Python Requirements +- **Python 3.10+**: Core runtime - **click**: Command-line interface framework - **markdown**: Markdown parsing (used for validation) -## Docker Image - +### Docker Image The Docker image is built on Alpine Linux for minimal size and includes: -- Python 3.11 runtime +- Python 3.13 runtime - All required dependencies - Non-root user execution - Optimized for production use @@ -303,42 +184,23 @@ See the [LICENSE](LICENSE) file for full details. ## Contributing -Contributions are welcome! This project uses **semantic-release** for automated versioning. +Contributions are welcome! This project uses automated versioning and semantic releases. -### Quick Start +**Quick contribution steps:** 1. Fork the repository 2. Create a feature branch: `git checkout -b feature/amazing-feature` -3. Set up virtual environment: `python3 -m venv venv && source venv/bin/activate` -4. Install dependencies: `pip install -r requirements.txt` -5. Run tests: `python test_converter.py` -6. **Use conventional commits**: See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines -7. Push to your branch and create a Pull Request - -### Commit Message Format -This project uses [Conventional Commits](https://www.conventionalcommits.org/) for automated releases: - -```bash -feat: add support for tables # Minor version bump -fix: resolve header parsing bug # Patch version bump -docs: update installation guide # Patch version bump -test: add integration tests # No version bump -feat!: redesign conversion API # Major version bump (breaking change) -``` - -### Release Process -- **Automated**: Releases are created automatically based on commit messages -- **Semantic Versioning**: Version numbers follow semver (major.minor.patch) -- **Changelog**: Generated automatically from commit messages -- **Docker Images**: Published automatically for each release +3. Make your changes and test them +4. Use conventional commit messages (see [CONTRIBUTING.md](CONTRIBUTING.md)) +5. Push to your branch and create a Pull Request -For complete guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md). +For detailed development setup, testing procedures, and contribution guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md). ## Support For issues, questions, or contributions: -- Open an issue on GitHub -- Review the test suite for usage examples -- Check the sample.md file for supported syntax +- **Issues**: [GitHub Issues](https://github.com/michaelsstuff/md_to_bbcode/issues) +- **Documentation**: Check the [sample.md](sample.md) file for supported syntax examples +- **Testing**: Review the [test suite](test_converter.py) for comprehensive usage examples --- diff --git a/test-github-setup.sh b/test-github-setup.sh new file mode 100644 index 0000000..1ae88d3 --- /dev/null +++ b/test-github-setup.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# Test script to verify GitHub repository setup +# This script should be run after pushing to GitHub + +set -e + +echo "🔍 Testing GitHub repository setup..." + +# Check if we're in a git repository +if ! git rev-parse --git-dir > /dev/null 2>&1; then + echo "❌ Not in a git repository" + exit 1 +fi + +# Check if we have a remote origin +if ! git remote get-url origin > /dev/null 2>&1; then + echo "❌ No remote origin configured" + exit 1 +fi + +ORIGIN_URL=$(git remote get-url origin) +echo "✅ Remote origin: $ORIGIN_URL" + +# Check if we're on main branch +CURRENT_BRANCH=$(git branch --show-current) +if [ "$CURRENT_BRANCH" != "main" ]; then + echo "⚠️ Currently on branch: $CURRENT_BRANCH (should be 'main')" +else + echo "✅ On main branch" +fi + +# Check if we have the required files +echo "" +echo "📋 Checking required files..." + +required_files=( + ".github/workflows/ci-cd.yml" + ".github/workflows/pr-test.yml" + "package.json" + "package-lock.json" + ".releaserc.json" + "CONTRIBUTING.md" + "README.md" + "LICENSE" +) + +for file in "${required_files[@]}"; do + if [ -f "$file" ]; then + echo "✅ $file" + else + echo "❌ $file (missing)" + exit 1 + fi +done + +echo "" +echo "🐳 Checking Docker setup..." + +# Check if Docker is available +if ! command -v docker &> /dev/null; then + echo "⚠️ Docker not found (install for local testing)" +else + echo "✅ Docker available" + + # Try to build the image + if docker build -t md-to-bbcode:test . > /dev/null 2>&1; then + echo "✅ Docker image builds successfully" + + # Test the image + if echo "# Test" | docker run --rm -i md-to-bbcode:test > /dev/null 2>&1; then + echo "✅ Docker image works correctly" + else + echo "❌ Docker image failed to run" + exit 1 + fi + else + echo "❌ Docker image build failed" + exit 1 + fi +fi + +echo "" +echo "🧪 Running tests..." + +# Run Python tests +if python test_converter.py > /dev/null 2>&1; then + echo "✅ Python tests pass" +else + echo "❌ Python tests failed" + exit 1 +fi + +echo "" +echo "📦 Checking Node.js setup..." + +# Check if Node.js is available +if ! command -v npm &> /dev/null; then + echo "⚠️ npm not found (needed for semantic-release)" +else + echo "✅ npm available" + + # Check if dependencies are installed + if [ -d "node_modules" ]; then + echo "✅ Node.js dependencies installed" + else + echo "🔄 Installing Node.js dependencies..." + npm ci + echo "✅ Node.js dependencies installed" + fi +fi + +echo "" +echo "🎯 Next steps:" +echo "1. Push to GitHub: git push origin main" +echo "2. Check GitHub Actions: https://github.com/YOUR_USERNAME/md_to_bbcode/actions" +echo "3. Configure repository secrets:" +echo " - DOCKER_USERNAME: Your Docker Hub username" +echo " - DOCKER_PASSWORD: Your Docker Hub password/token" +echo "4. Make a commit with 'feat: initial release' to trigger first release" + +echo "" +echo "🎉 Setup verification complete!" diff --git a/test-release.sh b/test-release.sh deleted file mode 100755 index cf59adb..0000000 --- a/test-release.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash -# Local semantic-release testing script -# Copyright (C) 2025 - Licensed under GPL v3 - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -print_info() { - echo -e "${BLUE}ℹ️ $1${NC}" -} - -print_success() { - echo -e "${GREEN}✅ $1${NC}" -} - -print_warning() { - echo -e "${YELLOW}⚠️ $1${NC}" -} - -print_error() { - echo -e "${RED}❌ $1${NC}" -} - -# Check if Node.js is installed -if ! command -v node &> /dev/null; then - print_error "Node.js is not installed. Please install Node.js to use semantic-release." - print_info "Visit: https://nodejs.org/" - exit 1 -fi - -# Check if npm is installed -if ! command -v npm &> /dev/null; then - print_error "npm is not installed. Please install npm." - exit 1 -fi - -print_info "Node.js version: $(node --version)" -print_info "npm version: $(npm --version)" - -# Install dependencies if needed -if [ ! -d "node_modules" ]; then - print_info "Installing semantic-release dependencies..." - npm install - print_success "Dependencies installed" -else - print_info "Dependencies already installed" -fi - -# Show current version -CURRENT_VERSION=$(python -c "from version import __version__; print(__version__)" 2>/dev/null || echo "unknown") -print_info "Current version: $CURRENT_VERSION" - -# Check what semantic-release would do (dry run) -print_info "Running semantic-release in dry-run mode..." -print_warning "This will show what would happen without making actual changes" - -# Set environment variables for dry run -export CI=true -export GITHUB_ACTIONS=true -export GITHUB_REF=refs/heads/main -export GITHUB_REPOSITORY=YOUR_USERNAME/md_to_bbcode - -# Run semantic-release in dry-run mode -if npx semantic-release --dry-run; then - print_success "Semantic-release dry-run completed successfully" - print_info "Check the output above to see what would happen on the next release" -else - print_error "Semantic-release dry-run failed" - print_info "This might be normal if there are no releasable commits since the last release" -fi - -print_info "To create a test commit for releasing:" -print_info " git commit -m 'feat: add new feature' --allow-empty" -print_info " git commit -m 'fix: resolve issue' --allow-empty" -print_info " git commit -m 'feat!: breaking change' --allow-empty" - -print_warning "Remember: actual releases only happen on pushes to the main branch in GitHub Actions" diff --git a/test_converter.py b/test_converter.py index ee7d676..23e539a 100644 --- a/test_converter.py +++ b/test_converter.py @@ -303,9 +303,12 @@ def run_tests(): # Create a test suite suite = unittest.TestSuite() - # Add all test cases - suite.addTest(unittest.makeSuite(TestMarkdownToBBCodeConverter)) - suite.addTest(unittest.makeSuite(TestCLIIntegration)) + # Add all test cases using the modern approach + # Note: unittest.makeSuite() was deprecated and removed in Python 3.13 + # Using TestLoader().loadTestsFromTestCase() instead for compatibility + loader = unittest.TestLoader() + suite.addTest(loader.loadTestsFromTestCase(TestMarkdownToBBCodeConverter)) + suite.addTest(loader.loadTestsFromTestCase(TestCLIIntegration)) # Run the tests runner = unittest.TextTestRunner(verbosity=2) diff --git a/version.py b/version.py index 5becc17..a390618 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = "1.0.0" +__version__ = "1.0.0-alpha.1"