-
Hi all, I’m looking for some advice of how to speed Github Actions up. I have always used Circle CI to perform my CI tests as I like how it utilises layering of containers to achieve good speeds. A fast build is something I value highly. Please see this build run on Circle CI, where I merged branch ‘master’ into branch ‘github-actions’: https://circleci.com/gh/PhpGt/Dom/528 The whole build and test run took only 12 seconds to complete. It even uploaded all of the test coverage artifacts so you can view them online. Compare the same test execution when run on Github actions: https://github.com/PhpGt/Dom/actions/runs/24972497. Github Actions takes 3 minutes and 32 seconds to compelte the same task. I know I’m comparing apples to oranges here, but the difference in execution time is so significant, I’m sure I am doing something wrong. Something to note is that I break my build and test steps into different jobs. This is so that when projects become more complex and have different test runners, they can run concurrently – once the dependencies are built, PHPUnit tests can run simultaneously with the Behat and Codeception, for example (the linked project uses only PHPUnit for now). Looking into the specifics of what makes Circle CI so fast, I have found the following points:
Thanks everyone! Greg. |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments
-
In Github Actions, when you choose Github Hosted Runner to run your workflows, it provides a clean instance for every job execution without built layers nor dependencies . If the actions/cache could not reach your requirement, you could consider to use self-hosted runner, then the built layers and dependencies will be stored in your machine which installed Github Action Runner App . |
Beta Was this translation helpful? Give feedback.
-
@yanjingzhuthank you for your reply. Github strongly advise not to use self-hosted runners for open source development (https://help.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#self-hosted-runner-security-with-public-repositories). If what you say is correct, then Github Actions are not suitable for open source development. That is a shame. |
Beta Was this translation helpful? Give feedback.
-
Edit: Just realized you are the one who made that example of caching the dependencies. See comment below. Definitely look into the actions cache. You can use the actions/cache for composer’s vendor directory, using a hash of the composer.lock file as the cache key. Here is an example of a github action that shows using the cache this same way.
(from https://github.com/marketplace/actions/composer-php-actions) I don’t know if you will be able to get it down to 12 seconds like with Circle, but if most of your time is spent on dependencies it could help a lot. |
Beta Was this translation helpful? Give feedback.
-
I just saw that you are already using the cache (and are apparently the source of where the cache example is coming from). My bad. The logs from your build are gone now so I couldn’t see the breakdown of where all the time was spent. |
Beta Was this translation helpful? Give feedback.
-
Oh, sorry for missing that you are using a public repo. Yes, github actions doesn’t suggest to use self-hosted runner for public repo. Using self-hosted runner is not a good suggestion. Which step cost the most of time to run in github action? I checked your repo, in the latest build “Use Github hosted runner to isolate issue” it is the upload artifacts (all your source code) and download artifacts that cost 2 more minutes. And I checked your circle ci build again , you just upload test results and coverage report. |
Beta Was this translation helpful? Give feedback.
-
I believe GitHub will have to find a solution to docker layer caching. This seems to be the number one reason for “my build is slower on GitHub Actions” complaints. We are suffering from this greatly, but the enjoyment of using GitHub Actions eases the pain a little. I believe docker layer caching is discussed in several places, not sure which of them will get traction and attention. Perhaps join the discussion / upvote one of these places / send feedback to GitHub? Here are two: |
Beta Was this translation helpful? Give feedback.
-
@rlittlefieldI already use actions/cache to cache Composer’s vendor directory. My question is in relation to persisting files between jobs, which actions/cache does not do, as far as I can tell. |
Beta Was this translation helpful? Give feedback.
-
@yanjingzhuPlease check my Circle CI build again. I have merged the Circle CI config into the same branch, github-actions. Every single file is persisted between “build” job and “test-phpunit” job. Both jobs execute and complete within 30 seconds combined. Also, uploading “all my source code” shouldn’t take 2 minutes - where is it uploading to? Surely it’s the same box? All of my source code consists of no more than a few megabytes of text files. |
Beta Was this translation helpful? Give feedback.
-
@dannybenyou are right. Without layer caching, the product will always be slow. There is nothing we can do about it. I will contribute to the links you provided. Thanks very much for your response. |
Beta Was this translation helpful? Give feedback.
-
Upload artifacts will upload to github server side. I tried to fork your repo , I found that it is php-actions/composer action slows down the upload artifacts step, but I could not figure out why this happens. |
Beta Was this translation helpful? Give feedback.
-
I was under the impression that actions/cache could persist files between jobs, as long as you have the same cache key. Isn’t that the main idea? As far as docker layer caching, if you are doing it for your own docker builds, I’ve found an action that will run the builds for you, and will use a connection to a container registry to dump all the layers. I’m using it with google’s gcr.io, and it works fine: |
Beta Was this translation helpful? Give feedback.
I believe GitHub will have to find a solution to docker layer caching. This seems to be the number one reason for “my build is slower on GitHub Actions” complaints. We are suffering from this greatly, but the enjoyment of using GitHub Actions eases the pain a little.
I believe docker layer caching is discussed in several places, not sure which of them will get traction and attention. Perhaps join the discussion / upvote one of these places / send feedback to GitHub?
Here are two:
- actions/cache #31 - Docker caching