Storing artifacts and test results issue

So in my circle.yml I call mkdir -p test-results/coverage test-results/nose

But when it gets to the step to store artifacts or test results, it can’t find the directory. The workaround I found was to create the directories and transfer them into my image in the Dockerfile with .gitkeep files in them so they will be added to source control.

This seems incorrect, why would it not be able to find the directories when I create them with mkdir? They’re on the same directory as the app and my config for nose and coverage are as follows:

In my settings.py:

NOSE_ARGS = [
    '--with-coverage',
    '--cover-package=sasite',
    '--with-xunit',
    '--xunit-file=test-results/nose/noseresults.xml',
    '--verbosity=3'
]

and my coverage setup:

if settings.IS_TESTING:
    import coverage
    cov = coverage.coverage(source=['sasite'], omit=['*/tests/', '/logs/', '/test-results/*', '*/test-results/*', '*/*/locale/*', '*/locale/*', '*/migrations/*', '/my.conf/*', '/env1/*', '/venv/*', '/caches/*', '/.docker/*', '/.circleci/*', '/scripts/*'])
    cov.set_option('report:show_missing', True)
    cov.erase()
    cov.start()

execute_from_command_line(sys.argv)

if settings.IS_TESTING:
    cov.stop()
    cov.save()
    cov.html_report(directory='test-results/coverage/coveragehtml.html')
    cov.xml_report(outfile='test-results/coverage/coveragexml.xml')
    cov.report()

When I create the directory for test-results with .gitkeep locally, it does succeed in saving artifacts and test results, or so it says. But nothing shows up in the summary.

Can you share your circle.yml file (and a link to a build?)

A link to the build:

https://circleci.com/bb/shenkan-associates/sawebsite-redesign/145

But I’m not sure you can see it since it’s a private organization. The build doesn’t show anything anyway, here’s the output for the save test results and store artifacts steps:

Uploading artifacts00:00
Uploading /app/test-results to test
Uploading /app/test-results/coverage/.gitkeep: SKIPPED, file is empty
Uploading /app/test-results/nose/.gitkeep: SKIPPED, file is empty
Uploading test results00:00

As you can see, the .gitkeep files are in the directories because mkdir doesn’t seem to work to create them. I had to add them to source control and put .gitkeep files in to get them to show up otherwise it tells me it can’t find the directories. Even when I have the command mkdir -p test-results/coverage test-results/nose above these steps.

Archiving the following test results
  * /app/test-results

Here’s my config.yml:

version: 2
jobs:
  build:
    working_directory: /app
    docker:
      - image: bayesimpact/circleci
    steps:
      - checkout
      - setup_remote_docker
      - restore_cache:
          keys: 
            - v1-{{ .Branch }}-{{ checksum "requirements/test.txt" }}
            - v1-{{ .Branch }}-dependencies     
      - run:
          name: Install dependencies
          command: |
            pip3 install virtualenv
            python3 -m venv venv
            . venv/bin/activate
            pip3 install --upgrade pip setuptools
            pip3 install -r requirements/test.txt
      - save_cache:
          key: v1-{{ .Branch }}-{{ checksum "requirements/test.txt" }}
          paths:
            - ./venv
      - restore_cache:
          keys:
            - v1-{{ .Branch }}
          paths:
            - /caches/app.tar
      - run:
          name: Load Docker image layer cache
          command: |
            set +o pipefail
            docker load -i /caches/app.tar | true
      - run:
          name: Build and tag application Docker image
          command: |
            docker build --cache-from=/caches/app -t app -f Dockerfile.imagetest .
            docker tag app app:testing
      - run:
          name: Save Docker image layer cache
          command: |
            mkdir -p caches
            docker save -o /caches/app.tar app
      - save_cache:
          key: v1-{{ .Branch }}-{{ epoch }}
          paths:
            - /caches/app.tar            
      - run:
          name: Run tests
          command: |
            . venv/bin/activate
            docker run app:testing
#      - run:
#          name: Build docker compose
#          command: |
#            docker-compose -f docker-compose.test.yml up -d --build
#      - run:
#          name: Run docker compose tests
#          command: |
#            docker-compose -f docker-compose.test.yml up
      - store_artifacts:
          path: test-results/coverage
          destination: coverage
      - store_artifacts:
          path: test-results/nose
          destination: test
      - store_test_results:
          path: test-results/nose
          destination: test

It looks like nothing is in those folders to be saved:

Uploading /app/test-results to tr1
Uploading /app/test-results/coverage/.gitkeep: SKIPPED, file is empty
Uploading /app/test-results/nose/.gitkeep: SKIPPED, file is empty

The only files it’s finding are the .gitkeep files – are the files being saved by the test-runner there to be uploaded? Could you try logging in with SSH and running a find command to verify where the files are being saved?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.