Skip to content

Commit c37941f

Browse files
committed
update ci/cd
1 parent ab9b015 commit c37941f

87 files changed

Lines changed: 2115 additions & 142400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Python dependencies
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "06:00"
10+
open-pull-requests-limit: 10
11+
assignees:
12+
- "yunjinqi"
13+
labels:
14+
- "dependencies"
15+
- "python"
16+
commit-message:
17+
prefix: "chore"
18+
include: "scope"
19+
20+
# Enable version updates for GitHub Actions
21+
- package-ecosystem: "github-actions"
22+
directory: "/"
23+
schedule:
24+
interval: "weekly"
25+
day: "monday"
26+
time: "06:00"
27+
open-pull-requests-limit: 5
28+
assignees:
29+
- "yunjinqi"
30+
labels:
31+
- "dependencies"
32+
- "github-actions"
33+
commit-message:
34+
prefix: "ci"
35+
include: "scope"

.github/workflows/codeql.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "CodeQL Security Analysis"
2+
3+
on:
4+
push:
5+
branches: [ master, main, develop ]
6+
pull_request:
7+
branches: [ master, main, develop ]
8+
schedule:
9+
- cron: '30 5 * * 1' # Weekly on Monday at 5:30 UTC
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'python' ]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
queries: security-and-quality
34+
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v3
37+
38+
- name: Perform CodeQL Analysis
39+
uses: github/codeql-action/analyze@v3
40+
with:
41+
category: "/language:${{matrix.language}}"

.github/workflows/docs.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build and Deploy Documentation
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build-docs:
21+
name: Build Documentation
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.11'
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install -r requirements.txt
37+
pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints nbsphinx
38+
pip install -e .
39+
40+
- name: Build documentation
41+
run: |
42+
# Create docs directory if it doesn't exist
43+
mkdir -p docs/_build
44+
45+
# Generate API documentation
46+
sphinx-apidoc -o docs/source backtrader
47+
48+
# Build HTML documentation
49+
cd docs && make html || echo "Documentation build completed with warnings"
50+
51+
- name: Upload documentation artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: documentation
55+
path: docs/_build/html/
56+
retention-days: 30
57+
58+
deploy-docs:
59+
name: Deploy to GitHub Pages
60+
needs: build-docs
61+
runs-on: ubuntu-latest
62+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
63+
64+
environment:
65+
name: github-pages
66+
url: ${{ steps.deployment.outputs.page_url }}
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Download documentation artifacts
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: documentation
76+
path: ./public
77+
78+
- name: Setup Pages
79+
uses: actions/configure-pages@v4
80+
81+
- name: Upload to Pages
82+
uses: actions/upload-pages-artifact@v3
83+
with:
84+
path: ./public
85+
86+
- name: Deploy to GitHub Pages
87+
id: deployment
88+
uses: actions/deploy-pages@v4

.github/workflows/publish.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
test_pypi:
9+
description: 'Publish to Test PyPI first'
10+
required: true
11+
default: 'true'
12+
type: choice
13+
options:
14+
- 'true'
15+
- 'false'
16+
17+
jobs:
18+
build:
19+
name: Build Distribution
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.11'
30+
31+
- name: Install build dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install build wheel setuptools twine
35+
36+
- name: Build distribution
37+
run: python -m build
38+
39+
- name: Check distribution
40+
run: twine check dist/*
41+
42+
- name: Upload distribution artifacts
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: dist
46+
path: dist/
47+
retention-days: 7
48+
49+
test-pypi:
50+
name: Publish to Test PyPI
51+
needs: build
52+
runs-on: ubuntu-latest
53+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.test_pypi == 'true'
54+
55+
steps:
56+
- name: Download distribution artifacts
57+
uses: actions/download-artifact@v4
58+
with:
59+
name: dist
60+
path: dist/
61+
62+
- name: Publish to Test PyPI
63+
uses: pypa/gh-action-pypi-publish@release/v1
64+
with:
65+
repository-url: https://test.pypi.org/legacy/
66+
skip-existing: true
67+
verbose: true
68+
69+
pypi:
70+
name: Publish to PyPI
71+
needs: build
72+
runs-on: ubuntu-latest
73+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.test_pypi == 'false')
74+
75+
steps:
76+
- name: Download distribution artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: dist
80+
path: dist/
81+
82+
- name: Publish to PyPI
83+
uses: pypa/gh-action-pypi-publish@release/v1
84+
with:
85+
skip-existing: true
86+
verbose: true

.github/workflows/release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version number (e.g., 1.0.0)'
11+
required: true
12+
type: string
13+
14+
jobs:
15+
create-release:
16+
name: Create Release
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install build wheel setuptools
36+
37+
- name: Determine version
38+
id: version
39+
run: |
40+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
41+
VERSION="${{ github.event.inputs.version }}"
42+
else
43+
VERSION=${GITHUB_REF#refs/tags/v}
44+
fi
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
echo "Version: $VERSION"
47+
48+
- name: Build package
49+
run: |
50+
python -m build
51+
52+
- name: Generate changelog
53+
id: changelog
54+
run: |
55+
echo "# Changelog for v${{ steps.version.outputs.version }}" > CHANGELOG_RELEASE.md
56+
echo "" >> CHANGELOG_RELEASE.md
57+
58+
# Get commits since last tag
59+
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
60+
if [ -z "$LAST_TAG" ]; then
61+
echo "## All Changes" >> CHANGELOG_RELEASE.md
62+
git log --pretty=format:"- %s (%h)" >> CHANGELOG_RELEASE.md
63+
else
64+
echo "## Changes since $LAST_TAG" >> CHANGELOG_RELEASE.md
65+
git log $LAST_TAG..HEAD --pretty=format:"- %s (%h)" >> CHANGELOG_RELEASE.md
66+
fi
67+
68+
echo "" >> CHANGELOG_RELEASE.md
69+
echo "## Installation" >> CHANGELOG_RELEASE.md
70+
echo '```bash' >> CHANGELOG_RELEASE.md
71+
echo "pip install backtrader==${{ steps.version.outputs.version }}" >> CHANGELOG_RELEASE.md
72+
echo '```' >> CHANGELOG_RELEASE.md
73+
74+
- name: Create GitHub Release
75+
uses: softprops/action-gh-release@v1
76+
with:
77+
tag_name: v${{ steps.version.outputs.version }}
78+
name: Release v${{ steps.version.outputs.version }}
79+
body_path: CHANGELOG_RELEASE.md
80+
draft: false
81+
prerelease: false
82+
files: |
83+
dist/*.whl
84+
dist/*.tar.gz
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Upload release artifacts
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: release-artifacts-${{ steps.version.outputs.version }}
92+
path: dist/
93+
retention-days: 90

.github/workflows/sync.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Sync to GitHub
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
- dev
9+
workflow_dispatch:
10+
11+
jobs:
12+
sync:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Add GitHub remote
21+
run: |
22+
git remote add github https://github.com/cloudQuant/backtrader.git || true
23+
git remote -v
24+
25+
- name: Push to GitHub
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.SYNC_GITHUB_TOKEN }}
28+
run: |
29+
# Configure git
30+
git config --global user.name "GitHub Actions"
31+
git config --global user.email "actions@github.com"
32+
33+
# Push all branches and tags
34+
git push https://${GITHUB_TOKEN}@github.com/cloudQuant/backtrader.git --all --force
35+
git push https://${GITHUB_TOKEN}@github.com/cloudQuant/backtrader.git --tags --force

0 commit comments

Comments
 (0)