【问题标题】:Github action not uploading artifactGithub 操作未上传工件
【发布时间】:2020-02-02 05:10:51
【问题描述】:

我在从工作流中将工件上传到 github 时遇到问题。

这是我的 yaml 文件:


on:
  push:
      branches:
      - master

jobs:
    build:
      name: build and test
      runs-on: ubuntu-latest

      steps:
        - uses: actions/checkout@v1
        - name: Install robotframework and dependencies
          run: |
            pip install selenium
            pip install robotframework
            pip install robotframework-seleniumlibrary
            pip install robotframework-imaplibrary
            pip install robotframework-httplibrary
            pip install robotframework-requests
        - name: Download and install chromedriver
          run: |
            wget http://chromedriver.storage.googleapis.com/77.0.3865.10/chromedriver_linux64.zip
            sudo unzip chromedriver_linux64.zip -d /usr/local/bin
            export CHROME_BIN=chromium-browser
        - name: Run robot tests
          run: |
            cd robot/tests
            python -m robot -i ready bookingform.robot
        - name: publish test results
          uses: actions/upload-artifact@v1
          with:
            name: report
            path: report.html
        - name: clean up stuff
          run: |
            history
            pwd

在“发布测试结果”之前一切正常,此时没有任何内容写入日志,也没有上传任何工件。如果我查看工作流日志,该步骤旁边有一个灰色图标(不是通常的检查或红色 x),所以我真的对可能发生的事情感到困惑。我在“清理内容”步骤中添加了任意内容,只是为了测试会发生什么,但该步骤也没有运行。

我试过弄乱路径,认为它可能与路径无效或其他什么有关,但这并没有帮助。无论我在该文件底部附近添加什么,都会发生相同的行为。

我尝试运行另一个上传工件并且运行良好的工作流文件,日志显示上传操作已被调用并且工件已保存,但是当我使用我的 yaml 文件时,我看不到任何类似的东西。

【问题讨论】:

  • 当我在上传工件时遇到问题时,我使用ls -la 打印目录内容。也许在Run robot tests 步骤中尝试一下,以确保您使用的是正确的目录结构?
  • 请记住,在每个步骤中,您都会被放回根工作流目录;在发布步骤期间,您不再在 robot/tests/ 中。
  • 谢谢@Samira,这给了我一些指示。我还意识到了其他事情;如果出现故障,则会跳过步骤,因此我在相关步骤中添加了 if: always(),这似乎可以解决问题。

标签: workflow artifacts github-actions


【解决方案1】:

每个作业步骤都会将工作路径重置为GITHUB_WORKSPACE,这将是actions/checkout 运行后存储库的根目录。

upload-artifact 操作很可能找不到 report.html,因为它不再位于正确的目录中。

尝试如下更改路径:

        - name: publish test results
          uses: actions/upload-artifact@v1
          with:
            name: report
            path: robot/tests/report.html

还有一个working-directory 可以设置为一个步骤。但是,它似乎与uses 的操作不兼容。它只能应用于run 脚本步骤。

working-directoryuses 一起使用不会工作:

        - name: publish test results
          working-directory: robot/tests
          uses: actions/upload-artifact@v1
          with:
            name: report
            path: report.html

working-directoryrun 一起使用工作:

        - name: print test results
          working-directory: robot/tests
          run: cat report.html

【讨论】:

    猜你喜欢
    • 2021-09-01
    • 2020-11-04
    • 2023-02-14
    • 2020-05-05
    • 2020-11-17
    • 2021-12-18
    • 2019-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多