# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2020-2021 Huawei Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

stages:
  - compliance
  - build
  - test

include:
 - project: 'OSTC/infrastructure/pipelines'
   file:
    - 'dco.yaml'
    - 'reuse.yaml'
 - project: 'OSTC/OHOS/manifest'
   file:
    # Include the set of generic build rules.
    - '.ostc-ci/build-generic.yaml'
    # Include the set of build flavours.
    - '.ostc-ci/build-flavours.yaml'
    # Include the set of jobs using the default manifest.
    - '.ostc-ci/default-targets.yaml'

dco:
  extends: .dco

reuse:
  extends: .reuse
  # FIXME: https://git.ostc-eu.org/OSTC/OHOS/meta-ohos/-/issues/19
  allow_failure: true

build-docs:
  image:
    name: registry.ostc-eu.org/ostc/containers/ostc-docs-builder
  stage: build
  script:
    - cd docs && make
  artifacts:
    paths:
      - docs/build
  rules:
    # Build the docs when a merge request is created.
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        # React to changes to the docs directory.
        - docs/**/*
        # Run this job in case the pipeline changes.
        - .ostc-ci/*.yml

# Customize the generic .build job, included from build-generic.yaml above,
# with settings for testing updates to the meta-ohos git repository.
.build:
  variables:
    # The path of the git repository to deviate from what the git-repo manifest
    # prepares. This effectively allows testing incoming changes that match the
    # repository holding this CI pipeline.
    #
    # The path is relative to the checked out "sources/" directory.
    OHOS_CI_GIT_REPO_PATH: "meta-ohos"
  artifacts:
    # Disable collection of image artifacts. They are not used here and they
    # are expensive to upload and store.
    paths: []
  rules:
    # Perform bitbake build when a merge request is created.
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        # React to changes to meta-layers assets and flavours.
        - assets/**/*
        - flavours/**/*
        - meta-*/**/*
        # Run this job in case the pipeline changes.
        - .ostc-ci/*.yml
