summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 435bfb71d67986d69b2d2f18952285306d5ffeec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
image: buildstream/buildstream-fedora:latest

variables:
  # Store cache in the shared Docker volume, which gives us much more space
  # than if we build in the root disk.
  XDG_CACHE_HOME: "/cache"

  YBD_base: "/cache/ybd_base"
  YBD_gits: "/cache/ybd_base/gits"
  GET_SOURCES_ATTEMPTS: 3

cache:
  paths:
  - ".${YBD_gits}/"
  - "./cache/buildstream/sources/"

before_script:
  # Ensure cache is inside build directory. GitLab CI will ignore
  # everything if we tell it to store /cache because it only wants
  # to cache things inside the build directory.
  - ln -s /cache ./cache

  # Update to latest BuildStream
  - |
    cd ~/buildstream
    git pull origin master
    dnf install -y python3-pip
    pip3 install .
    cd -

  - export XDG_CACHE_HOME=/cache

  # Create ~/.ssh for storing keys
  - mkdir -p ~/.ssh

  # Private key stored as a protected variable that allows pushing to
  # ostree@ostree.baserock.org
  - |
    if [ -z "$baserock_ostree_cache_private_key" ]; then
        echo >&2 "Private key for ostree.baserock.org is not available."
    else
        echo "$baserock_ostree_cache_private_key" > ~/.ssh/id_rsa
        chmod 600 ~/.ssh/id_rsa
        ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
    fi

  # Trust the host key of the cache server.
  - ssh-keyscan -p 22200 ostree.baserock.org >> ~/.ssh/known_hosts

  # Enable push and pull for Baserock artifact cache (default config is pull only)
  - |
    mkdir -p ~/.config
    echo "projects:" > ~/.config/buildstream.conf
    echo "  baserock:" > ~/.config/buildstream.conf
    echo "    artifacts:" > ~/.config/buildstream.conf
    echo "      pull-url: https://ostree.baserock.org/cache/" >> ~/.config/buildstream.conf
    if [ -n "$baserock_ostree_cache_private_key" ]; then
        echo "      push-url: ostree@ostree.baserock.org:cache" >> ~/.config/buildstream.conf
        echo "      push-port: 22200" >> ~/.config/buildstream.conf
    fi
    cat ~/.config/buildstream.conf

  # Install and configure YBD
  - |
    export LC_ALL="C.UTF-8"
    export CI_YBD_BRANCH=`[[ "$CI_BUILD_REF_NAME" =~ ^staging/fromybd/ ]] && echo -b ${CI_BUILD_REF_NAME#staging/fromybd/}` 
    git clone https://gitlab.com/baserock/spec.git
    git clone https://gitlab.com/baserock/ybd.git $CI_YBD_BRANCH
    cd ybd && ./install_dependencies.sh && cd ..
    pip install -r spec/requirements.txt


stages:
  - build-1
  - deploy-1
  - build-2
  - build-3

ybd-build-test:
  stage: build-1
  script:
  - ybd/ybd.py strata/build-essential/stage1-binutils.morph x86_64

bst-build-test:
  stage: build-1
  script:
  - scripts/bst-build-or-show gnu-toolchain/stage1-gcc.bst