Skip to main content

gitlab-ci and yarn

For my previous post, on gitlab-ci and codeception, I created a small project on gitlab that runs selenium webtests during gitlab-ci. The project being tested is just a small vue.js-application.

Recently I rewrote that small application; now it uses a single file vue component. I'm not completely sure what I've done, but it seems to work, and it involves webpack encore and yarn.

Running yarn from gitlab-ci

Now the challenge was to run yarn from gitlab-ci. I was looking for a docker container with yarn (even tried to build one myself), but it took me some time before I discovered that yarn is included in the node-container.

So I now use this node container in an extra task of the build stage in my .gitlab-ci.yaml. I create an artifact with the generated javascript, which is used in the test stage. That seems to work.

As I said before, I am new to vue, and it's the first time I use yarn and webpack. So maybe I am making some obvious mistakes. Please let me know if there are things that can be done in a better way.

gitlab-ci, codeception and selenium web tests

All the php projects I work on, have tests. For some projects, we use PHPUnit as testing framework, but for more recent projects, I prefer to use Codeception, because it has an elegant way to write acceptance tests. We also use gitlab for our projects, and by adding a nifty .gitlab-ci.yml file to our source code, we made gitlab run our test suite every time new commits are pushed to the repository.

Recently, we started using Selenium WebDriver with codeception, so that we could run browser tests, to make sure that the javascripts we use keep working. Of course we wanted to run these browser tests with gitlab-ci as well, but that was not as easy as we thought it would be. The idea was to run selenium with a browser via a docker container, but the challenging part was setting up a webserver the browser could connect to.

In a first attempt, I tried to start all the containers needed for our application, running docker-compose up from the ci like we do it for local development. This worked sometimes, but after a couple of builds the docker networks used by our gitlab runners got completely messed up, which was hard to fix.

In a second attempt, I tried to use Gitlab CI Services for all the containers in our docker-compose.yml file. I gave up before I completely configured that, because I noticed the networking problems wouldn't go away.

After days of swearing, I finally got it running. I think the networking problems were caused by the nginx-container I tried to use for the web tests. But actually I didn't need a container for nginx. It turned out I could just juse the php built-in development server to run the tests.

