Gitlab-CI intergration

For questions about Gambas web tools.
Post Reply
User avatar
BruceSteers
Posts: 1838
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Gitlab-CI intergration

Post by BruceSteers »

I figured out some gitlab ci stuff and got my gambas application to test compile itself on various distros.

It's pretty easy to test the latest main distros and use the distro supplied gambas vesrion.

I do it like this.. (note: my program uses gb.form.editor so i also need to ensure gb.highlight is installed)

The following bits of code are all in a file called .gitlab-ci.yml in my project directory. gitlab automatically tries to run it if it exists.

Code: Select all

build:ubuntu-noble:
  image: ubuntu:noble
  before_script:
    - >
       apt-get update && apt-get install -y gambas3 gambas3-gb-highlight
  script:
    - gbc3 -wax
    - gba3

build:fedora-latest:
  image: fedora:latest
  before_script:
    - >
       dnf install -y gambas3 gambas3-gb-highlight
  script:
    - gbc3 -wax
    - gba3

build:archlinux:
  image: archlinux:base
  before_script:
    - >
       pacman -Syu --needed --noconfirm
    - >
       pacman -Sy --noconfirm gambas3 gambas3-gb-highlight
  script:
    - gbc3 -wax
    - gba3

So just installing gambas3 and gambas3-gb-highlight
Then attempting to compile the project with gbc3 and gba3
If all goes well the test passes
if gbc compiler fails it shows the error


Needing gambas stable or master can be a bit trickier but i made a way.
Some of the Os's have older gambas version that do not have gb.highlight so i had to do this on some..

So this is what i worked out for distros that had older gambas...

For Ubuntu based system i could use the PPA method,
i had to set the timezone to stop tzdata asking for input and also installed software-properties-common (and sudo) so add-apt-repository worked

Code: Select all

build:ubuntu-jammy:
  image: ubuntu:jammy
  before_script:
    - >
       TZ=Europe/London && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && TERM=xterm-mono &&
       apt-get update && apt-get install -y sudo software-properties-common && sudo add-apt-repository -y ppa:gambas-team/gambas3 && 
       apt-get update && apt-get install -y gambas3 gambas3-gb-highlight
  script:
    - gbc3 -wax
    - gba3

For other systems i had to download and compile gambas stable from gitlab to install,
I used the Install_Gambas.sh script I've already made to install gambas on the supported distros.
I added some code to it so it can auto-install without user interaction.

Now a distro name can be given and "I" used to do the install not print the commands.
Eg.
./Install_Gambas.sh ubuntu-noble I

So it is a case of making the gitlab docker download gambas stable git then downloading my install script into the folder.
So i install sudo (for the install script) wget (to get my script) and git to clone...
git clone the gambas stable branch into a gambas folder and cd into it...
Download my installer script and make it executable..
then execute it with the distro name and I to make it auto-install
then cd back to project dir

Code: Select all


build:debian-bookworm:
  image: debian:bookworm
  before_script:
    - >
       apt-get update && apt install -y git sudo wget && cd ~ && git clone https://gitlab.com/gambas/gambas.git --depth=1 --branch=stable gambas &&
       cd gambas && wget -O ./Install_Gambas.sh https://gitlab.com/bsteers4/gambas/-/raw/bruces-patched/Install_Gambas.sh && chmod +x ./Install_Gambas.sh &&
       ./Install_Gambas.sh debian-bookworm i &&
       cd "$CI_PROJECT_DIR"
  script:
    - gbc3 -wax
    - gba3

build:opensuse-tumbleweed:
  image: opensuse/tumbleweed
  before_script:
    - >
       zypper update -y && zypper install -y git sudo wget && cd ~ && git clone https://gitlab.com/gambas/gambas.git --depth=1 --branch=stable gambas && 
       cd gambas && wget -O ./Install_Gambas.sh  https://gitlab.com/bsteers4/gambas/-/raw/bruces-patched/Install_Gambas.sh && chmod +x ./Install_Gambas.sh &&
       ./Install_Gambas.sh opensuse-tumbleweed i &&
       cd "$CI_PROJECT_DIR"
  script:
    - gbc3 -wax
    - gba3

Perhaps you may find this useful?
If at first you don't succeed , try doing something differently.
BruceS
Post Reply