diff --git a/.github/workflows/rootski-ci.yml b/.github/workflows/rootski-ci.yml index 101ec1b6..d40d0e82 100644 --- a/.github/workflows/rootski-ci.yml +++ b/.github/workflows/rootski-ci.yml @@ -41,7 +41,9 @@ jobs: - name: cache dependencies uses: actions/cache@v2 with: - path: ${{ env.pythonLocation }} + path: | + ${{ env.pythonLocation }} + /tmp/.buildx-cache key: ${{ env.pythonLocation }}-${{ hashFiles('**/aws-cdk/**/setup.py', '**/rootski_api/setup.py')}} # cache the python environment for faster pre-commit @@ -66,6 +68,17 @@ jobs: # install docker-compose because it is needed to run the tests make install-docker-compose + - name: Build production image + uses: docker/build-push-action@v2 + with: + context: . + builder: ${{ steps.buildx.outputs.name }} + file: ./rootski_api/tests/ci/Dockerfile + push: false + tags: api_build + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + - name: checkout trunk and current branches run: | # these steps are necessary for darker to compare diffs properly @@ -81,7 +94,7 @@ jobs: # check the code quality across the entire project (formatting, linting, static code checks) make check-code-quality-ci - # run the backend tests + # run the backend tests, commenting this out so we can have githubactions handle it for us cd rootski_api make full-test-ci diff --git a/rootski_api/setup.py b/rootski_api/setup.py index f79d97c5..b5005932 100644 --- a/rootski_api/setup.py +++ b/rootski_api/setup.py @@ -49,6 +49,7 @@ # return: version of the form ``X.X.X`` # """ # return ".dirty" if version.dirty else "" +# adding comment to trigger cache if __name__ == "__main__": setup( diff --git a/rootski_api/tests/ci/Dockerfile b/rootski_api/tests/ci/Dockerfile new file mode 100644 index 00000000..28c819ec --- /dev/null +++ b/rootski_api/tests/ci/Dockerfile @@ -0,0 +1,8 @@ +# The context for this file needs to be path/to/rootski_api +FROM python:3.9.6-slim-buster + +RUN apt-get update && apt-get -y install git make +# RUN apt-get -y install git +WORKDIR /usr/src/rootski_api +COPY . . +RUN make install \ No newline at end of file diff --git a/rootski_api/tests/ci/docker-compose.yml b/rootski_api/tests/ci/docker-compose.yml new file mode 100644 index 00000000..1bd4b6c6 --- /dev/null +++ b/rootski_api/tests/ci/docker-compose.yml @@ -0,0 +1,33 @@ +version: "3.9" + +services: + + rootski: + command: py.test tests/functional_tests/main/endpoints -xv +# command: tail -f /dev/null + image: rootski-api + build: + context: ../.. # rootski_api/ + dockerfile: ./tests/ci/Dockerfile + env_file: + - test.env + volumes: + - ../..:/usr/src/rootski_api + depends_on: + postgres: + condition: service_healthy + + # (1) this database intentionally has no volumes; the database for tests should be fresh + # (2) we run it on port 8432 to avoid accidentally wiping databases running on 5432 + postgres: + image: postgres:9.6 + command: "-p 8432" + env_file: + - test.env + ports: + - "8432:8432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready --username test-user --dbname test_db --port 8432" ] + interval: 1s + timeout: 1s + retries: 6