Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sakura editor のビルド用の GitHub Actions を導入する #1259

Conversation

m-tmatma
Copy link
Member

@m-tmatma m-tmatma commented May 3, 2020

PR の目的

sakura editor のビルド用の GitHub Actions を導入する

カテゴリ

  • CI関連
    • GitHub Actions

GitHub Actions の特徴

  • GitHub Actions は GitHub 製の CI ツールです。(appveyor や azure pipeline みたいに)
  • GitHub Actions は同時に 20 個 workflow の実行が可能
  • GitHub Actions はオープンソースに対してはフリー
  • GitHub Actions の artifacts の保存期間は 90 日
  • GitHub Actions は GitHub アカウントがあれば利用可能
  • GitHub Actions は GitHub ユーザー自身が GitHubアクションを作成、公開、利用可能
  • GitHub Actions は GitHub 製のGitHubアクションも GitHub で公開されているので必要に応じて PR を送ることも可能

PR の背景

sakura-editor/sakura-editor.github.io#6 で doxygen の管理をどうするか検討する中で、GitHub Actions を使えないか検討 を行っていた。

その結果、sakura-editor/sakura-editor.github.io#24sakura-editor/sakura-editor.github.io#25 でも GitHub Actions で GitHub Pages に展開できそうなので、GitHub Actions の調査を行っていた。

いろいろ調べたところ GitHub Actions は非常に強力なので、すでに使われている appveyor や Azure Pipelines に加えて導入してみたらいいんじゃないかと思い、実験してみたところ動作したので、導入してみようと思います。

いろいろ修正したほうがいいところはあると思いますが、最初に導入するレベルとしてはいいのではないかと思います。

注意

※ この PR では GitHub Actions のビルドは走っていませんが、いったん master にマージされればこのリポジトリで GitHub Actions が有効になり、以降の PR で有効になると考えられます。

PR のメリット

  • GitHub Actions を使ってみて、いろいろ試すきっかけになる
  • Appveyor や Azure Pipelines と異なり、別途アカウントを作成しなくても GitHub ユーザーなら自動的に使える

PR のデメリット (トレードオフとかあれば)

なし

未実装なところ

PR の影響範囲

なし

関連チケット

#967
#922
#1183

参考資料

https://github.co.jp/features/actions
https://help.github.com/ja/actions/getting-started-with-github-actions/about-github-actions

@m-tmatma m-tmatma added the CI appveyor など CI 関連 【ChangeLog除外】 label May 3, 2020
@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

説明欄の PR の背景 を訂正

@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

この PR に含まれていないのは https://github.com/sakura-editor/sakura にはまだ設定ファイルが取り込まれていないためだと思う。

https://github.com/m-tmatma/sakura/actions
では特に設定を行わなくてもビルドされた。


# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
Copy link
Member Author

@m-tmatma m-tmatma May 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

メモ

actions/checkouthttps://github.com/actions/checkout でソースが公開されている GitHub 純正の GitHub Action です。ソースを checkout します。

@v2 というのは actions/checkout のバージョンです。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

雑談

「謹製」に関して
https://suzumi-ya.com/epub/post-990/

@AppVeyorBot
Copy link

Build sakura 1.0.2746 completed (commit 9bb5912853 by @m-tmatma)

uses: actions/upload-artifact@v2
with:
name: exe ${{ matrix.platform }} ${{ matrix.config }}
path: '*.zip'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

メモ

パス名の部分で wildcard が使えるのは actions/upload-artifact@v2 以降。
actions/upload-artifact@v1 では使えなくて悩んだ。

- uses: actions/checkout@v2

- name: Add msbuild to PATH
uses: microsoft/[email protected]
Copy link
Member Author

@m-tmatma m-tmatma May 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

現状では msbuild に対してバージョン指定してないので Visual studio 2019 が使われる

https://github.com/microsoft/setup-msbuild
の markdown 参照

@k-takata
Copy link
Member

k-takata commented May 3, 2020

この PR に含まれていないのは https://github.com/sakura-editor/sakura にはまだ設定ファイルが取り込まれていないためだと思う。

