Skip to content
Snippets Groups Projects
build-pipeline-yocto.yml.jinja2 10 KiB
Newer Older
# --------------------------------------------------------------------------------------
# Global
# --------------------------------------------------------------------------------------
# As the trigger job is not executed in a environment with checked out repository, we
# need to get the includes directly from gitlab
  - project: '{{ CI_PROJECT_ROOT_NAMESPACE }}/yocto/infrastructure/gitlab-ci'
    ref: {{ GITLAB_CI_REVISION }}
  - Infrastructure
  - Build
  - Test
  - Package
  - Deploy SoftwareStore
  - Deploy SoftwareStore Internal
  - Deploy FTP
Tim Jaacks's avatar
Tim Jaacks committed
  - Deploy Azure
Tim Jaacks's avatar
Tim Jaacks committed
  - Confluence
  MASTER_BRANCH: {{ MASTER_BRANCH }}
# --------------------------------------------------------------------------------------
# Stage: Infrastructure
# --------------------------------------------------------------------------------------
changelog:
  extends: .changelog
Tim Jaacks's avatar
Tim Jaacks committed
build-version:
  extends: .build_version
  variables:
    # We have to set a machine, even if it is not actually needed for what the job does,
    # so we just choose the first.
    MACHINE: {{ MACHINES.split(' ')[0] }}
# --------------------------------------------------------------------------------------
# Stage: Build
# --------------------------------------------------------------------------------------
build-documentation:
  extends: .build_documentation
  rules:
    - if: $DOCUMENTATION_FILES
  variables:
    FILES: ${DOCUMENTATION_FILES}
  needs:
    - job: changelog

{% for machine in MACHINES.split(' ') %}

{% if SIMULATE_BUILD is not defined or SIMULATE_BUILD != "true" %}

  extends: .build_yocto
    BITBAKE_TASK: build
    MACHINE: {{ machine }}
{% else %}

build-{{ machine }}:
  extends:
    - .buildbase
    - .simulate_build
  variables:
    MACHINE: {{ machine }}
    # We have to specify a tag here instead of getting the artifacts from a master
    # branch, because we don't always execute the full pipeline on the master branches.
    # In those cases the actual build job does not exist, which results in a 404 error.
Tim Jaacks's avatar
Tim Jaacks committed
    BUILD_ARTIFACTS: ${BUILD_ARTIFACTS_{{ machine | replace("-", "_") }}}
  after_script:
    # FIXME: This is necessary because we're using an old build for the build simulation
    # which does not export these variables, yet. Can be removed as soon as we switch to
    # a newer release already containing these variables.
    - source build.env
    # yamllint disable-line rule:line-length
{%- if machine == "seco-mx6" %}
    - export SUPPORTED_HARDWARE="     SANTARO,     SANTOKA,     SANTINO,     SANTINO LT,     SANTVEND, "
{%- elif machine == "seco-mx8mm" %}
    - export SUPPORTED_HARDWARE="     TANARO, "
{%- elif machine == "seco-genio700" %}
    - export SUPPORTED_HARDWARE="     WILK, "
{%- endif %}
    - !reference [.save_build_env]

{% endif %}
# --------------------------------------------------------------------------------------
# Stage: Test
# --------------------------------------------------------------------------------------
# Run platform tests for this machine which the yocto image
# This is a little hacky as we need to match the machine name to
# the available platforms
{% for machine in MACHINES.split(' ') %}
{% if machine == 'seco-mx6' or machine == 'imx6guf' %}
  {% set platforms = "santaro santoka santino santino-lt" %}
  {% set lava_machine = "imx6guf" %}
{% elif machine == 'seco-mx6ull' or machine == 'imx6ullguf' %}
  {% set platforms = "nallino" %}
  {% set lava_machine = "imx6ullguf" %}
{% elif machine == 'seco-mx8mm' or machine == 'imx8mguf'  %}
  {% set platforms = "tanaro" %}
  {% set lava_machine = "imx8mguf" %}
{% elif machine == 'seco-genio700' %}
  {% set platforms = "wilk" %}
  {% set lava_machine = "genio700" %}
  {% set platforms = '' %}
  {% set lava_machine = '' %}
{% endif %}

