Workflow Simplification: - Consolidate 8 workflows into 1 comprehensive ci.yml workflow - Delete redundant workflows: test.yml, build.yml, docker.yml, minimal.yml, node-ruby.yml, shell-only.yml, simple.yml - Keep shell-based approach for maximum Forgejo runner compatibility - Update README.md to document simplified single-workflow design Test Fix: - Fix failing container_spec.rb test for missing state information - Add missing json method mock to handle fallback scenario - All 121 tests now passing The single workflow provides: - Test job: Install dependencies and run RSpec tests - Build job: Build Docker image and push to Docker Hub - Notify job: Report pipeline status - Full compatibility with any Forgejo runner configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
139 lines
No EOL
4 KiB
YAML
139 lines
No EOL
4 KiB
YAML
name: CI Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*.*.*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: docker
|
|
container:
|
|
image: ruby:3.3-alpine
|
|
|
|
steps:
|
|
- name: Install system dependencies
|
|
run: |
|
|
# Detect OS and install dependencies
|
|
if command -v apk >/dev/null 2>&1; then
|
|
# Alpine Linux
|
|
apk add --no-cache build-base libffi-dev linux-headers postgresql-dev git curl tzdata
|
|
elif command -v apt-get >/dev/null 2>&1; then
|
|
# Debian/Ubuntu
|
|
apt-get update && apt-get install -y build-essential libffi-dev libpq-dev git curl tzdata
|
|
elif command -v yum >/dev/null 2>&1; then
|
|
# CentOS/RHEL
|
|
yum install -y gcc make libffi-devel postgresql-devel git curl tzdata
|
|
elif command -v dnf >/dev/null 2>&1; then
|
|
# Fedora
|
|
dnf install -y gcc make libffi-devel postgresql-devel git curl tzdata
|
|
fi
|
|
|
|
- name: Clone repository
|
|
run: |
|
|
git clone ${{ github.server_url }}/${{ github.repository }}.git .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Install bundler
|
|
run: |
|
|
cd app
|
|
gem install bundler -v 2.6.7
|
|
|
|
- name: Install Ruby dependencies
|
|
run: |
|
|
cd app
|
|
bundle config path vendor/bundle
|
|
bundle install --jobs 4 --retry 3
|
|
|
|
- name: Run RSpec tests
|
|
run: |
|
|
cd app
|
|
mkdir -p tmp
|
|
bundle exec rspec --format progress
|
|
|
|
- name: Test status
|
|
run: |
|
|
if [ $? -eq 0 ]; then
|
|
echo "✅ All tests passed!"
|
|
else
|
|
echo "❌ Tests failed"
|
|
exit 1
|
|
fi
|
|
|
|
build:
|
|
needs: test
|
|
runs-on: docker
|
|
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
|
|
|
|
steps:
|
|
- name: Install Docker and git
|
|
run: |
|
|
if command -v apk >/dev/null 2>&1; then
|
|
apk add --no-cache docker git
|
|
elif command -v apt-get >/dev/null 2>&1; then
|
|
apt-get update && apt-get install -y docker.io git
|
|
elif command -v yum >/dev/null 2>&1; then
|
|
yum install -y docker git
|
|
elif command -v dnf >/dev/null 2>&1; then
|
|
dnf install -y docker git
|
|
fi
|
|
|
|
- name: Clone repository
|
|
run: |
|
|
git clone ${{ github.server_url }}/${{ github.repository }}.git .
|
|
git checkout ${{ github.sha }}
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build -t baktainer-test .
|
|
|
|
- name: Test Docker image
|
|
run: |
|
|
docker run --rm baktainer-test ruby --version
|
|
|
|
- name: Login to Docker Hub
|
|
run: |
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
|
|
|
- name: Tag and push image
|
|
run: |
|
|
IMAGE_NAME="${{ secrets.DOCKER_IMAGE_NAME }}"
|
|
|
|
# Tag as latest
|
|
docker tag baktainer-test "${IMAGE_NAME}:latest"
|
|
docker push "${IMAGE_NAME}:latest"
|
|
|
|
# Tag with version if it's a tag
|
|
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
|
|
VERSION_TAG="${GITHUB_REF#refs/tags/}"
|
|
docker tag baktainer-test "${IMAGE_NAME}:${VERSION_TAG}"
|
|
docker push "${IMAGE_NAME}:${VERSION_TAG}"
|
|
echo "✅ Pushed ${IMAGE_NAME}:${VERSION_TAG}"
|
|
fi
|
|
|
|
echo "✅ Docker image pushed successfully"
|
|
|
|
notify:
|
|
needs: [test, build]
|
|
runs-on: docker
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Notify pipeline status
|
|
run: |
|
|
echo "📊 Pipeline Status Report:"
|
|
echo "🧪 Tests: ${{ needs.test.result }}"
|
|
if [ "${{ needs.build.result }}" != "skipped" ]; then
|
|
echo "🐳 Build: ${{ needs.build.result }}"
|
|
fi
|
|
|
|
if [ "${{ needs.test.result }}" == "success" ]; then
|
|
echo "✅ All tests passed!"
|
|
else
|
|
echo "❌ Tests failed"
|
|
fi |