Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rerunning all jobs no longer respects what needs what #27884

Closed
gilesb2 opened this issue Nov 2, 2023 · 4 comments · Fixed by #29955
Closed

rerunning all jobs no longer respects what needs what #27884

gilesb2 opened this issue Nov 2, 2023 · 4 comments · Fixed by #29955
Labels
topic/gitea-actions related to the actions of Gitea type/bug
Milestone

Comments

@gilesb2
Copy link

gilesb2 commented Nov 2, 2023

Description

when I re run all jobs in a workflow (from the ui) after one has failed the structure of what needs what is not respected - ie they all run at once.

The original run respects structure.

my workflow is as below fwiw

name: target
on:
  pull_request:

jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - uses: RouxAntoine/checkout@v3.5.4
        with:
          fetch-depth: '1'
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - uses: sigyl-actions/gitea-issue-comment@main
        with:
          token: ${{ secrets.BOT_TOKEN }}
          id: ${{ github.event.number }}
          description: 'formatting'
          body: |
            formatting xml code
  format:
    runs-on: ubuntu-latest
    needs: comment
    steps:
      - uses: RouxAntoine/checkout@v3.5.4
        with:
          token: ${{ secrets.BOT_TOKEN }}
          # fetch-depth: '1'
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - run: git checkout -b ${{ github.head_ref }}
      - uses: sigyl-actions/xml-format@debug
        with:
          folder: '.'
          regex: ^.+\.(([aA][xX][mM][lL]))$
      - run: git status
      - uses: sigyl-actions/xml-format@debug
        with:
          folder: './recipes'
          regex: ^.+\.(([oO][xX][mM][lL])|([uU][xX][mM][lL])|([pP][xX][mM][lL]))$
      - run: git status
      - uses: sigyl-actions/check-for-changes@v1.0.0
        id: has-changes
      - run: git status
      - uses: ./.github/actions/git-prep
        if: steps.has-changes.outputs.changes == 'true'
      - run: git status
      - name: commit if changed
        if: steps.has-changes.outputs.changes == 'true'
        run: |
          git add -A
          git commit -a -m "formatted"
          git push origin HEAD
  schema:
    runs-on: ubuntu-latest
    needs: comment
    outputs:
      result: ${{ steps.schema.outputs.result }}
      error: ${{ steps.schema.outputs.error }}
      schema: ./.github/schemas/AreaModel.xsd
      
    steps:
      - uses: RouxAntoine/checkout@v3.5.4
        with:
          token: ${{ secrets.BOT_TOKEN }}
          fetch-depth: '1'
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - id: pwd
        run: |
          echo -n pwd= >> $GITHUB_OUTPUT
          pwd >> $GITHUB_OUTPUT
      - uses: sigyl-actions/xml-schema@main
        id: schema
        # continue-on-error: true
        with:
          schema_path: ${{ steps.pwd.outputs.pwd}}
          folder: '.'
          regex: ^.+\.(([aA][xX][mM][lL]))$
          xsd: ./.github/schemas/AreaModel.xsd
      # master recipes isn't a valid schema!
      #- uses: sigyl-actions/xml-schema@main
      #  with:
      #    schema_path: ${{ steps.pwd.outputs.pwd}}
      #    folder: './recipes'
      #    regex: ^.+\.(([oO][xX][mM][lL])|([uU][xX][mM][lL])|([pP][xX][mM][lL]))$
      #    xsd: ./.github/schemas/MasterRecipe.xsd
  schema1:
    runs-on: ubuntu-latest
    needs: comment
    steps:
      - id: fail-step
        continue-on-error: true
        run: |
          echo "oh=hahaah" >> $GITHUB_OUTPUT
          exit 1
      - run: echo ${{ steps.fail-step.outcome }}
      - name: json
        run: echo $JSON
        env:
          JSON: ${{ toJSON(steps) }}
      

  review:
    runs-on: ubuntu-latest
    needs:
      - format
      - schema
    steps:
      - name: json
        run: echo $JSON
        env:
          JSON: ${{ toJSON(needs) }}
      - uses: RouxAntoine/checkout@v3.5.4
        with:
          fetch-depth: '1'
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - run: echo ${{ needs.schema.outputs.error }}
      - uses: sigyl-actions/gitea-pr-review@main
        if: ${{ needs.schema.outputs.error != 'true' }}
        with:
          token: ${{ secrets.BOT_TOKEN }}
          id: ${{ github.event.number }}
          description: 'Schema checks pass'
          body: |
            pull changes
          event: APPROVED
      - uses: sigyl-actions/gitea-pr-review-xml-schema@main
        if: ${{ needs.schema.outputs.error == 'true' }}
        with:
          token: ${{ secrets.BOT_TOKEN }}
          id: ${{ github.event.number }}
          errors: ${{ needs.schema.outputs.result }}
          body: |
            # schema checks failed
          event: REQUEST_CHANGES

  request-review:
    needs:
      - review
      - format
      - schema
    runs-on: ubuntu-latest
    if: needs.schema.outputs.error != 'true'
    steps:
      - uses: RouxAntoine/checkout@v3.5.4
        with:
          fetch-depth: '1'
      - uses: actions/setup-node@v3
        with:
          node-version: '20'
      - uses: sigyl-actions/gitea-request-review@main
        with:
          token: ${{ secrets.BOT_TOKEN }}
          pr: ${{ github.event.number }}
          teams: reviewers,reviewers-2

