85 lines
2.0 KiB
YAML
85 lines
2.0 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
- 'feature/**'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- develop
|
|
|
|
jobs:
|
|
code-quality:
|
|
name: Code Quality Check
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} https://api.xiaoxiajianji.com/git/${GITHUB_REPOSITORY}.git .
|
|
git checkout ${GITHUB_SHA}
|
|
|
|
- name: Install quality tools
|
|
run: |
|
|
apt-get update
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
|
python3-black \
|
|
python3-isort \
|
|
python3-flake8 \
|
|
python3-mypy \
|
|
python3-bandit
|
|
|
|
- name: Run checks
|
|
run: |
|
|
python3 --version
|
|
black --version
|
|
isort --version-number
|
|
flake8 --version
|
|
mypy --version
|
|
bandit --version
|
|
echo "✅ Code quality environment is ready"
|
|
|
|
test:
|
|
name: Run Tests
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
needs:
|
|
- code-quality
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
git clone --depth=1 --branch=${GITHUB_REF_NAME} https://api.xiaoxiajianji.com/git/${GITHUB_REPOSITORY}.git .
|
|
git checkout ${GITHUB_SHA}
|
|
|
|
- name: Install test tools
|
|
run: |
|
|
apt-get update
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
|
python3-pytest \
|
|
python3-pytest-cov
|
|
|
|
- name: Run tests
|
|
run: |
|
|
python3 --version
|
|
pytest --version
|
|
echo "✅ Test environment is ready"
|
|
|
|
build-summary:
|
|
name: Build Summary
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test
|
|
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Summary
|
|
run: |
|
|
echo "✅ Build completed successfully!"
|
|
echo "Branch: ${GITHUB_REF_NAME}"
|
|
echo "Commit: ${GITHUB_SHA}"
|