Github Actions:跳过作业“等待挂起的作业”

问题描述 投票:0回答:1

最近 github actions 工作流程开始表现得很奇怪。

我有这个工作流程:

enter image description here

odoo
作业应该运行,但它只是被跳过,即使它说它正在等待待处理的作业。

有趣的是,如果我重新运行工作流程(从 github UI),它就会正确触发预期的作业并且工作流程正确完成。

此特定运行是在标签推送时触发的。工作流程如下所示:

---
# Build + Test + Deploy
name: BTD
on:
  push:

jobs:
  # This is only relevant if this workflow was triggered by tag push.
  prev_git_tag_info:
    runs-on: [self-hosted, pool]
    outputs:
      tag: ${{ steps.tag-info.outputs.tag }}
      rel_tag: ${{ steps.tag-info.outputs.rel_tag }}
      explanation: ${{ steps.tag-info.outputs.explanation }}
    steps:
      - name: Checkout monodoo
        uses: actions/checkout@v4
        with:
          # NOTE. This is needed for listdir, to make sure all related
          # commits between branches are found!
          fetch-depth: 0
      - name: get previous tag info
        id: tag-info
        uses: ./.github/actions/git_rel_tag
        with:
          tag: ${{ github.ref_name }}
          # Previous tag is one position to the right relative to provided tag.
          pos: "1"

  versions:
    runs-on: [self-hosted, pool]
    needs: [prev_git_tag_info]
    outputs:
      names_comma: ${{ steps.versions-getter.outputs.names_comma }}
      names_json: ${{ steps.versions-getter.outputs.names_json }}
    steps:
      - name: Checkout monodoo
        uses: actions/checkout@v4
        with:
          # NOTE. This is needed for listdir, to make sure all related
          # commits between branches are found!
          fetch-depth: 0
      - name: List Versions
        id: versions-getter
        uses: ./.github/actions/listdir
        with:
          paths: src/versions
          # There is one exception, where we include all paths, even if they
          # are not changed. Its when we have single tag that was just pushed.
          # This tag is not comparable with other tags, so we won't know what
          # changed. Thus we include all changes.
          only_changed: ${{ needs.prev_git_tag_info.outputs.explanation != 'single' }}
          dependency_paths: src/common
          # NOTE. These will only be truthy if tag was pushed.
          force_before_ref: ${{ needs.prev_git_tag_info.outputs.rel_tag }}
          force_after_ref: ${{ needs.prev_git_tag_info.outputs.tag }}

  odoo:  # This is job that started being skipped for unknown reason
    needs: [versions]
    if: ${{ needs.versions.outputs.names_comma != '' }}
    strategy:
      fail-fast: false
      matrix:
        version: "${{ fromJSON( needs.versions.outputs.names_json ) }}"
    uses: ./.github/workflows/_odoo.yml
    with:
      version: ${{ matrix.version }}
    secrets: inherit # pragma: allowlist secret

  # This is a dummy job, to just wait for all tests to pass. This way
  # we can specify single required status check instead of needing to
  # specify all projects (which is kind of dynamic).
  test_aggregate_success:
    runs-on: [self-hosted, pool]
    needs: odoo
    steps:
      - name: Pass
        run: echo "Tests Passed"
  test_aggregate_fail:
    runs-on: [self-hosted, pool]
    needs: odoo
    if: |
      always() &&
      contains(needs.*.result, 'failure') ||
      contains(needs.*.result, 'cancelled')
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            core.setFailed('Previous jobs failed or were cancelled. Forcing failure')

  tag_release:
    runs-on: [self-hosted, pool]
    needs: [prev_git_tag_info, versions, test_aggregate_success]
    # v1 tag is major tag aliasing latest semver tag.
    if: |
      startsWith(github.ref, 'refs/tags') &&
      needs.versions.outputs.names_comma != '' &&
      github.ref != 'refs/tags/v1'
    strategy:
      matrix:
        version: "${{ fromJSON( needs.versions.outputs.names_json ) }}"
    steps:
      - name: Checkout monodoo
        uses: actions/checkout@v4
        with:
          # To see all git tags.
          fetch-depth: 0
      - name: Get projects to tag
        id: projects
        uses: ./.github/actions/project_names
        with:
          version: ${{ matrix.version }}
          only_changed: ${{ needs.prev_git_tag_info.outputs.explanation != 'single' }}
          force_before_ref: ${{ needs.prev_git_tag_info.outputs.rel_tag }}
          force_after_ref: ${{ needs.prev_git_tag_info.outputs.tag }}
      - name: Get tag version
        if: steps.projects.outputs.names_comma != ''
        id: tag_version
        uses: ./.github/actions/format_version
        with:
          # We must provide version as prefix, because with multiple odoo
          # versions and same project name, we need to distinguish release
          # Docker tags from each other.
          major: ${{ matrix.version }}
          # ref_name here is git tag
          tag: ${{ github.ref_name }}
      - name: print version
        run: echo "${{ steps.tag_version.outputs.version }}"
      - name: Tag release
        if: steps.projects.outputs.names_comma != ''
        uses: ./.github/actions/tagit_ref
        with:
          version: ${{ matrix.version }}
          projects: ${{ steps.projects.outputs.names_comma }}
          dest_tags:
            ${{ steps.tag_version.outputs.version }},${{ matrix.version }}-stable
          DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }}
          DOCKER_REPO_ROOT: ${{ vars.DOCKER_REPO_ROOT }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  deploy_prod:
    needs: tag_release
    concurrency: deploying_to_prod-16-demo
    if: |
      always() &&
      startsWith(github.ref, 'refs/tags') &&
      github.ref != 'refs/tags/v1' &&
      !contains(needs.*.result, 'failure') &&
      !contains(needs.*.result, 'cancelled')
    uses: ./.github/workflows/_playbook.yml
    with:
      name: deploy-prod.yml
      # Deploying to demo environment to see if deployment would not
      # fail before deploying to real production environment
      target: prod-16-demo
    secrets: inherit # pragma: allowlist secret
github-actions jobs
1个回答
0
投票

随着标签数量的增加,你的 json ‘named_json’ 是否包含所有标签?您可能没有足够的跑步者用于“odoo”矩阵。

© www.soinside.com 2019 - 2024. All rights reserved.