2022年5月27日金曜日

AppVeyor で cygwin setup に失敗するようになったので対応した

2022/05/20 ごろから AppVeyor で Cygwin のセットアップが失敗するようになりました。

Starting cygwin install, version 2.900
User has backup/restore rights
Current Directory: C:\cygwin/var/cache/setup
Could not open service McShield for query, start and stop. McAfee may not be installed, or we don't have access.
root: C:\cygwin system
Selected local directory: C:\cygwin/var/cache/setup
net: Preconfig
site: http://cygwin.mirror.constant.com/
mbox Parse Errors:  line 12: The current ini file requires at least version 2.903 of setup.
Please download a newer version from https://cygwin.com/setup-x86.exe
unattended_mode is set at mbox: returning default value
site: http://cygwin.mirror.constant.com/
mbox Parse Errors:  line 12: The current ini file requires at least version 2.903 of setup.
Please download a newer version from https://cygwin.com/setup-x86.exe
unattended_mode is set at mbox: returning default value
site: http://cygwin.mirror.constant.com/
mbox Parse Errors:  line 12: The current ini file requires at least version 2.903 of setup.
Please download a newer version from https://cygwin.com/setup-x86.exe
unattended_mode is set at mbox: returning default value
site: http://cygwin.mirror.constant.com/
mbox Parse Errors:  line 12: The current ini file requires at least version 2.903 of setup.
Please download a newer version from https://cygwin.com/setup-x86.exe
unattended_mode is set at mbox: returning default value
site: http://cygwin.mirror.constant.com/
mbox Parse Errors:  line 12: The current ini file requires at least version 2.903 of setup.
Please download a newer version from https://cygwin.com/setup-x86.exe
unattended_mode is set at mbox: returning default value
download/verify error in unattended_mode: out of retries
note: Installation incomplete.  Check C:\cygwin\var\log\setup.log.full for details
Ending cygwin install

issue も出てます。対処方法もそこでコメントされている通りで、最新の setup exe を上書きダウンロードして使用すれば OK です。

https://github.com/appveyor/ci/issues/3820

Powershell であれば issue のリンクのように書けば対応できます。
64bit 版は setup-x86_64.exe をダウンロードして C:\cygwin64\setup-x86_64.exe に保存します。
https://github.com/appveyor/build-images/blob/master/scripts/Windows/install_cygwin.ps1#L10-L13

Powershell 以外であれば curl で下記のようにダウンロードすれば大丈夫です。

      curl -sSL -o C:\cygwin\setup-x86.exe "https://cygwin.com/setup-x86.exe"
      curl -sSL -o C:\cygwin64\setup-x86_64.exe "https://cygwin.com/setup-x86_64.exe"

今回は以上。


2022年5月18日水曜日

GitHub Actions で export-ignore 指定したパスがワークスペースになくて composite action が実行できなかった話

なにが起きたか

workflow の中で composite action として .github フォルダに置いた action を実行しようとしたところで、パスが存在しなくて失敗してました。


こんな感じのステップ
      - name: report
        uses: ./.github/actions/composite/test-report
        with:
          report_paths: test/*.xml
        if: always()

この composite action はいろいろなジョブで使っていたのですが、なぜか一部のジョブだけ失敗してました。
失敗していたジョブの共通点としては container 指定していて、 runner 上ではなく in コンテナなジョブであることでした。

なぜ .github フォルダがないのか?

確認してみるとパス指定ミスでもなく本当に .github フォルダがありませんでした。
ないフォルダはそれだけではなく、いくつか存在しないパスがありました。

これ見て即座に git export の除外指定だなとわかりました。
大分昔に Release 時に不要なパスが含まれないようにしていたのでした。
(git export の使い方としてあっているのかは知らない)

git export の設定を修正して、リリースワークフローを変えれば解決はするのですが、本質的ではないので export 設定はこのままにし、調査を続行。

なぜアーカイブダウンロードになったか?

export-ignore は clone/checkout には影響がないはずですし、
checkout 後にこれらのパスを削除するようなことはないです。
そこで actions@checkout ステップのログを確認してみると

なせかアーカイブダウンロードしてました。(なぜ?)
よくよく見ると・・・

The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
って書いてありました。つまり、コンテナにインストールされている git のバージョンが古いということですね!
これでコンテナ使ってるジョブだけ失敗するのも腑に落ちました。
どうしたか

使用してたコンテナイメージを更新して、インストールされている git のバージョンを更新しました。
git がインストールすらされていないコンテナイメージもありましたが、それでもなんとかしてくれる actions@checkout 偉いなと思いました。

コンテナの git が古い・ない、かつ export-ignore してるというなかなか踏むことなさそうな条件ですが、誰かの参考になれば幸いです。
では。