Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 009f8e52 authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

Merge branch 'master' into 'production'

Use version from build when not in header

See merge request !50
parents 20d7dc6a 0ec03e8d
Loading
Loading
Loading
Loading

.flake8

0 → 100644
+3 −0
Original line number Diff line number Diff line
[flake8]
max-line-length = 88
ignore = E203, E731
+55 −6
Original line number Diff line number Diff line
@@ -8,11 +8,10 @@ variables:
  PUBLISH_URL: ota.ecloud.global
  DOCKER_TLS_CERTDIR: "/certs"

services:
- docker:19.03.1-dind

build:
  stage: build
  services:
    - docker:19.03.1-dind
  script:
  - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME || true
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
@@ -21,6 +20,54 @@ build:
  - if [ "${CI_COMMIT_REF_NAME}" = master ] ; then docker push $CI_REGISTRY_IMAGE:latest ; fi
  tags:
    - generic_privileged
  rules:
    - if: '$CI_PIPELINE_SOURCE != "schedule"'

check:rules:tests:
  stage: build
  image: python:3.11-slim
  before_script:
    - pip install black==22.10.0 flake8==5.0.4 isort==5.10.1
  script:
    - cd tests/functional
    - black --check .
    - flake8 .
    - isort --check .
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - tests/functional/*

.tests:functional:
  stage: test
  image: python:3.11-slim
  variables:
    PYTEST_ADDOPTS: "--junitxml=report.xml"
  before_script:
    - cd tests/functional/
    - pip install -r requirements.txt
  rules:
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      changes:
        - tests/functional/*
  artifacts:
    when: always
    paths:
      - tests/functional/report.xml
    reports:
      junit: tests/functional/report.xml


tests:functional:staging:
  extends: .tests:functional
  script:
    - pytest --ota-domain "test.${PUBLISH_URL}"

tests:functional:production:
  extends: .tests:functional
  script:
    - pytest --ota-domain "${PUBLISH_URL}"

# Deploy stage
.deploy:image:
@@ -44,6 +91,8 @@ build:

deploy:staging:
  extends: .deploy:image
  rules:
    - if: '$CI_COMMIT_REF_NAME != "production" && $CI_PIPELINE_SOURCE != "schedule"'
      when: manual
  environment:
    name: staging
@@ -51,8 +100,8 @@ deploy:staging:

deploy:production:
  extends: .deploy:image
  only:
    - production
  rules:
    - if: '$CI_COMMIT_REF_NAME == "production" && $CI_PIPELINE_SOURCE != "schedule"'
  environment:
    name: production
    url: https://ota.ecloud.global
+17 −7
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@
            // Get the file list and parse it
            $files = scandir($dir);
            if (count($files) > 2) {
                
                $all_builds = array();
                foreach ($files as $file) {
                    // Skip all files except for the ones that match the pattern
                    // filename starting with e- and ending with .zip are considered as valid files
@@ -204,17 +204,27 @@
                    } else {
                        $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch);
                    }
                    
                    if ($build->includeInResults($this->postData['params'], $this->currenteOSVersion)) {
                        array_push($this->builds, $build);
                    }
                    array_push($all_builds, $build);

                    $sourceIncremental = isset($this->postData['params']['source_incremental']) ? $this->postData['params']['source_incremental'] : NULL;
                    if ($build->isValid($this->postData['params']) && $sourceIncremental && strcmp($sourceIncremental, $build->getIncremental()) === 0) {
                        $this->currentBuild = $build;
                        $this->logger->info($build->getIncremental().' is the current build');
                        if($this->currenteOSVersion === -1){
                            //get current version from build.prop
                            $this->currenteOSVersion = $this->currentBuild->getVersion();
                        }
                    }
                }

                $this->logger->debug('Current version: '.$this->currenteOSVersion);

                foreach ($all_builds as $build){
                    if ($build->includeInResults($this->postData['params'], $this->currenteOSVersion)) {
                        array_push($this->builds, $build);
                    }
                }

            }
            $this->logger->debug('Total execution  time  of getBuilds in seconds');
        }
+28 −0
Original line number Diff line number Diff line
import pytest


class Context:
    def __init__(self, config):
        self.domain = config.getoption("--ota-domain")
        assert self.domain is not None, "OTA server domain has to be defined"
        self.device = config.getoption("--ota-device")
        self.channel = config.getoption("--ota-channel")
        self.url = f"https://{self.domain}"


def pytest_addoption(parser):
    parser.addoption(
        "--ota-domain", action="store", default=None, help="OTA server domain"
    )
    parser.addoption(
        "--ota-device", action="store", default="FP3", help="OTA device name"
    )
    parser.addoption(
        "--ota-channel", action="store", default="stable", help="OTA channel name"
    )


@pytest.fixture
def ctx(request):
    context = Context(request.config)
    yield context
+2 −0
Original line number Diff line number Diff line
pytest==7.2.0
httpx==0.23.1
Loading