简体   繁体   English

使用 github 操作在 Windows 上测试 Perl

[英]Testing Perl on Windows with github actions

I've released MooseX::Extended to the CPAN ( github repository here ).我已经发布了MooseX::Extended到 CPAN(这里是 github 存储库)。

I'm trying to set up github actions and the linux tests run just fine.我正在尝试设置 github 操作,并且 linux 测试运行良好。 However, ( Windows is failing with this error :但是,( Windows 因此错误而失败

Configuring true-v1.0.2 ... OK
==> Found dependencies: Function::Parameters
--> Working on Function::Parameters
Fetching http://www.cpan.org/authors/id/M/MA/MAUKE/Function-Parameters-2.001003.tar.gz ... OK
Configuring Function-Parameters-2.001003 ... OK
Building Function-Parameters-2.001003 ... OK
Successfully installed Function-Parameters-2.001003
! Installing true failed. See C:\Users\RUNNER~1\.cpanm\work\1653412748.5640\build.log for details. Retry with --force to force install it.
Building true-v1.0.2 ... FAIL

Of course, I can't see that C:\Users\RUNNER~1\.cpanm\work\1653412748.5640\build.log to understand what happened.当然,我看不到C:\Users\RUNNER~1\.cpanm\work\1653412748.5640\build.log以了解发生了什么。

The true module passes its CPAN testers tests on Windows , so I don't know why it's failing in Github Actions. true的模块在 Windows 上通过了它的 CPAN 测试人员测试,所以我不知道为什么它在 Github Actions 中失败了。

My workflow looks like this:我的工作流程如下所示:

# Hacked from https://github.com/skaji/perl-github-actions-sample/blob/master/.github/workflows/windows.yml
# See also: https://perlmaven.com/github-actions-running-on-3-operating-systems
name: windows

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:

jobs:
  perl:
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        perl-version:
          - '5.20'
          - '5.22'
          - '5.24'
          - '5.26'
          - '5.28'
          - '5.30'
          - '5.32'
          - '5.34'
          - 'latest'
    steps:
      - uses: actions/checkout@v2
      - name: Set up Perl
        run: |
          choco install strawberryperl
          echo "C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin" >> $GITHUB_PATH
      - name: perl -V
        run: perl -V
      - name: Install Dependencies
        run: curl -sL https://git.io/cpm | perl - install -g --show-build-log-on-failure Dist::Zilla
      - name: Run Tests
        run: |
          dzil authordeps --missing | cpanm --notest
          dzil listdeps --author --missing | cpanm --notest
          dzil test --author --release

This is the PR to which the actions are attached .这是附加操作的 PR

I don't have access to a Windows box.我无权访问 Windows 框。 Does anyone know what I missed?有谁知道我错过了什么?

Since GitHub Actions/Workflows uses a container for Windows that already has a version of Strawberry Perl pre-installed, it will not allow you to install any other version.由于 GitHub Actions/Workflows 使用的 Windows 容器已经预装了Strawberry Perl版本,因此它不允许您安装任何其他版本。 You cannot remove the version of Perl that's pre-installed, and removing/installing a new one via Chocolatey is also next to impossible.您无法删除预安装的 Perl 版本,并且通过 Chocolatey 删除/安装新版本也几乎是不可能的。 If you re-install the version from Chocolatey that's already on the container, it seems to allow this, but it's basically a NOOP for you as a test setup.如果您从 Chocolatey 重新安装容器上已经存在的版本,它似乎允许这样做,但作为测试设置,这对您来说基本上是一个NOOP

The container also has MinGW installed;该容器还安装了 MinGW; this can be bad for us as well.这也可能对我们不利。 Having MinGW installed separately prevents XS modules from building (whether they be a dependency or if your own module is an XS module).单独安装 MinGW 会阻止构建 XS 模块(无论它们是依赖项还是您自己的模块是 XS 模块)。 Granted, this only happens if MinGW appears in the PATH ahead of your Perl install, but when you remove one Perl and add another, you're going to hit this problem.当然,只有在安装 Perl 之前 MinGW 出现在PATH中时才会发生这种情况,但是当您删除一个 Perl 并添加另一个 Perl 时,您将遇到这个问题。

