baktainer/.forgejo/workflows/test.yml

64 lines
1.6 KiB
YAML
Raw Normal View History

Add Forgejo Actions workflows for CI/CD ## Forgejo Actions Setup ### Directory Structure - `.forgejo/workflows/` - Forgejo Actions workflows directory - `ci.yml` - Main CI pipeline (test + build + notify) - `test.yml` - Test-only workflow for development - `build.yml` - Build-only workflow for releases - `docker.yml` - Advanced Docker workflow with caching - `README.md` - Comprehensive documentation ### Key Features #### 1. Main CI Pipeline (ci.yml) - Runs RSpec tests in Ruby 3.3 Alpine container - Builds and pushes Docker images to Docker Hub - Supports version tagging and latest tags - Provides pipeline status notifications #### 2. Test Workflow (test.yml) - Dedicated testing workflow for PRs - Runs unit and integration tests separately - Generates coverage reports - Uploads test artifacts #### 3. Build Workflow (build.yml) - Standalone Docker build workflow - Triggers on main branch and version tags - Includes build status notifications #### 4. Advanced Docker Workflow (docker.yml) - Uses Docker Buildx for advanced builds - Implements Docker layer caching - Automatic metadata extraction and tagging ### Forgejo vs GitHub Actions Differences #### Technical Adaptations - **Directory**: `.forgejo/workflows/` vs `.github/workflows/` - **Runners**: `runs-on: docker` with container specification - **Dependencies**: Explicit Alpine package installation - **Caching**: Adapted for Forgejo environment - **Execution**: Optimized for Docker container runtime #### Compatibility - Uses same action references (`actions/checkout@v4`, etc.) - Same secret management (`${{ secrets.* }}`) - Same environment variables (`${{ github.* }}`) - Maintains workflow syntax compatibility ### Required Configuration - Enable Repository Actions in Forgejo settings - Configure Docker Hub secrets (DOCKER_USERNAME, DOCKER_PASSWORD, DOCKER_IMAGE_NAME) - Ensure Forgejo Runner is installed and configured - Set up action repository sources ### Benefits - **Dual CI/CD**: Can run alongside GitHub Actions - **Self-hosted**: Full control over CI/CD infrastructure - **Docker-native**: Optimized for containerized workflows - **Feature parity**: Maintains same functionality as GitHub Actions This enables Baktainer to run on Forgejo instances with full CI/CD capabilities while maintaining compatibility with existing GitHub Actions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-15 11:02:58 -04:00
name: Run Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: docker
container:
image: ruby:3.3-alpine
defaults:
run:
working-directory: ./app
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install system dependencies
run: |
apk add --no-cache build-base libffi-dev linux-headers postgresql-dev git curl tzdata
- name: Install bundler
run: gem install bundler -v 2.6.7
- name: Cache Ruby gems
uses: actions/cache@v4
with:
path: app/vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('app/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Ruby dependencies
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Run unit tests
run: |
echo "🧪 Running unit tests..."
bundle exec rspec spec/unit/ --format documentation
- name: Run integration tests
run: |
echo "🧪 Running integration tests..."
bundle exec rspec spec/integration/ --format documentation
- name: Generate coverage report
run: |
echo "📊 Generating coverage report..."
COVERAGE=true bundle exec rspec --format progress
- name: Upload coverage results
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
path: app/coverage/