cpprefjp / site

cpprefjpサイトのMarkdownソース
https://cpprefjp.github.io/
368 stars 152 forks source link

外部リンクチェックCIのissue発行が動かなくなってる #1250

Closed faithandbrave closed 4 months ago

faithandbrave commented 4 months ago

https://github.com/cpprefjp/site/actions/workflows/outer_link_check.yml

CIが失敗しても、バッジも更新されていない模様。 内部リンクチェックもissue発行していませんが困っていないので、外部リンクチェックもissue発行しなくていいかもしれません。

yumetodo commented 4 months ago
{
  "message": "Problems parsing JSON",
  "documentation_url": "https://docs.github.com/rest/issues/issues#create-an-issue"
}

うーん?

yumetodo commented 4 months ago

issue作るスクリプトそのものは大丈夫ですね・・・。

https://github.com/yumetodo/site/issues/1

$./create_github_issue_when_not_empty.sh a.txt *** yumetodo/site aaa
{
  "url": "https://api.github.com/repos/yumetodo/site/issues/1",
  "repository_url": "https://api.github.com/repos/yumetodo/site",
  "labels_url": "https://api.github.com/repos/yumetodo/site/issues/1/labels{/name}",
  "comments_url": "https://api.github.com/repos/yumetodo/site/issues/1/comments",
  "events_url": "https://api.github.com/repos/yumetodo/site/issues/1/events",
  "html_url": "https://github.com/yumetodo/site/issues/1",
  "id": 2142433987,
  "node_id": "I_kwDOBOm_7M5_svLD",
  "number": 1,
  "title": "outer link check failed at aaa",
  "user": {
    "login": "yumetodo",
    "id": 10869046,
    "node_id": "MDQ6VXNlcjEwODY5MDQ2",
    "avatar_url": "https://avatars.githubusercontent.com/u/10869046?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/yumetodo",
    "html_url": "https://github.com/yumetodo",
    "followers_url": "https://api.github.com/users/yumetodo/followers",
    "following_url": "https://api.github.com/users/yumetodo/following{/other_user}",
    "gists_url": "https://api.github.com/users/yumetodo/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/yumetodo/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/yumetodo/subscriptions",
    "organizations_url": "https://api.github.com/users/yumetodo/orgs",
    "repos_url": "https://api.github.com/users/yumetodo/repos",
    "events_url": "https://api.github.com/users/yumetodo/events{/privacy}",
    "received_events_url": "https://api.github.com/users/yumetodo/received_events",
    "type": "User",
    "site_admin": false
  },
  "labels": [

  ],
  "state": "open",
  "locked": false,
  "assignee": null,
  "assignees": [

  ],
  "milestone": null,
  "comments": 0,
  "created_at": "2024-02-19T13:56:39Z",
  "updated_at": "2024-02-19T13:56:39Z",
  "closed_at": null,
  "author_association": "OWNER",
  "active_lock_reason": null,
  "body": "The commit hash was: _aaa_.\n\na\n",
  "closed_by": null,
  "reactions": {
    "url": "https://api.github.com/repos/yumetodo/site/issues/1/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
  },
  "timeline_url": "https://api.github.com/repos/yumetodo/site/issues/1/timeline",
  "performed_via_github_app": null,
  "state_reason": null
}
yumetodo commented 4 months ago

多分Issue本文として載せてるtxtファイルがjsonとしてvalidじゃなくさせているのだと思うので、とりあえずatficatに出してみようとcommit足してみました

faithandbrave commented 4 months ago

対応ありがとうございます!そしたら、いったん様子見ですかね

yumetodo commented 4 months ago

あ、そんな事する必要なかった、なぜなら本文のtxtはteeコマンドでコンソールに出しているから。

$cat a.txt
 URL http://www.mpir.org/ not found. requests.exceptions.ConnectionError : HTTPConnectionPool(host='www.mpir.org', port=80): Max retries exceeded with url: / (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7f57e8e85f10>: Failed to resolve 'www.mpir.org' ([Errno -2] Name or service not known)"))  from:['third_party_library.md']
URL https://github.com/cpprefjp/image/raw/master/reference/random/lognormal_distribution/lognormal_distribution.tsv.7z not found. 404 from:['reference/random/lognormal_distribution.md']

$./create_github_issue_when_not_empty.sh a.txt *** yumetodo/site aaa
{
  "message": "Problems parsing JSON",
  "documentation_url": "https://docs.github.com/rest/issues/issues#create-an-issue"
}

再現しましたね

yumetodo commented 4 months ago

JSONの組み立てを見直すべきそう

yumetodo commented 4 months ago

@faithandbrave jsonの組み立てをシェルスクリプトでどうにかするのが面倒なのでpythonで書き直してみました。

手元で動かして作ったIssueが https://github.com/yumetodo/site/issues/3 です。

もっとも、私はpythonを書いたことが殆どないので、この書き方でいいのか自信がないですが・・・(ほとんどBing Copilotにかかせた・・・)

yumetodo commented 4 months ago

https://github.com/cpprefjp/site/actions/runs/7962387892/job/21735782180

faithandbrave commented 4 months ago

https://github.com/cpprefjp/site/commit/deea6843c856c0ae236b8904b563911dbd247eda#diff-655a0f343fe4bfab2b462c1b404553524fc1b9c0bf2d8565f260f4a32d375d0eL9-L11

if [ "$(wc -l < "$1")" -eq 0 ]; then
    exit 0
fi

このへんの処理(check_result.txtが空だったら何もしない)がPython側スクリプトになかったようなので足しました。

faithandbrave commented 4 months ago

無事に動くようになったようです。

@yumetodo 対応ありがとうございました。

yumetodo commented 4 months ago

あっ・・・、成功時にissue作らなくするのは見落としてました、ありがとうございます