{% if platforms %}
# Run smoketests for this machine which the yocto image
smoketest:{{ machine }}:
  stage: Test
  needs:
    - job: build-{{ machine }}
  variables:
    BUILD_JOB: build-{{ machine }}
    LAVA_MACHINE: {{ lava_machine }}
    PLATFORMS: {{ lava_machine }}
    TEST_SUITE: boot.jinja2
    TEST_EXTRA_ARGUMENTS: --all-devices
  stage: Test
  needs:
    - job: build-{{ machine }}
  variables:
    BUILD_JOB: build-{{ machine }}
    LAVA_MACHINE: {{ lava_machine }}
    PLATFORMS: {{ platforms }}
# --------------------------------------------------------------------------------------
# Stage: Package
# --------------------------------------------------------------------------------------
package-documentation:
  extends: .package_documentation
  rules:
    - if: $DOCUMENTATION_FILES
  variables:
    ASSOCIATED_BUILD_JOB: build-documentation
  needs:
    - job: build-documentation
    - job: build-version

{% for machine in MACHINES.split(' ') %}

package-{{ machine }}:
  extends: .package_build
  variables:
    MACHINE: {{ machine }}
    TYPE: ${PACKAGE_TYPE}
    ASSOCIATED_BUILD_JOB: build-{{ machine }}
  needs:
    - job: build-{{ machine }}
      artifacts: false

# --------------------------------------------------------------------------------------
# Stage: Deploy SoftwareStore
# --------------------------------------------------------------------------------------
.deploy-software-store:
Tim Jaacks's avatar
Tim Jaacks committed
  extends: .deploy-rsync
{% if CI_COMMIT_TAG is defined %}
  stage: Deploy SoftwareStore
  rules: &deploy_software_store_rules
    - if: $DEPLOY_RELEASE_TARGET !~ /^./
      when: never
    - when: manual
    DEPLOY_SOURCE: ${RELEASE_NAME}
    DEPLOY_TARGET: ${DEPLOY_RELEASE_TARGET}/${RELEASE_NAME}
    DEPLOY_TARGET_LINK: ${DEPLOY_RELEASE_TARGET_LINK}/${RELEASE_NAME}
{% else %}
  stage: Deploy SoftwareStore Internal
  rules: &deploy_software_store_rules
    - if: $DEPLOY_INTERNAL_RELEASE_TARGET !~ /^./
      when: never
    - when: manual
    DEPLOY_SOURCE: ${RELEASE_NAME}
    DEPLOY_TARGET: ${DEPLOY_INTERNAL_RELEASE_TARGET}/${RELEASE_NAME}
    DEPLOY_TARGET_LINK: ${DEPLOY_INTERNAL_RELEASE_TARGET_LINK}/${RELEASE_NAME}

deploy-documentation:
  extends: .deploy-software-store
  rules:
    - if: $DOCUMENTATION_FILES !~ /^./
      when: never
    - *deploy_software_store_rules
  variables:
    ASSOCIATED_PACKAGE_JOB: package-documentation
  needs:
    - job: package-documentation
      artifacts: false
    - job: build-version

{% for machine in MACHINES.split(' ') %}

deploy-{{ machine }}:
  extends: .deploy-software-store
  variables:
    ASSOCIATED_PACKAGE_JOB: package-{{ machine }}
    MACHINE: {{ machine }}
  needs:
    - job: package-{{ machine }}
      artifacts: false
# --------------------------------------------------------------------------------------
# Stage: Deploy FTP
# --------------------------------------------------------------------------------------
{% if SIMULATE_BUILD is defined and SIMULATE_BUILD == "true"
   or CI_COMMIT_TAG is defined %}
