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

Skip duplicated Github actions run #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dolfinus
Copy link
Contributor

@dolfinus dolfinus commented Mar 20, 2021

Hello.

There is an annoying fact about Github Actions - sometimes it runs actions twice. For example:

  1. You just pushed a commit to a branch - testing workflow will run only once
  2. Someone forked your repo and creates a pull request - same thing
  3. You've created a new branch (feature, bugfix or release branch), pushed a commit here and also created a pull request to the main branch - two copies of workflow will be run

Running a workflow twice does not make any sense, it just takes twice the time without any useful side effect.

In this PR I've added a separated job of checking if another copy of workflow already started: https://github.com/fkirc/skip-duplicate-actions

This job allows to:

  1. Skip the second copy of workflow in the case 3 (branch in original repo + PR to main branch). Cases 1 and 2 will work just the same as now
  2. Skip workflow if someone changed only files which are not connected to package code, like README or CHANGELOG
  3. Cancel already started workflow in the same PR or branch if someone pushed new commits to it.

Also I've found another quite annoying bug - step actions/cache does not update cache item if it was restored using a primary key.
For example, some dependencies like dialyzer or other ones store their files in deps or _build folders (which are cached in the workflow). But when these dependencies perform some updates of these folders, it does not lead to the updating of mix.lock file. File hasn't been changed -> hash is the same -> cache primary key is the same -> caching action will not update the existing cache.
This will cause the increase of workflow run time because the stored cache will not be used by some steps. Until mix.lock will be updated which will lead to updating the cache item.
Here I've appended a commit SHA to the cache primary key, so it will always be updated. But it will not affect cache reading.

What do you think about that?

@dolfinus dolfinus force-pushed the skip_duplicated_runs branch from 001b3c7 to 95143b0 Compare March 20, 2021 20:53
@dolfinus dolfinus changed the title Skip duplicated runs Skip duplicates Github actions run Mar 20, 2021
@dolfinus dolfinus changed the title Skip duplicates Github actions run Skip duplicated Github actions run Mar 20, 2021
@dolfinus dolfinus force-pushed the skip_duplicated_runs branch 5 times, most recently from 4790cd3 to 054ef42 Compare March 22, 2021 22:20
@dolfinus dolfinus force-pushed the skip_duplicated_runs branch from 054ef42 to cf74a78 Compare March 23, 2021 15:06
@dolfinus dolfinus mentioned this pull request Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant