我有一个包,它是我组织内多个其他包的核心依赖项。我的目标是编写一个操作来自动化/促进这些反向依赖项的测试。粗略地说,该行动应该:
\n步骤 1 和 3 我开始工作,但我\xe2\x80\x99m 遇到了步骤 2 的问题。我当前的解决方案是对所有作业输出进行硬编码,以将结果从步骤 2 传递到步骤 3,但我想知道如果有办法避免硬编码。
\n以下示例工作流程说明了我的问题:
\nname: Test\non: push\n\njobs:\n unit-tests:\n runs-on: ${{ matrix.os }}\n continue-on-error: true\n\n name: ${{ matrix.os }} (${{ matrix.pkg }})\n\n strategy:\n fail-fast: false\n matrix:\n # there will be more pkgs and OSes\n os: [ubuntu-latest]\n pkg: [pkgA, pkgB]\n\n # how to avoid hardcoding these?\n outputs:\n ubuntu-latest-pkgA: ${{ steps.update-output.outputs.ubuntu-latest-pkgA }}\n ubuntu-latest-pkgB: ${{ steps.update-output.outputs.ubuntu-latest-pkgB }} \n \n steps:\n - uses: actions/checkout@v2\n \n - name: fake unit tests\n run: |\n exit 1 # fail all tests for now\n shell: bash\n\n - name: set error if tests fail\n id: update-output\n if: ${{ failure() }}\n run: echo "::set-output name=${{ matrix.os }}-${{ matrix.pkg }}::error"\n shell: bash\n\n aggregate-results:\n runs-on: ubuntu-latest\n needs: unit-tests\n steps:\n - name: Aggregate results\n env:\n NEEDS: ${{ toJSON(needs) }}\n run: echo "$NEEDS"\nRun Code Online (Sandbox Code Playgroud)\n这项工作aggregate-results(受这篇文章的启发)运行良好并打印:
{\n "unit-tests": {\n "result": "success",\n "outputs": {\n "ubuntu-latest-pkgA": "error",\n "ubuntu-latest-pkgB": "error"\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n我可以用它来创建内容丰富的评论。然而,这项工作要求我对和unit-tests的所有组合的输出进行硬编码。有没有办法动态地做到这一点?ospkg
小智 2
我也在寻找这个解决方案。实现这一方法的唯一方法是切换到可重用的工作流程,该工作流程允许访问一个特定的工作上下文
https://docs.github.com/en/actions/learn-github-actions/contexts#jobs-context
| 归档时间: |
|
| 查看次数: |
7894 次 |
| 最近记录: |