Skip to content

Commit

Permalink
ci: fix app-test job, DRY up docker layer cache loading
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Apr 16, 2019
1 parent 3d3e0d8 commit 44e8d06
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ common-steps:
command: |
set +o pipefail
docker images
fromtag=$(docker images |grep securedrop-test-xenial |head -n1 |awk '{print $2}')
cd securedrop && DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-xenial:${fromtag:-latest}" ./bin/dev-shell true
fromtag=$(docker images |grep securedrop-test-xenial-py2 |head -n1 |awk '{print $2}')
cd securedrop && DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-xenial-py2:${fromtag:-latest}" ./bin/dev-shell true
- &saveimagelayers
run:
name: Save Docker image layer cache
command: |
docker images
docker save -o /caches/layers.tar securedrop-test-xenial:latest
docker save -o /caches/layers.tar securedrop-test-xenial-py2:latest
- &savecache
save_cache:
Expand Down Expand Up @@ -73,11 +73,7 @@ jobs:
paths:
- /caches/layers.tar.gz

- run:
name: Load image layer cache
command: |
set +o pipefail
docker load -i /caches/layers.tar |true
- *loadimagelayers

- run:
name: Build Docker image
Expand Down Expand Up @@ -141,9 +137,9 @@ jobs:
name: Run tests
command: |
export TESTFILES=$(cd securedrop; circleci tests glob 'tests/test*py' 'tests/**/test*py' |circleci tests split --split-by=timings |xargs echo)
docker rm -f securedrop-test-xenial || true
fromtag=$(docker images |grep securedrop-test-xenial |head -n1 |awk '{print $2}')
cd securedrop && DOCKER_RUN_ARGUMENTS=$(bash <(curl -s https://codecov.io/env)) DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-xenial:${fromtag:-latest}" make test
docker rm -f securedrop-test-xenial-py2 || true
fromtag=$(docker images |grep securedrop-test-xenial-py2 |head -n1 |awk '{print $2}')
cd securedrop && DOCKER_RUN_ARGUMENTS=$(bash <(curl -s https://codecov.io/env)) DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-xenial-py2:${fromtag:-latest}" make test
- store_test_results:
path: ~/test-results
Expand All @@ -169,11 +165,7 @@ jobs:
paths:
- /caches/layers.tar.gz

- run:
name: Load image layer cache
command: |
set +o pipefail
docker load -i /caches/layers.tar |true
- *loadimagelayers

- run:
name: Build Docker images
Expand Down Expand Up @@ -237,9 +229,9 @@ jobs:
name: Run tests
command: |
export TESTFILES=$(cd securedrop; circleci tests glob 'tests/pageslayout/test*py' |circleci tests split --split-by=timings |xargs echo)
docker rm -f securedrop-test-xenial || true
fromtag=$(docker images |grep securedrop-test-xenial |head -n1 |awk '{print $2}')
cd securedrop && DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-xenial:${fromtag:-latest}" make translation-test
docker rm -f securedrop-test-xenial-py2 || true
fromtag=$(docker images |grep securedrop-test-xenial-py2 |head -n1 |awk '{print $2}')
cd securedrop && DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-xenial-py2:${fromtag:-latest}" make translation-test
- store_test_results:
path: ~/test-results
Expand Down

0 comments on commit 44e8d06

Please sign in to comment.