Gitea Version

1.21.0-rc2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

ubuntu

How are you running Gitea?

container from docker hub on linux

Database

SQLite

@gilesbradshaw
Copy link

here is the first run

image

here is the second with re run all jobs

image

@gilesbradshaw

This comment has been minimized.

@nicorac
Copy link

nicorac commented Nov 27, 2023

Same issue here.

I've prepared a lighter workflow to reproduce the bug:

# Since the default value of act_runner "fetch_interval" parameter is
# "10s", we need to sleep each step for > 10secs...
name: Test
run-name: ${{ gitea.actor }} started this build

on:
  push:

jobs:

  job1:
    name: job1
    steps:
      - name: job1 step
        run: |
          sleep 15
          echo "job1 done!"

  job2:
    name: job2
    steps:
      - name: job2 step
        run: |
          sleep 15
          echo "job2 done!"

  job3:
    name: job3 (waits for both job1 and job2)
    needs: [ job1, job2 ]
    steps:
      - name: job3 step
        run: |
          sleep 15
          echo "job 3 done!"

@xXluki98Xx
Copy link

Bug is still present in Gitea 1.21.4

@lunny lunny added this to the 1.21.9 milestone Mar 22, 2024
@lunny lunny closed this as completed in 2f060c5 Mar 22, 2024
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Mar 22, 2024
Fix go-gitea#28761
Fix go-gitea#27884
Fix go-gitea#28093

## Changes

### Rerun all jobs
When rerun all jobs, status of the jobs with `needs` will be set to
`blocked` instead of `waiting`. Therefore, these jobs will not run until
the required jobs are completed.

### Rerun a single job
When a single job is rerun, its dependents should also be rerun, just
like GitHub does
(go-gitea#28761 (comment)).
In this case, only the specified job will be set to `waiting`, its
dependents will be set to `blocked` to wait the job.

### Show warning if every job has `needs`
If every job in a workflow has `needs`, all jobs will be blocked and no
job can be run. So I add a warning message.

<img
src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b"
width="480px" />
lunny added a commit that referenced this issue Mar 22, 2024
Backport #29955 by @Zettat123

Fix #28761
Fix #27884
Fix #28093

## Changes

### Rerun all jobs
When rerun all jobs, status of the jobs with `needs` will be set to
`blocked` instead of `waiting`. Therefore, these jobs will not run until
the required jobs are completed.

### Rerun a single job
When a single job is rerun, its dependents should also be rerun, just
like GitHub does
(#28761 (comment)).
In this case, only the specified job will be set to `waiting`, its
dependents will be set to `blocked` to wait the job.

### Show warning if every job has `needs`
If every job in a workflow has `needs`, all jobs will be blocked and no
job can be run. So I add a warning message.

<img
src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b"
width="480px" />

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
silverwind pushed a commit to silverwind/gitea that referenced this issue Mar 22, 2024
Fix go-gitea#28761
Fix go-gitea#27884
Fix go-gitea#28093

## Changes

### Rerun all jobs
When rerun all jobs, status of the jobs with `needs` will be set to
`blocked` instead of `waiting`. Therefore, these jobs will not run until
the required jobs are completed.

### Rerun a single job
When a single job is rerun, its dependents should also be rerun, just
like GitHub does
(go-gitea#28761 (comment)).
In this case, only the specified job will be set to `waiting`, its
dependents will be set to `blocked` to wait the job.

### Show warning if every job has `needs`
If every job in a workflow has `needs`, all jobs will be blocked and no
job can be run. So I add a warning message.

<img
src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b"
width="480px" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants