Travis CI does not provide Arch Linux as a testing environment but if you need to test some script or some app specifically on Arch Linux, you would have to do that manually for every change made into code and that would waste time. I had a similar problem when I was trying to test the Event Linux build scripts based on Arch Linux which required the Arch Linux environment to be able to run build scripts which take around 25 to 30 minutes to be tested for every change
How to use Arch travis script for Travis CI?
To solve the problem we need to use Arch as chroot in Travis CI. To do so we are going to use this script (link) which will deploy Arch Linux chroot on travis for us to start testing
For using it we need to configure the travis.yml like this :-
sudo: required arch: repos: - archlinuxfr=http://repo.archlinux.fr/$arch packages: # pacman packages - yaourt - archiso script: - ./build-repo - sudo ./build.sh -v script: - "travis_wait 30 sleep 1800 &" - curl -s https://raw.githubusercontent.com/fossasia/arch-travis/master/arch-travis.sh | bash
arch.packages defines a list of packages (from official repository or AUR) to be installed before running the build.
packages: # pacman packages - python - perl # aur packages - go-git # packages from custom repo - yaourt
Here in arch.repos we define custom repository required for the package which is required during testing.
For eg. in above code repo : http://repo.archlinux.fr/$arch is used to install yaourt we could have used AUR too but that will increase our build testing time as the AUR will first download the pkgbuild and then build the package which can result in increase of time
arch.script defines a list of scripts to run as part of the build. Like in above example we have used ./build-repo and sudo ./build -v
Anything defined in the arch.script list will run from the base of the repository as a normal user called travis CI . sudo is available as well as any packages installed in the setup. The path of the build dir (or repository base), is stored in the TRAVIS_BUILD_DIR environment variable inside the chroot.
At the end of example we have used
Which defines the scripts to be run by travis, this is where arch-travis was initialized and then we pipe it
Usage of travis-wait function
script: - travis_wait 30 sleep 1800 & - curl -s https://raw.githubusercontent.com/fossasia/arch-travis/master/arch-travis.sh | bash
We cannot use travis wait function inside the chroot neither we can export it so we apply the travis wait function at the point where we have initialised the Arch-travis
Example usage for pkgbuild scripts
sudo: required # this to get sudo permissions arch: # anything to be tested under Arch is defined below this script: - makepkg app.pkgbuild # this will test the pkgbuild script script: #for setting up arch chroot using the arch travis script - curl -s https://raw.githubusercontent.com/fossasia/arch-travis/master/arch-travis.sh | bash
- Increases build time by about 1-3 min.
- Does not work on travis container-based infrastructure because sudo is required.
- Limited configuration.
- Does not include base group packages.