.deploy-ftp:
Tim Jaacks's avatar
Tim Jaacks committed
  extends: .deploy-rsync
  stage: Deploy FTP
  tags:
    - ftp
  rules: &deploy_ftp_rules
    - if: $DEPLOY_FTP_TARGET !~ /^./
      when: never
    - when: manual
      allow_failure: true
  variables:
    DEPLOY_SOURCE: ${RELEASE_NAME}
    DEPLOY_TARGET: ${DEPLOY_FTP_TARGET}/${RELEASE_NAME}
    DEPLOY_TARGET_LINK: ${DEPLOY_FTP_TARGET_LINK}/${RELEASE_NAME}

ftp-documentation:
  extends: .deploy-ftp
  rules:
    - if: $DOCUMENTATION_FILES !~ /^./
      when: never
    - *deploy_ftp_rules
  variables:
    ASSOCIATED_PACKAGE_JOB: package-documentation
  needs:
    - job: package-documentation
      artifacts: false
    - job: build-version

{% for machine in MACHINES.split(' ') %}

ftp-{{ machine }}:
  extends: .deploy-ftp
  variables:
    ASSOCIATED_PACKAGE_JOB: package-{{ machine }}
    MACHINE: {{ machine }}
  needs:
    - job: package-{{ machine }}
      artifacts: false
Tim Jaacks's avatar
Tim Jaacks committed
# --------------------------------------------------------------------------------------
# Stage: Deploy Azure
# --------------------------------------------------------------------------------------
{% if SIMULATE_BUILD is defined and SIMULATE_BUILD == "true"
   or CI_COMMIT_TAG is defined %}

Tim Jaacks's avatar
Tim Jaacks committed
  extends: .deploy-azure
  stage: Deploy Azure
  rules: &azure_rules
    #  "=~ /^./" is the GitLab way of checking whether a variable is set and not empty.
    # See for reference: https://gitlab.com/gitlab-org/gitlab/-/issues/321371
    - if: $AZURE_CONTAINER_NAME !~ /^./ || $AZURE_TARGET_FOLDER !~ /^./
      when: never
    - when: manual
Tim Jaacks's avatar
Tim Jaacks committed
      allow_failure: true
  variables:
    DEPLOY_SOURCE: ${RELEASE_NAME}
    DEPLOY_TARGET: ${AZURE_TARGET_FOLDER}/${RELEASE_NAME}
Tim Jaacks's avatar
Tim Jaacks committed
    CONTAINER_NAME: ${AZURE_CONTAINER_NAME}

azure-documentation:
  extends: .azure
  rules:
    - if: $DOCUMENTATION_FILES !~ /^./
      when: never
    - *azure_rules
  variables:
    ASSOCIATED_PACKAGE_JOB: package-documentation
  needs:
    - job: package-documentation
      artifacts: false
    - job: build-version

{% for machine in MACHINES.split(' ') %}

azure-{{ machine }}:
  extends: .azure
  variables:
Tim Jaacks's avatar
Tim Jaacks committed
    ASSOCIATED_PACKAGE_JOB: package-{{ machine }}
    MACHINE: {{ machine }}
Tim Jaacks's avatar
Tim Jaacks committed
  needs:
    - job: package-{{ machine }}
      artifacts: false
    - job: build-version
{% endfor %}
Tim Jaacks's avatar
Tim Jaacks committed

# --------------------------------------------------------------------------------------
# Stage: Confluence
# --------------------------------------------------------------------------------------
{% if SIMULATE_BUILD is defined and SIMULATE_BUILD == "true"
   or CI_COMMIT_TAG is defined %}

    - if: $CONFLUENCE_PARENT_ID =~ /^./ && $CONFLUENCE_SPACE =~ /^./
      when: manual
      allow_failure: true

Tim Jaacks's avatar
Tim Jaacks committed
generate-confluence-page:
  extends:
    - .generate-confluence-page
Tim Jaacks's avatar
Tim Jaacks committed
  variables:
    PAGE_TEMPLATE: .gitlab-ci/confluence-page.xml.jinja2

publish-confluence-page:
  extends:
    - .publish-confluence-page
Tim Jaacks's avatar
Tim Jaacks committed

{% endif %}