skip to Main Content

Merry Christmas, dear smart participants
I’ve this job

test-dev:
  stage: test
  script:
    - mkdir -p tests/js/screens/diffs
    - docker run --rm -d --name=browser_$CI_JOB_ID -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome
    - npx mocha tests/js/screenshots-* --timeout 50000
    - npx playwright test tests/js/pw_*
    - php artisan test
    - docker stop browser_$CI_JOB_ID
  artifacts:
    when: always
    name: $CI_COMMIT_SHA
    untracked: true
    paths:
      - tests/js/screens
      - tests/js/report
  cache:
    when: always
    paths:
      - storage/framework
      - vendor/ #composer packages
      - node_modules
      - public
    key:
      files:
        - vendor/ #composer packages
        - composer.lock
  tags:
    - test_new_runner

The same job, but in progress for rebuild

    test-dev:
    #  allow_failure: true
      stage: test
      image: selenium/standalone-chrome
      script:
        - mkdir -p tests/js/screens/diffs
    #    - docker run --rm -d --name=browser_$CI_JOB_ID -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome
        - npx mocha tests/js/screenshots-* --timeout 50000
        - npx playwright test tests/js/pw_*
        - php artisan test
    #    - docker stop browser_$CI_JOB_ID
      artifacts:
        when: always
        name: $CI_COMMIT_SHA
        untracked: true
        paths:
          - tests/js/screens
          - tests/js/report
      cache:
        when: always
        paths:
          - storage/framework
          - vendor/ #composer packages
          - node_modules
          - public
        key:
          files:
            - vendor/ #composer packages
            - composer.lock
      tags:
        - test_new_runner

I want to remove docker launch, because it’s make a failure, but I don’t undertsand how I can use this with image
But if I use image I don’t have npx inside
I haven’t any idea how to do this, can somebody help with this?

2

Answers


  1. Chosen as BEST ANSWER

    I make what wrote @Prabhu But it note a last step

    test-dev:
      stage: test
      image: docker:20.10.16  
      services:
        - docker:dind  
      script:
        - apk add --update npm
        - mkdir -p tests/js/screens/diffs
        - docker run --rm -d --name=browser_$CI_JOB_ID -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome
        - npx mocha tests/js/screenshots-* --timeout 50000
        - npx playwright test tests/js/pw_*
        - php artisan test
        - docker stop browser_$CI_JOB_ID 
      artifacts:
        when: always
        name: $CI_COMMIT_SHA
        untracked: true
        paths:
          - tests/js/screens
          - tests/js/report
      cache:
        when: always
        paths:
          - storage/framework
          - vendor/ #composer packages
          - node_modules
          - public
        key:
          files:
            - vendor/ #composer packages
            - composer.lock
      tags:  
        - test_new_runner
    

    After this step, you should share your docker socket in container like that

    [[runners]]
      name = "23.01.01"
      url = ""
      id = 19
      token = ""
      token_obtained_at = 2023-01-02T05:52:07Z
      token_expires_at = 0001-01-01T00:00:00Z
      executor = "docker"
      [runners.custom_build_dir]
      [runners.cache]
        MaxUploadedArchiveSize = 0
        [runners.cache.s3]
        [runners.cache.gcs]
        [runners.cache.azure]
      [runners.docker]
        tls_verify = false
        image = "ruby:2.7"
        privileged = false
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]
        shm_size = 0
    

    Loock into volumes


  2. You can use base image docker:20.10.16 then install npx then use service to run docker dind and then run selenium browser in your docker.

    like:

    test-dev:
      stage: test
      image: docker:20.10.16  
      services:
        - docker:dind  
      script:
        - apk add --update npm
        - mkdir -p tests/js/screens/diffs
        - docker run --rm -d --name=browser_$CI_JOB_ID -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-chrome
        - npx mocha tests/js/screenshots-* --timeout 50000
        - npx playwright test tests/js/pw_*
        - php artisan test
        - docker stop browser_$CI_JOB_ID 
      artifacts:
        when: always
        name: $CI_COMMIT_SHA
        untracked: true
        paths:
          - tests/js/screens
          - tests/js/report
      cache:
        when: always
        paths:
          - storage/framework
          - vendor/ #composer packages
          - node_modules
          - public
        key:
          files:
            - vendor/ #composer packages
            - composer.lock
      tags:  
        - test_new_runner
    

    Hope this works.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search