Commit 9f3dbcdd authored by Adrian DC's avatar Adrian DC
Browse files

fix: resolve #106: resolve relative paths against configuration

parent 42143f0d
Loading
Loading
Loading
Loading
+4 −0
Changes for .gitlab-ci.yml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -184,6 +184,10 @@ stages:
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -v ./tests/local:/opt/src:ro -p
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -v ./tests/volumes:/opt/src3:ro -p
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -v ./tests/local:/opt/src:ro -v ./tests/volumes:/opt/src:ro -p && exit 1 || true
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -w . -p
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -w ./tests/volumes/ -p
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -w /opt/src -p
    - gitlabci-local -c ./tests/volumes/.gitlab-ci.yml -w /opt/unknown -p
    - gitlabci-local -c ./tests/includes/.gitlab-ci.yml -p
    - gitlabci-local -c ./tests/extends/.gitlab-ci.yml -p
    - gitlabci-local -c ./tests/multilines/.gitlab-ci.yml -p
+3 −2
Changes for gitlabci_local/parser.py: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -251,12 +251,13 @@ def parser(options, data, environment):
        if 'volumes' in local:
            if not options.volume:
                options.volume = []
            options.volume = local['volumes'] + options.volume
            for volume in local['volumes']:
                options.volume += ['.local:' + volume]

        # Parse local workdir
        if 'workdir' in local:
            if not options.workdir:
                options.workdir = Path(local['workdir']).resolve()
                options.workdir = Path(options.path / local['workdir']).resolve()

        # Parse local configurations
        if 'configurations' in local:
+12 −4
Changes for gitlabci_local/runner.py: 12 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -303,24 +303,32 @@ def runner(options, job_data, last_result, jobs_status):
    # Extend mounts
    if options.volume:
        for volume in options.volume:
            cwd = Path('.')
            volume_local = False
            volume_nodes = volume.split(':')

            # Handle .local volumes
            if volume_nodes[0] == '.local':
                cwd = options.path
                volume_local = True
                volume_nodes.pop(0)

            # Parse HOST:TARGET:MODE
            if len(volume_nodes) == 3:
                volume_host = resolvePath(os.path.expandvars(volume_nodes[0]))
                volume_host = resolvePath(cwd / os.path.expandvars(volume_nodes[0]))
                volume_target = os.path.expandvars(volume_nodes[1])
                volume_mode = volume_nodes[2]

            # Parse HOST:TARGET
            elif len(volume_nodes) == 2:
                volume_host = resolvePath(os.path.expandvars(volume_nodes[0]))
                volume_host = resolvePath(cwd / os.path.expandvars(volume_nodes[0]))
                volume_target = os.path.expandvars(volume_nodes[1])
                volume_mode = 'rw'

            # Parse VOLUME
            else:
                volume_host = resolvePath(os.path.expandvars(volume))
                volume_target = resolvePath(os.path.expandvars(volume))
                volume_host = resolvePath(cwd / os.path.expandvars(volume))
                volume_target = resolvePath(cwd / os.path.expandvars(volume))
                volume_mode = 'rw'

            # Append volume mounts
+1 −0
Changes for tests/volumes/.gitlab-ci.yml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ variables:
  before_script:
    - echo '__BEFORE__'
  script:
    - pwd
    - ls -la /opt/src/
    - ls -la /opt/src/folder/
    - ls -la /opt/src2/