Skip to content

Commit f6a999b

Browse files
committed
v0.1.0
2 parents a78dd22 + 5956383 commit f6a999b

Some content is hidden

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

67 files changed

+13932
-4
lines changed

.github/md-link-config.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^http://localhost"
5+
},
6+
{
7+
"pattern": "^http://0.0.0.0"
8+
},
9+
{
10+
"pattern": "^https://github.com/user-attachments/assets/"
11+
}
12+
],
13+
"httpHeaders": [
14+
{
15+
"urls": ["https://github.com/", "https://guides.github.com/", "https://help.github.com/", "https://docs.github.com/"],
16+
"headers": {
17+
"Accept-Encoding": "zstd, br, gzip, deflate"
18+
}
19+
}
20+
],
21+
"timeout": "20s",
22+
"retryOn429": true,
23+
"retryCount": 5,
24+
"fallbackRetryDelay": "30s",
25+
"aliveStatusCodes": [200, 206, 429]
26+
}
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
DOCKERHUB_USERNAME: mmmay0722
10+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
11+
REGISTRY: docker.io
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 60
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Log in to Docker Hub
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ${{ env.REGISTRY }}
29+
username: ${{ env.DOCKERHUB_USERNAME }}
30+
password: ${{ env.DOCKERHUB_TOKEN }}
31+
32+
- name: Extract tag name
33+
id: extract_tag
34+
run: |
35+
if [[ $GITHUB_REF == refs/tags/* ]]; then
36+
TAG_NAME=${GITHUB_REF#refs/tags/}
37+
echo "is_tag=true" >> $GITHUB_OUTPUT
38+
else
39+
TAG_NAME="latest"
40+
echo "is_tag=false" >> $GITHUB_OUTPUT
41+
fi
42+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
43+
echo "Extracted tag: $TAG_NAME"
44+
45+
- name: Build and push Docker image
46+
uses: docker/build-push-action@v5
47+
timeout-minutes: 30
48+
with:
49+
context: .
50+
file: ./Dockerfile
51+
push: true
52+
tags: ${{ env.REGISTRY }}/${{ env.DOCKERHUB_USERNAME }}/webqa-agent:${{ steps.extract_tag.outputs.tag_name }}
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max
55+
platforms: linux/amd64
56+
provenance: false
57+
sbom: false
58+
59+
create-release:
60+
needs: build-and-push
61+
runs-on: ubuntu-latest
62+
if: startsWith(github.ref, 'refs/tags/v')
63+
permissions:
64+
contents: write
65+
discussions: write
66+
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
with:
71+
fetch-depth: 0
72+
73+
- name: Extract tag name
74+
id: extract_tag
75+
run: |
76+
TAG_NAME=${GITHUB_REF#refs/tags/}
77+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
78+
echo "Current tag: $TAG_NAME"
79+
80+
- name: Generate changelog
81+
id: changelog
82+
run: |
83+
CURRENT_TAG=${{ steps.extract_tag.outputs.tag_name }}
84+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
85+
86+
echo "## 🚀 Release $CURRENT_TAG" > CHANGELOG.md
87+
echo "" >> CHANGELOG.md
88+
echo "### 📦 Docker Images" >> CHANGELOG.md
89+
echo "- \`${{ env.DOCKERHUB_USERNAME }}/webqa-agent:$CURRENT_TAG\`" >> CHANGELOG.md
90+
echo "" >> CHANGELOG.md
91+
92+
if [ -n "$PREVIOUS_TAG" ]; then
93+
echo "### 📝 Changes since $PREVIOUS_TAG" >> CHANGELOG.md
94+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..$CURRENT_TAG >> CHANGELOG.md
95+
else
96+
echo "### 📝 Initial Release" >> CHANGELOG.md
97+
echo "This is the initial release of WebQA Agent." >> CHANGELOG.md
98+
fi
99+
100+
- name: Create GitHub Release
101+
uses: softprops/action-gh-release@v1
102+
with:
103+
tag_name: ${{ steps.extract_tag.outputs.tag_name }}
104+
name: Release ${{ steps.extract_tag.outputs.tag_name }}
105+
body_path: CHANGELOG.md
106+
draft: false
107+
prerelease: false
108+
generate_release_notes: true
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
112+
notify:
113+
needs: [build-and-push, create-release]
114+
runs-on: ubuntu-latest
115+
if: always()
116+
117+
steps:
118+
- name: Notify build status
119+
run: |
120+
if [ "${{ needs.build-and-push.result }}" == "success" ]; then
121+
echo "✅ Docker image built and pushed successfully!"
122+
echo "✅ Both versioned and latest tags have been updated!"
123+
else
124+
echo "❌ Docker image build failed!"
125+
exit 1
126+
fi
127+
128+
if [ "${{ needs.create-release.result }}" == "success" ] || [ "${{ needs.create-release.result }}" == "skipped" ]; then
129+
echo "✅ Release process completed successfully!"
130+
else
131+
echo "❌ Release process failed!"
132+
fi

.gitignore

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
3-
*.py[codz]
3+
*.py[cod]
44
*$py.class
5+
.DS_Store
56

67
# C extensions
78
*.so
@@ -143,6 +144,8 @@ venv/
143144
ENV/
144145
env.bak/
145146
venv.bak/
147+
node_modules/
148+
package-lock*.json
146149

147150
# Spyder project settings
148151
.spyderproject
@@ -182,9 +185,9 @@ cython_debug/
182185
.abstra/
183186

184187
# Visual Studio Code
185-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
188+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186189
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
190+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188191
# you could uncomment the following to ignore the entire vscode folder
189192
# .vscode/
190193

@@ -205,3 +208,26 @@ cython_debug/
205208
marimo/_static/
206209
marimo/_lsp/
207210
__marimo__/
211+
212+
# IDEs
213+
.vscode/
214+
.idea/
215+
216+
# Temp files
217+
./tmp/*
218+
219+
# Data files
220+
/log/*
221+
/logs/*
222+
*log
223+
*.log
224+
report/
225+
reports/
226+
output/
227+
.pytest*
228+
test.py
229+
test_cases_*.json
230+
231+
#config
232+
.env
233+
config/config*.yaml

.pre-commit-config.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
repos:
2+
# - repo: https://github.com/psf/black
3+
# rev: 25.1.0
4+
# hooks:
5+
# - id: black
6+
# args: ["--line-length=120"]
7+
- repo: https://github.com/PyCQA/flake8
8+
rev: 7.2.0
9+
hooks:
10+
- id: flake8
11+
args: [
12+
"--select=E,F",
13+
"--ignore=E741,E731,E722,E721,E501,E402,E266,E265,E262,E203,F403,F405",
14+
"--exclude=**/__init__.py",
15+
"--max-line-length=120"
16+
]
17+
- repo: https://github.com/PyCQA/isort
18+
rev: 6.0.1
19+
hooks:
20+
- id: isort
21+
- repo: https://github.com/codespell-project/codespell
22+
rev: v2.4.1
23+
hooks:
24+
- id: codespell
25+
args: ["--skip=*.po,*.ts,*.css", "--ignore-regex=\\b\\w{2,3}\\b"]
26+
- repo: https://github.com/pre-commit/pre-commit-hooks
27+
rev: v4.3.0
28+
hooks:
29+
- id: trailing-whitespace
30+
- id: check-yaml
31+
- id: end-of-file-fixer
32+
- id: requirements-txt-fixer
33+
- id: double-quote-string-fixer
34+
- id: check-merge-conflict
35+
- id: fix-encoding-pragma
36+
args: ["--remove"]
37+
- id: mixed-line-ending
38+
args: ["--fix=lf"]
39+
- id: detect-private-key
40+
- id: check-json
41+
- repo: https://github.com/executablebooks/mdformat
42+
rev: 0.7.9
43+
hooks:
44+
- id: mdformat
45+
args: ["--number", "--table-width", "200"]
46+
additional_dependencies:
47+
- mdformat-openmmlab
48+
- mdformat_frontmatter
49+
- linkify-it-py
50+
- repo: https://github.com/myint/docformatter
51+
rev: v1.7.7
52+
hooks:
53+
- id: docformatter
54+
language: python
55+
args: ["--in-place", "--wrap-descriptions", "79"]
56+
- repo: https://github.com/jackdewinter/pymarkdown
57+
rev: v0.9.30
58+
hooks:
59+
- id: pymarkdown
60+
args: [fix]
61+
- repo: https://github.com/gitleaks/gitleaks
62+
rev: v8.27.0
63+
hooks:
64+
- id: gitleaks
65+
entry: "gitleaks dir"
66+
args: [
67+
"--verbose",
68+
"--redact=50"
69+
]
70+
- repo: https://github.com/PyCQA/pylint/
71+
rev: v3.3.7
72+
hooks:
73+
- id: pylint
74+
name: pylint
75+
entry: pylint
76+
language: system
77+
types: [python]
78+
require_serial: false
79+
args:
80+
[ "--jobs=4",
81+
"--disable=all",
82+
"--enable=E,F",
83+
"--disable=E0401,E0402,E0102,E1101",
84+
"-sn"
85+
]
86+
- repo: https://github.com/tcort/markdown-link-check
87+
rev: v3.12.2
88+
hooks:
89+
- id: markdown-link-check
90+
args: [-q,-c, ./.github/md-link-config.json]

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
FROM mcr.microsoft.com/playwright/python:v1.52.0-noble
2+
3+
# 设置工作目录
4+
WORKDIR /app
5+
6+
# 安装 Node.js 和 npm,以及必要的工具
7+
RUN apt-get update && apt-get install -y \
8+
curl \
9+
unzip \
10+
wget \
11+
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
12+
&& apt-get install -y nodejs \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# 优化pip配置和网络设置
16+
RUN pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple && \
17+
pip config set global.trusted-host mirrors.tuna.tsinghua.edu.cn && \
18+
pip config set global.timeout 300 && \
19+
pip config set global.retries 5
20+
21+
# 1. 先安装nuclei
22+
RUN ARCH=$(dpkg --print-architecture) && \
23+
if [ "$ARCH" = "amd64" ]; then \
24+
NUCLEI_ARCH="amd64"; \
25+
elif [ "$ARCH" = "arm64" ]; then \
26+
NUCLEI_ARCH="arm64"; \
27+
else \
28+
NUCLEI_ARCH="amd64"; \
29+
fi && \
30+
wget -O /tmp/nuclei.zip "https://github.com/projectdiscovery/nuclei/releases/download/v3.4.7/nuclei_3.4.7_linux_${NUCLEI_ARCH}.zip" && \
31+
mkdir -p /tmp/nuclei && \
32+
cd /tmp/nuclei && \
33+
unzip /tmp/nuclei.zip && \
34+
mv nuclei /usr/local/bin/ && \
35+
chmod +x /usr/local/bin/nuclei && \
36+
rm -rf /tmp/nuclei /tmp/nuclei.zip
37+
38+
# 2. 复制Python依赖文件并安装
39+
COPY requirements.txt /app/
40+
RUN pip install --no-cache-dir --default-timeout=300 -r requirements.txt
41+
42+
# 3. 复制Node.js依赖文件并安装
43+
COPY package.json /app/
44+
RUN npm install
45+
46+
# 4. 复制项目文件
47+
COPY . /app
48+
49+
# 更新nuclei模板
50+
RUN nuclei -ut -v
51+
52+
# 设置运行webqa-agent
53+
CMD ["python", "webqa-agent.py"]

0 commit comments

Comments
 (0)