I've got a workflow that has some setup steps that install php with a bunch of extensions & composer.
Is it possible to cache the Install PHP and Install Composer & Dependencies so these steps don't have to happen on every run?
These steps combined take about 4 mins of a 5 min run.
name: Build
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
with:
path: ./src
- name: Install PHP
run: |
sudo apt-get update -y && export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
echo "tzdata tzdata/Areas select Europe" >> /tmp/preseed.cfg
echo "tzdata tzdata/Zones/Europe select Berlin" >> /tmp/preseed.cfg
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php8.1 -y --quiet
sudo apt-get install php8.1-dev libmcrypt-dev php-pear php-xml php8.1-xml -y
sudo pecl channel-update pecl.php.net
sudo apt-get install -y libapache2-mod-php8.1 php8.1-common php8.1-gmp php8.1-curl php8.1-soap php8.1-bcmath php8.1-intl php8.1-mbstring php8.1-xmlrpc php8.1-mysql php8.1-gd php8.1-xml php8.1-cli php8.1-zip
sudo rm /usr/bin/php; sudo ln -sf /usr/bin/php8.1 /usr/bin/php
- name: Install Composer & Dependencies
run: |
cd ./src/ || exit 99
sudo apt-get install -y git zip libzip-dev openssh-client libmcrypt-dev
sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
cp auth.json.pipeline auth.json
sudo composer self-update --2
composer install --no-dev --verbose --prefer-dist --no-ansi --no-interaction
I would recommend using Setup PHP and Install PHP Dependencies with Composer GitHub Actions instead of manually installing PHP and Composer with dependencies.
These actions already have a caching mechanism and provide many interesting and valuable things additionally.
For example:
name: PHP
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v3
- uses: 'shivammathur/setup-php#v2'
name: Setup PHP
with:
php-version: '8.1'
- uses: 'ramsey/composer-install#v2'
name: Install Composer & Dependencies
- name: Run Script
run: |
php -v
composer -v
Running this WF on my little test PHP project with few dependencies takes about 30s without cache and 20s when cache exists.
Execution demo: Screenshot.
Cache demo: Screenshot.
In addition, there is a Cache GitHub action that can be used if you need manually cache some things for your workflow.
Learn more about managing caches.
Related
I tried adding the following to the github steps in the yaml file from https://github.com/actions/virtual-environments/issues/1307#issuecomment-664989873
steps:
- name: Install openssl&libssl-dev
run: |
sudo apt-get install -y --allow-downgrades openssl=1.0.2g-1ubuntu4.16 libssl-dev=1.0.2g-1ubuntu4.16
- name: Display openssl&libssl-dev versions
run: dpkg -l openssl libssl-dev | grep '^ii' | cut -c5-
But received error Version '1.0.2g-1ubuntu4.16' for 'openssl' was not found
How do I figure out what "old versions" of openssl I can install in at least ubuntu 18.04 for github actions?
I'm trying to add TravisCI to my project, but I won't stop getting this error when triggering the builds:
WARNING: The following packages cannot be authenticated!
google-chrome-stable E: There were unauthenticated packages and -y was
used without --allow-unauthenticated apt-get.diagnostics apt-get
install failed The command "sudo -E apt-get -yq --no-install-suggests
--no-install-recommends $(travis_apt_get_options) install google-chrome-stable" failed and exited with 100 during .
I've searched for an answer and I found that adding chrome: stable in the addons section should fix it, but it's still failing. This is the .travis.yml file:
dist: trusty
sudo: false
language: node_js
node_js:
- "10"
addons:
chrome: stable
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
cache:
directories:
- ./node_modules
install:
- cd project/projectName
- npm install
script:
- npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
- npm run e2e -- --protractor-config=e2e/protractor-ci.conf.js
And this is the full log:
Worker information
0.17s0.01s0.00s0.01s
system_info
Build system information
0.00s0.00s6.03s0.00s4.23s0.00s1.26s
docker_mtu_and_registry_mirrors
docker stop/waiting
resolvconf
resolvconf stop/waiting
Adding APT Sources
0.16s$ curl -sSL "https://build.travis-ci.com/files/gpg/google-chrome.asc" | sudo -E apt-key add -
OK
0.01s$ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a ${TRAVIS_ROOT}/etc/apt/sources.list >/dev/null
7.82s$ travis_apt_get_update
Installing APT Packages
0.50s$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install google-chrome-stable
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
indicator-application libappindicator1 libappindicator3-1 libdbusmenu-glib4
libdbusmenu-gtk3-4 libdbusmenu-gtk4 libindicator3-7 libindicator7
Use 'sudo apt autoremove' to remove them.
Recommended packages:
libu2f-udev libvulkan1
The following packages will be upgraded:
google-chrome-stable
1 upgraded, 0 newly installed, 0 to remove and 303 not upgraded.
Need to get 75.8 MB of archives.
After this operation, 59.1 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
google-chrome-stable
E: There were unauthenticated packages and -y was used without --allow-unauthenticated
apt-get.diagnostics
apt-get install failed
The command "sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install google-chrome-stable" failed and exited with 100 during .
Your build has been stopped.
How could I fix this? Also, since the root folder (where the .travis.yml file is) isn't where the app is located (it is under root/project/projectName), I wrote - cd project/projectName before doing the -npm install, I don't know if thats the correct way of doing it, so I'd also like to check that.
Thanks!
I am currently trying to implement a workflow which requires protobuf to be installed. However, on Ubuntu I have to compile this myself. The problem is that this takes quite some time to do so I figured caching this step is the thing to do.
However, I am not sure how I can use actions/cache for this, if at all possible.
The following is how I am installing protobuf and my Python dependencies:
name: Service
on:
push:
branches: [develop, master]
jobs:
test:
runs-on: ubuntu-18.04
steps:
- name: Install protobuf-3.6.1
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-all-3.6.1.tar.gz
tar -xvf protobuf-all-3.6.1.tar.gz
cd protobuf-3.6.1
./configure
make
make check
sudo make install
sudo ldconfig
- uses: actions/checkout#v2
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
How can I cache these run steps s.t. they don't have to run each time?
I tested the following:
name: Service
on:
push:
branches: [develop, master]
jobs:
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout#v2
- name: Load from cache
id: protobuf
uses: actions/cache#v1
with:
path: protobuf-3.6.1
key: protobuf3
- name: Compile protobuf-3.6.1
if: steps.protobuf.outputs.cache-hit != 'true'
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-all-3.6.1.tar.gz
tar -xvf protobuf-all-3.6.1.tar.gz
cd protobuf-3.6.1
./configure
make
make check
- name: Install protobuf
run: |
cd protobuf-3.6.1
sudo make install
sudo ldconfig
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
I would also delete all the source files once it's built.
I've got a problem running polymer test on gitlab CI shared runner. I got stuck in Selenium error: no such session when running chromedriver. It didn't appear on running firefox. How can I run polymer test in gitlab CI using xvfb-run -a polymer test to run in chrome browser?
This is my .gitlab-ci.yml file:
image: node:6.9.5
before_script:
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
- echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/java-8-debian.list
- echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/java-8-debian.list
- apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
- echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
- apt-get update -yqqq
- apt-get install -y oracle-java8-installer
- apt-get install -y google-chrome-stable
- apt-get install -y iceweasel
- apt-get install -y xvfb
- npm install -g bower
- npm install -g polymer-cli
- bower install --allow-root
stages:
- build
- test
- deploy
testing:
stage: test
script:
- xvfb-run -a polymer test
only:
- develop
tags:
- docker
This is the error report:
http://pastebin.com/wsVMLc83
Thank you.
I am trying to setup a project with Travis CI. Project also uses pygame. I had multiple attempts to set it up - but it seem to be failing.
The closest I got was following:
.travis.yml:
language: python
python:
- "2.7"
install:
- pip install -r requirements.txt
before_install:
- sudo apt-get update
- sudo apt-get build-dep python-pygame
- sudo apt-get install mercurial
script:
- nosetests tests/*.py
requirements.txt:
Twisted==13.2.0
coverage==3.7.1
nose==1.3.0
hg+http://bitbucket.org/pygame/pygame
wsgiref==0.1.2
zope.interface==4.1.0
Travis CI downloads the pygame package, but the installation hangs:
https://travis-ci.org/ruslanosipov/space/builds/19142164#L390
Any hint?
Solution was as follows:
Create separate .travis_requirements.txt without the pygame.
Change .travis.yml as follows:
language: python
python:
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get build-dep -qq python-pygame
- sudo apt-get install -qq python-pygame
install:
- pip install -r .travis_requirements.txt
script:
- nosetests tests/*.py
virtualenv:
system_site_packages: true
Main change is using "system_site_packages" setting and installing pygame via apt-get.