So I ended up by adding a service for selenium with chrome and a service for mysql (the project I was trying this on, didn't really need other services), and I just added a php -S statement to the script that ran the tests, I had a running server.

I still needed a small hack, to make the browser in the selenium container actually find the webserver. I ended up using a sed-command on the configuration file of my test suite in codeception.

For reference, here is a part of my gitlab-ci.yml file:

    - LOCAL_IP=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
    - echo Local IP $LOCAL_IP
    # Run the php built in server. Don't try to run nginx as a service, that only causes troubles. ;-)
    - php -S 0.0.0.0:8080 -t public/ 2> /dev/null &
    - sed -i "s/localhost:8080/$LOCAL_IP:8080/" tests/acceptance.suite.yml

Note that for this to work, I had to fiddle with the php container to have iproute2 installed.

If you want to see how it actutally works; I created a small demo project on gitlab that uses codeception in gitlab-ci to run a couple of browser tests. You can find the source code on gitlab: https://gitlab.com/johanv/codeception-ci-demo.

Van github naar gitlab

Mijn website is een statische website. Dat wil zeggen dat de hele site automatisch wordt gegenereerd op basis van een aantal tekstbestanden. En die tekstbestanden beheer ik met git.

Gisteren verhuisde ik de git-repository met die teksten van github naar gitlab. Niet omdat ik problemen heb met het bedrijf achter github (want Microsoft is tegenwoordig érg goed bezig), maar wel omdat ik gitlab-ci wou gebruiken om mijn site te bouwen. Concreet komt het erop neer dat, telkens ik een nieuwe versie van de source push, gitlab voor mij mijn site automatisch bouwt en deployt.

Misschien heeft github ook wel zo'n service. Maar die van gitlab heb ik nu al vaak gebruikt, en ik ben er erg tevreden over. Dus vanaf nu wordt mijn blog gepowerd door nikola en gitlab. Waarvoor dank.

Waarom ik signformyfuture.be ondertekende

Sign for my future

Afgelopen zondag werd het klimaatbetoog van Nic Balthazar uitgezonden op één. En ik heb gekeken. Onder het goedkeurend geknik van een aantal Belgische klimaatexperts betoogt Nic dat, tenzij we op korte termijn met z'n allen koolstofneutraal worden (voor België zou dat in 2040 moeten zijn, volgens het rapport van het IPCC van oktober 2018), ergens rond 2060-2080 geconfronteerd zullen worden met wereldwijde droogtes en een miljard klimaatvluchtelingen.

In het klimaatplan van de Vlaamse Overheid staat dat Vlaanderen tegen 2030 40% minder CO2 wil uitstoten. 2030, dat is over 10 jaar. En dus nog eens 10 jaar later, zou die uitstoot nul moeten zijn. Dat lijkt mij erg snel voor zo'n grote omschakeling. Ik zie het nog niet direct gebeuren (lees anders even mee in de commentaren op Facebook waarom ik dat denk). Snelle drastische wijzigingen zijn we in België niet gewoon, laat staan wereldwijd: De Verenigde Staten doen al niet meer mee, en Trump is allicht niet de laatste in zijn soort.

In 2060 zijn mijn kinderen vijftigers. Het zou dus toch niet slecht zijn mocht er snel iets gebeuren. Zeker omdat er een domino-effect dreigt als de aarde blijft opwarmen. Hier en daar zijn er mensen die zelf iets ondernemen of hun manier van leven aanpassen, om klimaatneutraler te zijn. Dat is lovenswaardig, maar dat gaat niet genoeg zijn. Een drastische verandering zoals we die nodig hebben, moet vanuit de overheid komen. En daarom tekende ik op sign for my future. En ik nodig u uit om hetzelfde te doen.

Put your money where your mouth is: Google Analytics

All of a sudden I saw the light. In this series I evangelize that Google is evil, and how I don't want to be tracked. But meanwhile I secretly tell Google that you are reading my blog, via Google Analytics. Which is at least a bit hypocritic.

I don't even remember why I ever put the Google Analytics script on mysite. Sometimes I looked to the list of popular blog posts, but I can do that without Google Analytics. So let's dump it.

Google Analytics in the garbage can

Removing Google Analytics from my site is nothing more than deleting a script. And with those 10 lines of Javascript, I could delete half of my privacy statement as well. Win-win.

Read more…

Contacts, calendar and photos: NextCloud FTW

I've never had a mobile phone before 2010. I used to say that if people wanted to contact me, it should take some effort. So when I bought my first mobile phone back in 2010, I wasn't really interested in having a phone; I was looking for a convenient portable computing device. So I got myself a smartphone.

I remember that I really enjoyed that the phone numbers of my contacts were stored in my Google account. This way I didn't have to create a new contact list after flashing a new ROM. (And at once I could get rid of the hand written list I copied every year.)

But this convenience comes with a price. Google knows all my contacts, and their phone numbers. Let's put this to an end.

Apps that have permissions to access my contacts

As from today, NextCloud will be the one that keeps my contacts, calendar and photos.

Read more…

Getting rid of Google

I've never trusted Google less than today. Yet Google has never known me better. Google knows my contacts and my calendar. Google knows where I am, it has access to all my photos, and it reads lots of the emails I receive. Google used to see my DNS requests, and I would not be suprised if Google has my finger prints.

That is way too much information, this should come to an end. But since I don't want to start over from scratch, I want to do leave Google taking one step at the time. I will start today.

getting rid of google

Read more…

How to use a tablet as a third screen for your Ubuntu system

At work I have a docking station, that allows me to use two external screens with my laptop. And I find this extremely useful. I put a terminal window here, some source doe there, a similar source file over there, and I need to write a unit test while looking up things on Stack Overflow. So those three screens are easily filled.

Sometimes I work from home. I don't have a docking station at my place, and I can use only one external screen. This works as well, but often I miss the extra screen real estate. We do have a tablet though, mainly used by our children. Those are typically away or asleep when I code... So how difficult could it be to use the tablet as an external screen?

a tablet as external screen

Read more…