To get around this, the best course of action is to remove the currently installed version of Perl from the PATH environment variable, along with their currently installed version of MinGW.为了解决这个问题,最好的做法是从PATH环境变量中删除当前安装的 Perl 版本,以及他们当前安装的 MinGW 版本。 Once both are safely out of the PATH, you can install a Portable[1] Strawberry Perl , put that Perl's paths in your PATH and begin testing with a fresh install of Strawberry Perl.一旦两者都安全地脱离 PATH,您可以安装 Portable[1] Strawberry Perl ,将该 Perl 的路径放入您的PATH并开始使用全新安装的 Strawberry Perl 进行测试。 GitHub recently broke our ability to do this directly in an Action YAML file. GitHub 最近打破了我们直接在 Action YAML 文件中执行此操作的能力。

That all sounds like a big headache, but it's really not.这一切听起来让人头疼,但事实并非如此。 There's an Action available to us for this very purpose: actions-setup-perl .为此目的,我们可以使用一个 Action: actions-setup-perl With this action you can easily test using any version of Perl you like.通过此操作,您可以轻松地使用您喜欢的任何版本的 Perl 进行测试。 So, if you're hearing someone report a bug on Perl v5.26 on Windows, you can now add that to your matrix and test easily without the need for any back-and-forth from the user:因此,如果您听到有人报告 Windows 上 Perl v5.26 的错误,您现在可以将其添加到您的矩阵中并轻松测试,而无需用户来回进行任何来回操作:

name: windows
on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:
jobs:
  perl:
    runs-on: windows-latest
    strategy:
      fail-fast: true
      matrix:
        perl-version:
          - '5.30'
          # - '5.28'
          # - '5.26'
          # - '5.24'
          # - '5.22'
          # - '5.20'
          # - '5.18'
          # - '5.16'
          - '5.14'
    steps:
      - name: Setup perl
        uses: shogo82148/actions-setup-perl@v1
        with:
          perl-version: ${{ matrix.perl-version }}
          distribution: strawberry
      - name: Set git to use LF
        run: |
          git config --global core.autocrlf false
          git config --global core.eol lf
      - uses: actions/checkout@v2
      - name: perl -V
        run: perl -V
      - name: Ensure we have a working toolchain
        run: cpanm ExtUtils::Manifest App::cpanminus
      - name: Install Dependencies
        run: cpanm -n --installdeps .
      - name: Run Tests
        run: cpanm --test-only -v .

[1] Portable versions of Strawberry Perl are zipped up, already compiled versions of Perl that do not require you to run an installer on Windows. [1] Strawberry Perl 的便携版本已压缩,已经编译的 Perl 版本不需要您在 Windows 上运行安装程序。 This means that no heightened privileges are required, etc. You just unzip the archive in the directory you want to run Perl from, then add the relevant paths to Perl in your $env:PATH variable.这意味着不需要更高的权限等。您只需将存档解压缩到要从中运行 Perl 的目录中,然后在$env:PATH变量中添加到 Perl 的相关路径。 It takes away any annoyances of build irregularities, etc. I've found it to be the most sane way to test on Windows.它消除了构建不规则等的任何烦恼。我发现它是在 Windows 上测试的最明智的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 使用 Github 测试 Windows 上的操作 - Python testing with Github Actions on Windows GitHub Actions 将更改推送到 Windows 上的远程/源 - GitHub Actions push changes to remote/origin on windows Windows 是否可以对 Elixir 进行 Github 操作? - Is it possible to have Github Actions for Elixir with Windows? 如何在 Windows 版本的 GitHub 操作上设置 Bakeware env vars? - How to set Bakeware env vars on GitHub Actions for a Windows release? 如何在 Github 操作上执行 MSI 文件(Windows 最新运行程序) - How to execute MSI file on Github Actions (windows-latest runner) Hashlib 通过 GitHub 动作对 Ubuntu 和 Windows 产生不同的结果 - Hashlib produces different results on Ubuntu and Windows via GitHub actions 为什么perl测试dir -d“”在Windows上返回true? 是不是有错误? - why perl testing dir -d “ ” on windows returns true? bug or not? 使用Perl在Windows系统上测试许多压缩文件的有效性 - Testing the validity of many gzipped files on a Windows system using Perl 如何在 Windows 的 GitHub Actions 中拥有两个 Windows 驱动器“C:”和“D:”? - How can I have two windows drives `C:` and `D:` within GitHub Actions in windows? 如何在 Windows 最新 VM 中为 Xamarin 应用程序设置 Github 操作? - How to set-up Github Actions for Xamarin apps in windows-latest VM?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM