stages:
  - build 
  - test 
  - deploy

# variables:
  # $CI_BUILDS_DIR : /builds/ewbo4360/devops_wise24_ewbo/MPD

before_script:
# the 2 following steps make sure that the required building tool (meson) is installed on the runner
#and also that all the other external dependencies are here (this will be part of a container later) 
  - apt-get update  # Make sure the package lists are updated
  - apt-get upgrade -y 
  - apt-get install -y build-essential
  - apt-get install -y meson 
  - apt-get install -y meson
  - apt-get install -y ccache
  - apt-get install -y libfmt-dev 
  - apt-get install -y libgtest-dev 
  - apt-get install -y libpcre2-dev 
  - apt-get install -y libsystemd-dev libdbus-1-dev 
  - apt-get install -y libicu-dev 
  - apt-get install -y libcurl4-gnutls-dev 
  - apt-get install -y libpcre2-dev 
  - apt-get install -y libavahi-client-dev 
  - apt-get install -y libmad0-dev libmpg123-dev libid3tag0-dev 
  - apt-get install -y libflac-dev libvorbis-dev libopus-dev libogg-dev 
  - apt-get install -y libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev 
  - apt-get install -y libfluidsynth-dev libgme-dev libmikmod-dev libmodplug-dev 
  - apt-get install -y libmpcdec-dev libwavpack-dev libwildmidi-dev 
  - apt-get install -y libsidplay2-dev libsidutils-dev libresid-builder-dev 
  - apt-get install -y libavcodec-dev libavformat-dev 
  - apt-get install -y libmp3lame-dev libtwolame-dev libshine-dev 
  - apt-get install -y libsamplerate0-dev libsoxr-dev 
  - apt-get install -y libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev 
  - apt-get install -y libzzip-dev 
  - apt-get install -y libyajl-dev libexpat-dev 
  - apt-get install -y libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev 
  - apt-get install -y libpulse-dev libshout3-dev
  - apt-get install -y libsndio-dev 
  - apt-get install -y libmpdclient-dev 
  - apt-get install -y libnfs-dev 
  - apt-get install -y libupnp-dev 
  - apt-get install -y libsqlite3-dev 
  - apt-get install -y libchromaprint-dev 
  - apt-get install -y libgcrypt20-dev

  # This sets up the meson envt 
  - meson setup \
    -Ddocumentation=disabled \
    -Dtest=true \
    -Dsystemd=enabled \
    -Dpcre=enabled \
    --wrap-mode nofallback
    output/full


build-job :
  stage: build
  image: ubuntu:22.04
  script:
    - echo "Hello, $GITLAB_USER_LOGIN! This is a build job"
    - meson compile -C output/full --verbose

test-job1:
  stage: test
  script:
    - echo "This job tests something"

test-job2:
  stage: test
  script:
    - echo "This job tests something, but takes more time than test-job1."
    - echo "After the echo commands complete, it runs the sleep command for 20 seconds"
    - echo "which simulates a test that runs 20 seconds longer than test-job1"
    - sleep 20

deploy-prod:
  stage: deploy
  script:
    - echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
  environment: production