python-template icon indicating copy to clipboard operation
python-template copied to clipboard

Limit number of CI jobs run

Open sverhoeven opened this issue 3 years ago • 2 comments

At

  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/.github/workflows/tests.yml#L4-L6
  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/.github/workflows/markdown-link-check.yml#L3
  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/%7B%7Bcookiecutter.project_name%7D%7D/.github/workflows/build.yml#L3
  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/%7B%7Bcookiecutter.project_name%7D%7D/.github/workflows/cffconvert.yml#L3
  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/%7B%7Bcookiecutter.project_name%7D%7D/.github/workflows/lint.yml#L3
  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/%7B%7Bcookiecutter.project_name%7D%7D/.github/workflows/markdown-link-check.yml#L3
  • https://github.com/NLeSC/python-template/blob/ce276a6a6ef4d893f2766c08d0df2a608858dc7f/%7B%7Bcookiecutter.project_name%7D%7D/.github/workflows/sonarcloud.yml#L3-L6

2 jobs are triggered when a push is done to a pull request, because the on:push and on:pull_request:types=syncronize both get triggered on a push.

To not to double work we should change to on: section of most GHA workflows.

Option 1:

on:
  push:
    branches: [main]
  pull_request:
    types: [opened, synchronize, reopened]

Con: No job triggered when pushed to feature branch without PR

Option 2:

on:
  push:
  pull_request:
    types: [opened, reopened]

There might be other options, but I like minimalism of option 2 and clarity of option 1.

sverhoeven avatar Apr 28 '21 07:04 sverhoeven

Maybe we can also cancel jobs of previous commits in the PR. @fdiblen do you know if this is possible?

sverhoeven avatar Apr 29 '21 12:04 sverhoeven

Previous jobs can be canceled with https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency , though this feature is in beta

sverhoeven avatar May 03 '21 06:05 sverhoeven

This has been fixed in c2ee7dc6a269b34ea678a552b7b215a229d57f1e and e22b7cfde3719f98b9ab95be43d30f4ce8ce00f6.

egpbos avatar Jul 11 '23 15:07 egpbos