diff --git a/.github/workflows/commit_checks.yaml b/.github/workflows/commit_checks.yaml index 89cf96a..a79d5f0 100644 --- a/.github/workflows/commit_checks.yaml +++ b/.github/workflows/commit_checks.yaml @@ -49,6 +49,13 @@ jobs: with: python-version: '3.11' + - name: Cache Pip + uses: actions/cache@v3 + id: venv + with: + path: .venv + key: ${{ runner.os }}-venv-${{ hashFiles('poetry.lock') }} + - name: Venv and Setup run: | echo -e "## Python Info\n" >> $GITHUB_STEP_SUMMARY @@ -125,31 +132,29 @@ jobs: echo "CAPTURA_CONFIG_APP=$docker_config_path" >> .env echo "CAPTURA_FLAKEY=/home/captura/flakey.yaml" >> .env + # https://github.com/docker/build-push-action?tab=readme-ov-file#usage + - name: Build Server Image. + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/dockerfile + target: ci + tags: acederberg/captura-ci # should match tags in `./docker/compose.ci.yaml`. + + pull: false + push: false + + cache-from: type=gha,ref=acederberg/captura-ci + cache-to: type=gha,mode=max + - name: Start Docker Compose Project. run: | docker compose \ --file docker/compose.ci.yaml \ --env-file .env \ - up --detach --quiet-pull - - docker compose \ - --file docker/compose.ci.yaml \ - exec server \ - bash -c ' \ - mkdir --parents ~/app/.venv \ - && python -m venv ~/app/.venv' + up --detach --build --quiet-pull # NOTE: ``act.yaml`` defined everything necessary for the client and server. - - name: Install Dependencies In Server. - run: | - docker compose \ - --file docker/compose.ci.yaml \ - exec server \ - bash -c ' \ - source ~/app/.venv/bin/activate \ - && pip install --quiet poetry \ - && poetry install --with test' - - name: Generate Dummy Data In Server. run: | version=$( \ @@ -166,15 +171,15 @@ jobs: && poetry run simulatus initialize \ && poetry run simulatus apply' - echo -e "# Dummy Data Report\n\n~~~" >> $GITHUB_STEP_SUMMARY - docker compose \ - --file docker/compose.ci.yaml \ - exec server \ - bash -c ' \ - source ~/app/.venv/bin/activate \ - && poetry run simulatus --loud reports aggregate' \ - >> $GITHUB_STEP_SUMMARY - echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY + # echo -e "# Dummy Data Report\n\n~~~" >> $GITHUB_STEP_SUMMARY + # docker compose \ + # --file docker/compose.ci.yaml \ + # exec server \ + # bash -c ' \ + # source ~/app/.venv/bin/activate \ + # && poetry run simulatus --loud reports aggregate' \ + # >> $GITHUB_STEP_SUMMARY + # echo -e "~~~\n" >> $GITHUB_STEP_SUMMARY - name: Run Tests. run: | @@ -195,6 +200,7 @@ jobs: bash -c ' \ source ~/app/.venv/bin/activate \ && poetry run coverage html' + continue-on-error: true - name: Stop Compose Project. if: always() diff --git a/docker/compose.ci.yaml b/docker/compose.ci.yaml index 4d5c4ac..f478cb3 100644 --- a/docker/compose.ci.yaml +++ b/docker/compose.ci.yaml @@ -10,6 +10,7 @@ services: extends: file: ./compose.base.yaml service: server + image: acederberg/captura-ci:0.1.5 networks: captura: {} db: diff --git a/docker/compose.yaml b/docker/compose.yaml index 2810674..2169679 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -6,7 +6,7 @@ services: extends: file: ./compose.base.yaml service: server - image: acederberg/captura-ci:0.1.5 + image: acederberg/captura-development:0.1.5 networks: captura: {} volumes: diff --git a/docker/dockerfile b/docker/dockerfile index 0ad9620..a4db67d 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -29,7 +29,7 @@ COPY ./docker/docker.sh /home/captura/.bashrc # --------------------------------------------------------------------------- # -FROM base AS ci +FROM base AS base_w_repo # NOTE: Assumes that build is occuring at the project root. COPY --chown=captura:captura ./ /home/captura/app @@ -37,7 +37,17 @@ COPY --chown=captura:captura ./ /home/captura/app # --------------------------------------------------------------------------- # -FROM ci AS production +FROM base_w_repo AS ci + +RUN mkdir --parents /home/captura/app/.venv \ + && python -m venv /home/captura/app/.venv \ + && .venv/bin/python3 -m pip install --quiet poetry \ + && .venv/bin/python3 -m poetry install --with test + + +# --------------------------------------------------------------------------- # + +FROM base_w_repo AS production RUN mkdir /home/captura/.captura /home/captura/.captura/logs COPY ./docker/logging.yaml /home/captura/.captura diff --git a/pyproject.toml b/pyproject.toml index 972c1ce..60ca522 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -142,7 +142,8 @@ push = false [tool.bumpver.file_patterns] "pyproject.toml" = ['current_version = "{version}"', 'version = "{version}"'] "src/app/__init__.py" = ["{version}"] -"docker/docker-compose.yaml" = ["image: acederberg/captura-development:{version}"] +"docker/compose.yaml" = ["image: acederberg/captura-development:{version}"] +"docker/compose.ci.yaml" = ["image: acederberg/captura-ci:{version}"] [tool.setuptools_scm]