Commit 683b4a8b authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding some tests for robot2doc software + fixing gitlab-ci

parent b310c165
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
test:
  script:
    docker run -v$(pwd):/work:ro etsiforge/r2d "/bin/sh" -c "cd /work/robot2doc && python3 -m pytest"
 No newline at end of file
    docker run -v$(pwd):/work:rw --user $(id -u):$(id -g) etsiforge/r2d "/bin/sh" -c "cd /work/robot2doc && python3 -m pytest"
 No newline at end of file
+4 −2
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ def get_git_reference(folder):

    return (None, None, branch)


if __name__ == "__main__":

    if len(sys.argv) < 2:
@@ -229,6 +230,7 @@ if __name__ == "__main__":
    else:
        print("Could not determine branch")

    
    for solspec in sol_specs:
        spec_index = load_spec_index(ROOT, solspec)
        create_test_for_sol(solspec, spec_index, ROOT, COMMIT_ID, OUTDIR)
+23 −0
Original line number Diff line number Diff line
FROM ubuntu:20.04

MAINTAINER ETSI CTI

LABEL description="ETSI CTI robot2doc software tests image"

RUN DEBIAN_FRONTEND=noninteractive apt update \
	&& apt install python3 git -y \
	&& apt install python3-pip -y \
    && DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y \
    && DEBIAN_FRONTEND=noninteractive apt-get autoclean \
    && rm -rf /var/lib/apt/lists/*

RUN useradd --create-home --shell /bin/bash --user-group gitlab-runner --groups sudo \
    && echo "gitlab-runner:gitlab-runner" | chpasswd \
    && adduser gitlab-runner sudo \
    && echo "gitlab-runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

#To avoid to use the cache when new commits are available
ADD "https://forge.etsi.org/rep/api/v4/projects/224/repository/branches/master" /tmp/devalidateCache

RUN DEBIAN_FRONTED=noninteractive \
	pip3 install pytest robotframework python-docx \
 No newline at end of file
+11 −1
Original line number Diff line number Diff line
@@ -29,8 +29,18 @@ def test_parse_commit_from_log():

def test_get_git_reference():

    comm, reftype = crs.get_git_reference("..")
    comm, reftype, branch = crs.get_git_reference('..')

    assert comm is not None
    assert isinstance(comm, str)

def test_parse_branch_from_log():
    '''Test usage of parse_branch_from_log'''

    with_branch = "231f303 (HEAD, tag: 2.7.1.0.0.2, origin/2.7.1-dev) updated indexes"
    with_master = "023ca44 (origin/master) Merge branch '2.7.1-dev-SOL002-branch' into '2.7.1-dev'"
    without_branch = "023ca44 (noBranch) Merge branch '2.7.1-dev-SOL002-branch' into '2.7.1-dev'"

    assert crs.parse_branch_from_log(with_branch) == "2.7.1-dev"
    assert crs.parse_branch_from_log(with_master) == "master"
    assert crs.parse_branch_from_log(without_branch) is None