fix(ci): replace GitHub Actions with native bash commands
- Remove dependency on GitHub (network blocks access) - Replace actions/checkout@v4 with git clone - Replace actions/setup-python@v4 with apt-get install - Replace docker/build-push-action with native docker commands - Use config.settings.test (SQLite in-memory) for tests Closes: network connectivity issue in CI
This commit is contained in:
@@ -6,6 +6,9 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main, develop ]
|
branches: [ main, develop ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION: "3.11"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
name: Code Quality Checks
|
name: Code Quality Checks
|
||||||
@@ -13,110 +16,66 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install uv
|
|
||||||
run: |
|
run: |
|
||||||
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git .
|
||||||
|
git checkout ${GITHUB_SHA}
|
||||||
|
|
||||||
|
- name: Install Python and uv
|
||||||
|
run: |
|
||||||
|
apt-get update && apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-venv
|
||||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
- name: Create virtual environment
|
- name: Create virtual environment and install dependencies
|
||||||
run: uv venv
|
|
||||||
|
|
||||||
- name: Activate virtual environment and install dependencies
|
|
||||||
run: |
|
run: |
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
uv venv --python python${PYTHON_VERSION}
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
uv sync --dev
|
uv sync --dev
|
||||||
|
|
||||||
- name: Run Ruff linting
|
- name: Run Ruff linting
|
||||||
run: |
|
run: |
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
ruff check .
|
ruff check .
|
||||||
|
|
||||||
- name: Run Ruff formatting check
|
- name: Run Ruff formatting check
|
||||||
run: |
|
run: |
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
ruff format . --check
|
ruff format . --check
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
services:
|
|
||||||
postgres:
|
|
||||||
image: postgres:15.10
|
|
||||||
env:
|
|
||||||
POSTGRES_DB: test_db
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
options: >-
|
|
||||||
--health-cmd pg_isready
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
options: >-
|
|
||||||
--health-cmd "redis-cli ping"
|
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
ports:
|
|
||||||
- 6379:6379
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install uv
|
|
||||||
run: |
|
run: |
|
||||||
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git .
|
||||||
|
git checkout ${GITHUB_SHA}
|
||||||
|
|
||||||
|
- name: Install Python and uv
|
||||||
|
run: |
|
||||||
|
apt-get update && apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-venv
|
||||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
- name: Create virtual environment
|
- name: Create virtual environment and install dependencies
|
||||||
run: uv venv
|
|
||||||
|
|
||||||
- name: Activate virtual environment and install dependencies
|
|
||||||
run: |
|
run: |
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
uv venv --python python${PYTHON_VERSION}
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
uv sync --dev
|
uv sync --dev
|
||||||
|
|
||||||
- name: Wait for services to be ready
|
|
||||||
run: |
|
|
||||||
# Wait for PostgreSQL
|
|
||||||
until pg_isready -h localhost -p 5432 -U postgres; do
|
|
||||||
echo "Waiting for PostgreSQL..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
# Wait for Redis
|
|
||||||
until redis-cli -h localhost -p 6379 ping; do
|
|
||||||
echo "Waiting for Redis..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Run Django tests
|
- name: Run Django tests
|
||||||
run: |
|
run: |
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
source .venv/bin/activate
|
source .venv/bin/activate
|
||||||
cd src
|
cd src
|
||||||
python manage.py test --verbosity=2
|
python manage.py test --verbosity=2
|
||||||
env:
|
env:
|
||||||
DJANGO_SETTINGS_MODULE: config.settings.development
|
DJANGO_SETTINGS_MODULE: config.settings.test
|
||||||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_db
|
|
||||||
REDIS_URL: redis://localhost:6379/0
|
|
||||||
CELERY_BROKER_URL: redis://localhost:6379/0
|
|
||||||
SECRET_KEY: test-secret-key-for-ci
|
SECRET_KEY: test-secret-key-for-ci
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@@ -126,56 +85,21 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git .
|
||||||
- name: Set up Docker Buildx
|
git checkout ${GITHUB_SHA}
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Extract metadata for web image
|
|
||||||
id: meta-web
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ github.repository_owner }}/mostovik-web
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
|
|
||||||
- name: Extract metadata for celery image
|
|
||||||
id: meta-celery
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ github.repository_owner }}/mostovik-celery
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
|
|
||||||
- name: Build web image
|
- name: Build web image
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
BRANCH_TAG=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')
|
||||||
context: .
|
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
||||||
file: ./docker/Dockerfile.web
|
docker build -f ./docker/Dockerfile.web -t mostovik-web:${BRANCH_TAG} -t mostovik-web:${BRANCH_TAG}-${SHA_SHORT} .
|
||||||
push: false
|
|
||||||
load: true
|
|
||||||
tags: ${{ steps.meta-web.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-web.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Build celery image
|
- name: Build celery image
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
BRANCH_TAG=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')
|
||||||
context: .
|
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
||||||
file: ./docker/Dockerfile.celery
|
docker build -f ./docker/Dockerfile.celery -t mostovik-celery:${BRANCH_TAG} -t mostovik-celery:${BRANCH_TAG}-${SHA_SHORT} .
|
||||||
push: false
|
|
||||||
load: true
|
|
||||||
tags: ${{ steps.meta-celery.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-celery.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
push:
|
push:
|
||||||
name: Push to Gitea Registry
|
name: Push to Gitea Registry
|
||||||
@@ -185,63 +109,48 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git .
|
||||||
|
git checkout ${GITHUB_SHA}
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ vars.GITEA_REGISTRY_URL }}
|
|
||||||
username: ${{ secrets.GITEA_USERNAME }}
|
|
||||||
password: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Extract metadata for web image
|
|
||||||
id: meta-web
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository_owner }}/mostovik-web
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Extract metadata for celery image
|
|
||||||
id: meta-celery
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository_owner }}/mostovik-celery
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=sha,prefix={{branch}}-
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
|
|
||||||
- name: Build and push web image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./docker/Dockerfile.web
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta-web.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-web.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Build and push celery image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./docker/Dockerfile.celery
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta-celery.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-celery.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Image digest
|
|
||||||
run: |
|
run: |
|
||||||
echo "Web image digest: ${{ steps.docker_build_web.outputs.digest }}"
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login ${{ vars.GITEA_REGISTRY_URL }} -u ${{ secrets.GITEA_USERNAME }} --password-stdin
|
||||||
echo "Celery image digest: ${{ steps.docker_build_celery.outputs.digest }}"
|
|
||||||
|
- name: Build and push images
|
||||||
|
run: |
|
||||||
|
BRANCH_TAG=$(echo ${GITHUB_REF_NAME} | sed 's/\//-/g')
|
||||||
|
SHA_SHORT=$(echo ${GITHUB_SHA} | cut -c1-7)
|
||||||
|
REGISTRY="${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository_owner }}"
|
||||||
|
|
||||||
|
# Build and push web image
|
||||||
|
docker build -f ./docker/Dockerfile.web \
|
||||||
|
-t ${REGISTRY}/mostovik-web:${BRANCH_TAG} \
|
||||||
|
-t ${REGISTRY}/mostovik-web:${BRANCH_TAG}-${SHA_SHORT} \
|
||||||
|
.
|
||||||
|
docker push ${REGISTRY}/mostovik-web:${BRANCH_TAG}
|
||||||
|
docker push ${REGISTRY}/mostovik-web:${BRANCH_TAG}-${SHA_SHORT}
|
||||||
|
|
||||||
|
# Tag as latest if main branch
|
||||||
|
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||||
|
docker tag ${REGISTRY}/mostovik-web:${BRANCH_TAG} ${REGISTRY}/mostovik-web:latest
|
||||||
|
docker push ${REGISTRY}/mostovik-web:latest
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build and push celery image
|
||||||
|
docker build -f ./docker/Dockerfile.celery \
|
||||||
|
-t ${REGISTRY}/mostovik-celery:${BRANCH_TAG} \
|
||||||
|
-t ${REGISTRY}/mostovik-celery:${BRANCH_TAG}-${SHA_SHORT} \
|
||||||
|
.
|
||||||
|
docker push ${REGISTRY}/mostovik-celery:${BRANCH_TAG}
|
||||||
|
docker push ${REGISTRY}/mostovik-celery:${BRANCH_TAG}-${SHA_SHORT}
|
||||||
|
|
||||||
|
# Tag as latest if main branch
|
||||||
|
if [ "${GITHUB_REF_NAME}" = "main" ]; then
|
||||||
|
docker tag ${REGISTRY}/mostovik-celery:${BRANCH_TAG} ${REGISTRY}/mostovik-celery:latest
|
||||||
|
docker push ${REGISTRY}/mostovik-celery:latest
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Image summary
|
||||||
|
run: |
|
||||||
|
echo "Images pushed to ${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository_owner }}/"
|
||||||
|
|||||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -6,6 +6,19 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [0.4.1] - 2026-02-02
|
||||||
|
|
||||||
|
### Исправлено
|
||||||
|
|
||||||
|
#### CI/CD Pipeline
|
||||||
|
- Удалена зависимость от GitHub Actions (сеть блокирует доступ к GitHub)
|
||||||
|
- `actions/checkout@v4` → `git clone` с переменными Gitea
|
||||||
|
- `actions/setup-python@v4` → установка через `apt-get`
|
||||||
|
- `docker/build-push-action@v5` → чистые `docker build/push` команды
|
||||||
|
- Тесты используют `config.settings.test` (SQLite in-memory) вместо PostgreSQL service
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [0.4.0] - 2026-01-28
|
## [0.4.0] - 2026-01-28
|
||||||
|
|
||||||
### Добавлено
|
### Добавлено
|
||||||
|
|||||||
Reference in New Issue
Block a user