pull_request: のブランチが masterrelease/* に制限されているからでしょう。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

pull_request: のブランチが masterrelease/* に制限されているからでしょう。

追加してみたけど変化ありませんでした。

https://help.github.com/ja/actions/reference/workflow-syntax-for-github-actions
を確認したところ、以下となっており、pull_request で指定するのはマージ先のようです。

on.<push|pull_request>.<branches|tags>
pushおよびpull_requestイベントを使用する場合、特定のブランチまたはタグで
実行するワークフローを設定できます。 pull_requestでは、ベース上のブランチ
及びタグだけが評価されます。 tagsもしくはbranchesだけを定義すると、
定義されていないGit refに影響するイベントに対して、ワークフローが実行されません。

@k-takata
Copy link
Member

k-takata commented May 3, 2020

ありゃ、違ってましたか。すんません。
ベースブランチで既に GHA が有効化されてないと動かないのかな。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

この PR に含まれていないのは https://github.com/sakura-editor/sakura にはまだ設定ファイルが取り込まれていないためだと思う。

ちなみに別のリポジトリで試しているものでは PR に対して実行されています。
test-sakura-editor#1

こちらは master に対して実行する設定ファイルが master に含まれています。

@AppVeyorBot
Copy link

Build sakura 1.0.2747 completed (commit 704ea0ebf2 by @m-tmatma)

@AppVeyorBot
Copy link

Build sakura 1.0.2748 completed (commit 491a4335cf by @m-tmatma)

@k-takata
Copy link
Member

k-takata commented May 3, 2020

権限がない人からのPRだとダメだけど、権限があればPRで設定ファイルを追加しても行けるとか?

@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

権限がない人からのPRだとダメだけど、権限があればPRで設定ファイルを追加しても行けるとか?

どういうことですか?
どちらのリポジトリでも、私は、書き込み権限あります。

@berryzplus
Copy link
Contributor

これがナニをするものか、未知の領域なので判断付かない感じです。

  • 雰囲気、便利そう。
  • なんかあったらそれは別に対応したらいいじゃないか。

ということで異論なしっす。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

これがナニをするものか、未知の領域なので判断付かない感じです。

GitHub Actions は GitHub 製の CI ツールです。(appveyor や azure pipeline みたいに)
説明欄に記載しました。

@k-takata
Copy link
Member

k-takata commented May 3, 2020

どちらのリポジトリでも、私は、書き込み権限あります。

書き込み権限があってもowner権限がないと多分ダメなのではないかと。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

owner権限も両方あります。
単純にマージ 対象のブランチに設定ファイルが、入ってないのが、
原因かと思います

@k-takata
Copy link
Member

k-takata commented May 3, 2020

どちらのリポジトリもベースブランチに設定ファイルが無い状態なのに違いが出たという話だと勘違いしてました。

Copy link
Contributor

@berryzplus berryzplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

入れてみないと分からん気配なので、入れて試してみましょう。
変なことは起きないと思いますが、なんか起きたらrevert含め対処する感じでお願い:smile:

@m-tmatma m-tmatma merged commit 2c77cc7 into sakura-editor:master May 3, 2020
@m-tmatma
Copy link
Member Author

m-tmatma commented May 3, 2020

マージしたらビルド走りました
https://github.com/sakura-editor/sakura/actions/runs/94359619

@m-tmatma m-tmatma deleted the feature/introduce-github-actions-sakura-build branch May 3, 2020 08:59
@berryzplus
Copy link
Contributor

このPRをマージしたあとの master をベースにしたブランチを push できませんでした。
rebase して push しちゃったので詳細見てなかったんですが、なんか設定が必要になる系?
(失敗したpushは自分とこ https://github.com/berryzplus/sakura 宛てでした。)

手順を踏めばなんとかなるようなら問題だとは思わない感じです。
う~ん、やっぱり出るなぁ・・・。

git.exe push --set-upstream --progress "origin" feature/github_actions_test
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 494 bytes | 494.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To https://github.com/berryzplus/sakura.git
! [remote rejected]     feature/github_actions_test -> feature/github_actions_test (refusing to allow an OAuth App to create or update workflow `.github/workflows/build-sakura.yml` without `workflow` scope)
error: failed to push some refs to 'https://github.com/berryzplus/sakura.git'


git did not exit cleanly (exit code 1) (5625 ms @ 2020/05/04 1:52:54)

@m-tmatma m-tmatma mentioned this pull request May 4, 2020
5 tasks
@berryzplus
Copy link
Contributor

放置かいっ!w

このメッセージがエラー原因のように見えました。

! [remote rejected] feature/github_actions_test -> feature/github_actions_test (refusing to allow an OAuth App to create or update workflow .github/workflows/build-sakura.yml without workflow scope)
error: failed to push some refs to 'https://github.com/berryzplus/sakura.git'

workflow スコープがどうたらってとこと、OAuth App がどうたらってとこがヒントなのかな?

その辺の手順というか、「前提としてこういう設定が必要」みたいな情報が欲しいです。
おいらのとこのリポジトリは、まだなんも設定しとらん状態なので。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 4, 2020

放置かいっ!w

気づかなかった。

rebase して push しちゃったので詳細見てなかったんですが、なんか設定が必要になる系?

rebase して push した場合 --force または --force-with-lease が必要です。
ただ、いまいち何をしたのかがわからないです。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 4, 2020

ただ、いまいち何をしたのかがわからないです。

なお、tortoisegit を使うと履歴を視覚的に表示してくれるので便利です。
https://tortoisegit.org/docs/tortoisegit/tgit-dug-revgraph.html

@berryzplus
Copy link
Contributor

ただ、いまいち何をしたのかがわからないです。

すみません、分かるように書いていませんでした。

  1. 現master(2c77cc7) をベースにコミットを積んでローカルブランチを作った。
  2. 自分のとこのリポジトリ(https://github.com/berryzplus/sakura.git) に push しようとしたら、なんかエラーが出た(詳細見てない)
  3. よくわからんので一個前のmaster(d2a5a15)にリベースした。
  4. 自分のとこのリポジトリ(https://github.com/berryzplus/sakura.git) に pushできた ⇒ https://github.com/berryzplus/sakura/tree/feature/fix_mailaddress_detection
  5. 原因わからずじまいでキモいので現master(2c77cc7) をベースにコミットを積んでローカルブランチを作った。feature/github_actions_test
  6. 自分のとこのリポジトリ(https://github.com/berryzplus/sakura.git) に push しようとしたらなんかエラーが出た(sakura editor のビルド用の GitHub Actions を導入する #1259 の「やっぱり出るなぁ」以降のログが出力された。)

@k-takata
Copy link
Member

k-takata commented May 4, 2020

(refusing to allow an OAuth App to create or update workflow .github/workflows/build-sakura.yml without workflow scope)

github の認証はどうやってますか? sshを使っているのならば何も設定する必要はないはずですが、エラーメッセージから察するに、httpsでパスワードにpersonal access tokenを使っているのだとしたら、workflow スコープにチェックを入れてtokenを作り直す必要があると思います。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 4, 2020

(refusing to allow an OAuth App to create or update workflow .github/workflows/build-sakura.yml without workflow scope)

github の認証はどうやってますか? sshを使っているのならば何も設定する必要はないはずですが、エラーメッセージから察するに、httpsでパスワードにpersonal access tokenを使っているのだとしたら、workflow スコープにチェックを入れてtokenを作り直す必要があると思います。

最初これを読んで意味がわからなかったです。

https://github.com/settings/tokens/new で token 作るときに workflow にチェックをつけて token を作ったものを指定するということですね。 @k-takata

image

参考
https://github.community/t5/GitHub-Actions/Refusing-to-allow-an-integration-to-create-or-update/td-p/32472

@berryzplus
Copy link
Contributor

github の認証はどうやってますか?

設定するのがめんどくて https:// のパスワード認証です。

sshを使っているのならば何も設定する必要はないはずですが、エラーメッセージから察するに、httpsでパスワードにpersonal access tokenを使っているのだとしたら、workflow スコープにチェックを入れてtokenを作り直す必要があると思います。

ふむむ...
単にアクセスプロトコルを git: にしたら動くのかな?

OAuth で思いついて GitHubSettings にある Authorized Apps をチェックしてみたら GitHub Actions は居ませんでした(=たぶんこれ、Authorizedになってない... )

もうちょっと見て見ます。

@m-tmatma
Copy link
Member Author

m-tmatma commented May 4, 2020

OAuth で思いついて GitHubSettings にある Authorized Apps をチェックしてみたら GitHub Actions は居ませんでした(=たぶんこれ、Authorizedになってない... )

https://github.com/settings/tokens
はどうなっていますか?

@berryzplus
Copy link
Contributor

普通に書き間違ってたんですけど RSA鍵 を登録して ssh接続 するようにしたらpushできました。(git: って書いてますが、元からSSH接続を設定するつもりでした。用語、超ぁゃしぃ...

https://github.com/settings/tokens
はどうなっていますか?

モバイル用に作成した token が3つほど登録されております...。
試しに workflow の権限付けてみたら push が成功しました。

というわけで、おいらの問題は解決っす。
ありがとうございます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI appveyor など CI 関連 【ChangeLog除外】
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants