modified: .github/workflows/md-check.yml
Check cpp / md pair / Check md headers (push) Successful in 4s

This commit is contained in:
hanyixuanten committed 2026-10-19 18:58:40 +08:00
1 parent 453d49e01a
commit 0779388b9c
1 file changed
+42 -42
+42 -42
View File
@@ -1,4 +1,4 @@
name: Check cpp / md pair and analyze cpp name: Check cpp / md pair
on: on:
push: push:
@@ -8,7 +8,7 @@ permissions:
jobs: jobs:
check-and-analyze: check-and-analyze:
name: Check md headers and analyze cpp name: Check md headers
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@@ -68,51 +68,51 @@ jobs:
exit $EXIT_CODE exit $EXIT_CODE
- name: Submit changed cpp files for analysis # - name: Submit changed cpp files for analysis
env: # env:
API_KEY: ${{ secrets.API_KEY }} # API_KEY: ${{ secrets.API_KEY }}
run: | # run: |
set -euo pipefail # set -euo pipefail
API_BASE="https://oia.vblg.top" # API_BASE="https://oia.vblg.top"
if [ ! -s /tmp/cpp_files.txt ]; then # if [ ! -s /tmp/cpp_files.txt ]; then
echo "没有需要分析的 .cpp 文件。" # echo "没有需要分析的 .cpp 文件。"
exit 0 # exit 0
fi # fi
while IFS= read -r cpp_file; do # while IFS= read -r cpp_file; do
[ -z "$cpp_file" ] && continue # [ -z "$cpp_file" ] && continue
echo "提交分析: $cpp_file" # echo "提交分析: $cpp_file"
BASE=$(basename "$cpp_file" .cpp) # BASE=$(basename "$cpp_file" .cpp)
CODE=$(cat "$cpp_file") # CODE=$(cat "$cpp_file")
PAYLOAD=$(jq -n \ # PAYLOAD=$(jq -n \
--arg problem_id "$BASE" \ # --arg problem_id "$BASE" \
--arg problem "" \ # --arg problem "" \
--arg code "$CODE" \ # --arg code "$CODE" \
--arg notes "" \ # --arg notes "" \
--arg language "cpp17" \ # --arg language "cpp17" \
'{ # '{
problem_id: $problem_id, # problem_id: $problem_id,
problem: $problem, # problem: $problem,
code: $code, # code: $code,
notes: $notes, # notes: $notes,
language: $language # language: $language
}') # }')
HTTP_CODE=$(curl -sS -o /tmp/resp.json -w "%{http_code}" \ # HTTP_CODE=$(curl -sS -o /tmp/resp.json -w "%{http_code}" \
-X POST "${API_BASE}/api/v1/analyze" \ # -X POST "${API_BASE}/api/v1/analyze" \
-H "Authorization: Bearer ${API_KEY}" \ # -H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \ # -H "Content-Type: application/json" \
-d "$PAYLOAD") # -d "$PAYLOAD")
if [ "$HTTP_CODE" != "202" ]; then # if [ "$HTTP_CODE" != "202" ]; then
echo "::error file=${cpp_file}::提交分析失败 (HTTP ${HTTP_CODE})" # echo "::error file=${cpp_file}::提交分析失败 (HTTP ${HTTP_CODE})"
cat /tmp/resp.json || true # cat /tmp/resp.json || true
exit 1 # exit 1
fi # fi
echo "已提交: $(cat /tmp/resp.json)" # echo "已提交: $(cat /tmp/resp.json)"
done < /tmp/cpp_files.txt # done < /tmp/cpp_files.txt