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

in_progress count check is zero breaks the actionflow #28

Closed
zhouzhuojie opened this issue Aug 5, 2021 · 5 comments
Closed

in_progress count check is zero breaks the actionflow #28

zhouzhuojie opened this issue Aug 5, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@zhouzhuojie
Copy link

Description

Used to have this step from the default template setup, and in_progress suddenly reports 0 a few days ago (without any code changes), and the filename actionsflow.yml stays the same. This breaks the following steps' if conditions.

    steps:
      - name: Check is running
        uses: actions/github-script@v4
        id: runningCount
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            const runed = await github.actions.listWorkflowRuns({
              owner: context.repo.owner,
              repo: context.repo.repo,
              workflow_id: "actionsflow.yml",
              status:"in_progress"
            });
            console.log(runed.data.total_count);
            return runed.data.total_count;
          result-encoding: string
Run actions/github-script@v4
  with:
    github-token: ***
    script: const runed = await github.actions.listWorkflowRuns({
    owner: context.repo.owner,
    repo: context.repo.repo,
    workflow_id: "actionsflow.yml",
    status:"in_progress"
  });
  console.log(runed.data.total_count);
  return runed.data.total_count;
  
    result-encoding: string
    debug: false
    user-agent: actions/github-script
0

Steps to reproduce

Steps mentioned above.

Possible solution

One possible solution: instead of checking the count of "in_progress", which might be unreliable due to how github defines it, a github action native feature concurrency may be helpful here:

concurrency:
  group: actionsflow
  cancel-in-progress: true
@zhouzhuojie zhouzhuojie added the bug Something isn't working label Aug 5, 2021
@theowenyoung
Copy link
Member

Thanks report, same problem happened in my workflow, I suppose that's a github api issue, but there is also a quick fix way, I'll change the default workflow later.

@theowenyoung
Copy link
Member

@zhouzhuojie
Copy link
Author

Thanks report, same problem happened in my workflow, I suppose that's a github api issue, but there is also a quick fix way, I'll change the default workflow later.

Yes, I think that may work (sorry didn't try yet), and it definitely depends on github's pagination and its implicit ordering, and it might not be efficient to query all the runs as it may return a list of all the previous workflows before.

I fixed mine with concurrency like:


concurrency: 
  group: actionsflow

jobs:
  run:
    runs-on: ubuntu-latest
    name: Run
    steps:
      - uses: actions/checkout@v2
      - name: Run Actionsflow
        uses: actionsflow/actionsflow-action@v1
        with:
          args: "build --include ${{ github.event.inputs.include || ''}} -f ${{github.event.inputs.force=='true' && 'true' || 'false'}} --verbose ${{github.event.inputs.verbose=='true' && 'true' || 'false'}}"
          json-secrets: ${{ toJSON(secrets) }}
          json-github: ${{ toJSON(github) }}
      - name: Setup act
        uses: actionsflow/setup-act-for-actionsflow@v1
      - name: Run act
        run: act --workflows ./dist/workflows --secret-file ./dist/.secrets --eventpath ./dist/event.json --env-file ./dist/.env -P ubuntu-latest=actionsflow/act-environment:v1 -P ubuntu-18.04=actionsflow/act-environment:v1

cancel-in-progress: true is optional if we just want the new run to be pending.

@theowenyoung
Copy link
Member

@zhouzhuojie Thanks the information! I don't know this concurrency config option before, and yes, it's a perfect way to solve concurrency problem, I'll use it as the default solution!

Thanks again!

@theowenyoung
Copy link
Member

Done. close #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants