chore(ci): use prebuilt python validation image
This commit is contained in:
+13
-14
@@ -18,7 +18,7 @@ jobs:
|
||||
validate:
|
||||
name: Validate Code Quality And Tests
|
||||
runs-on: ubuntu-latest
|
||||
container: python:3.12-slim
|
||||
container: xiaoxia-ci-python:3.12
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -48,28 +48,27 @@ jobs:
|
||||
archive.extract(member, '.')
|
||||
PY
|
||||
|
||||
- name: Prepare environment
|
||||
- name: Verify CI environment
|
||||
run: |
|
||||
python --version
|
||||
python -m pip --version
|
||||
python -m black --version
|
||||
python -m isort --version-number
|
||||
python -m flake8 --version
|
||||
bandit --version
|
||||
pytest --version
|
||||
echo "✅ Prebuilt CI environment is ready"
|
||||
|
||||
- name: Run code quality checks
|
||||
run: |
|
||||
python3 --version
|
||||
python3 -m venv .venv
|
||||
. .venv/bin/activate
|
||||
python -m pip install --index-url https://pypi.org/simple --upgrade pip
|
||||
python -m pip install --index-url https://pypi.org/simple -r requirements-quality.txt
|
||||
python -m pip install --index-url https://pypi.org/simple -r requirements-dev.txt
|
||||
|
||||
- name: Run code quality checks
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
python -m black --version
|
||||
python -m isort --version-number
|
||||
python -m flake8 --version
|
||||
python -m mypy --version
|
||||
bandit --version
|
||||
echo "✅ Code quality environment is ready"
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
pytest --version
|
||||
echo "✅ Test environment is ready"
|
||||
|
||||
|
||||
+13
-14
@@ -18,7 +18,7 @@ jobs:
|
||||
validate:
|
||||
name: Validate Code Quality And Tests
|
||||
runs-on: ubuntu-latest
|
||||
container: python:3.12-slim
|
||||
container: xiaoxia-ci-python:3.12
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -48,28 +48,27 @@ jobs:
|
||||
archive.extract(member, '.')
|
||||
PY
|
||||
|
||||
- name: Prepare environment
|
||||
- name: Verify CI environment
|
||||
run: |
|
||||
python --version
|
||||
python -m pip --version
|
||||
python -m black --version
|
||||
python -m isort --version-number
|
||||
python -m flake8 --version
|
||||
bandit --version
|
||||
pytest --version
|
||||
echo "✅ Prebuilt CI environment is ready"
|
||||
|
||||
- name: Run code quality checks
|
||||
run: |
|
||||
python3 --version
|
||||
python3 -m venv .venv
|
||||
. .venv/bin/activate
|
||||
python -m pip install --index-url https://pypi.org/simple --upgrade pip
|
||||
python -m pip install --index-url https://pypi.org/simple -r requirements-quality.txt
|
||||
python -m pip install --index-url https://pypi.org/simple -r requirements-dev.txt
|
||||
|
||||
- name: Run code quality checks
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
python -m black --version
|
||||
python -m isort --version-number
|
||||
python -m flake8 --version
|
||||
python -m mypy --version
|
||||
bandit --version
|
||||
echo "✅ Code quality environment is ready"
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
pytest --version
|
||||
echo "✅ Test environment is ready"
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||
PIP_NO_CACHE_DIR=0 \
|
||||
PIP_INDEX_URL=https://pypi.org/simple \
|
||||
VIRTUAL_ENV=/opt/xiaoxia-ci-venv \
|
||||
PATH=/opt/xiaoxia-ci-venv/bin:$PATH
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
COPY requirements-quality.txt requirements-dev.txt ./
|
||||
|
||||
RUN python -m venv "$VIRTUAL_ENV" \
|
||||
&& python -m pip install --retries 10 --timeout 120 -r requirements-quality.txt \
|
||||
&& python -m pip install --retries 10 --timeout 120 -r requirements-dev.txt \
|
||||
&& python -m black --version \
|
||||
&& python -m isort --version-number \
|
||||
&& python -m flake8 --version \
|
||||
&& bandit --version \
|
||||
&& pytest --version
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
IMAGE_NAME="${CI_IMAGE_NAME:-xiaoxia-ci-python:3.12}"
|
||||
|
||||
echo "🔨 Building CI image: $IMAGE_NAME"
|
||||
docker build \
|
||||
-f "$REPO_ROOT/infra/docker/ci.Dockerfile" \
|
||||
-t "$IMAGE_NAME" \
|
||||
"$REPO_ROOT"
|
||||
|
||||
echo "✅ CI image ready: $IMAGE_NAME"
|
||||
@@ -4,7 +4,6 @@
|
||||
black==26.5.1
|
||||
isort==8.0.1
|
||||
flake8==7.3.0
|
||||
mypy==2.1.0
|
||||
bandit==1.9.4
|
||||
|
||||
# 测试
|
||||
|
||||
@@ -4,5 +4,4 @@
|
||||
black==26.5.1
|
||||
isort==8.0.1
|
||||
flake8==7.3.0
|
||||
mypy==2.1.0
|
||||
bandit==1.9.4
|
||||
|
||||
Reference in New Issue
Block a user