awalsh128 / cache-apt-pkgs-action

Cache APT packages in GitHub Actions
Other
205 stars 35 forks source link

Optimize initial APT install with `apt-fast`. #26

Closed awalsh128 closed 2 years ago

awalsh128 commented 2 years ago

As mentioned in another issue, installs can be drastically sped up using apt-fast. It would be nice to introduce some of these efficiencies into the action as well.

awalsh128 commented 2 years ago

To install as documented from the GitHub site:

sudo add-apt-repository ppa:apt-fast/stable
sudo apt-get update
sudo apt-get -y install apt-fast

Unattended install can be done with DEBIAN_FRONTEND=noninteractive apt-get install -y apt-fast.

Timed the install of apt-fast itself and it takes about 5 seconds.

time DEBIAN_FRONTEND=noninteractive sudo apt-get install -y apt-fast
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  aptitude zsh fish
The following NEW packages will be installed:
  apt-fast
0 upgraded, 1 newly installed, 0 to remove and 274 not upgraded.
Need to get 0 B/35.8 kB of archives.
After this operation, 128 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package apt-fast.
(Reading database ... 118995 files and directories currently installed.)
Preparing to unpack .../apt-fast_1.9.12-1~ubuntu20.04.1_all.deb ...
Unpacking apt-fast (1.9.12-1~ubuntu20.04.1) ...
Setting up apt-fast (1.9.12-1~ubuntu20.04.1) ...
Processing triggers for man-db (2.9.1-1) ...

real    0m5.064s
user    0m4.240s
sys     0m0.761s

Although the quick install takes less than a second /bin/bash -c "$(curl -sL https://git.io/vokNn)".

pablgonz commented 2 years ago

According to (https://github.com/actions/virtual-environments), apt-fast is available by default in all distributions.

I believe that the speed, especially when using cache is considerably increased by using:

apt-fast -y install --no-install-recommends

By default apt installs the recommendations, but they are not necessary (in most cases) and if they are the user should make them explicit (in my humble opinion).

awalsh128 commented 2 years ago

Perfect, thanks @pablgonz. I should be able to implement this by end of next week.

pablgonz commented 2 years ago

Jeje...Any reason not to upgrade to actions/cache@v3?

awalsh128 commented 2 years ago

None at all. Updated in staging and master.

awalsh128 commented 2 years ago

Feature now in master. Will put this into the v1.1.0 release.