Skip to content

Commit

Permalink
Remove storage when migrations changed (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok authored Feb 24, 2024
1 parent d9ecd7d commit 8c63631
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM scratch
COPY Dockerfile /
COPY Dockerfile .
2 changes: 1 addition & 1 deletion .github/workflows/task_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- uses: mikepenz/[email protected]
if: ${{ !cancelled() && (steps.binaries.outcome == 'success' || steps.binaries.outcome == 'failure') }}
with:
check_name: Unit test report
check_name: Unit tests
report_paths: "**/target/surefire-reports/TEST-*.xml"
require_tests: "${{ steps.binaries.outcome == 'failure' }}"
fail_on_failure: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/work_change.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ jobs:
- uses: mikepenz/[email protected]
if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }}
with:
check_name: Unit test report
check_name: Unit tests
report_paths: "**/target/surefire-reports/TEST-*.xml"
require_tests: "${{ steps.images.outcome == 'failure' }}"
fail_on_failure: false
job_summary: false
- uses: mikepenz/[email protected]
if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }}
with:
check_name: Integration test report
check_name: Integration tests
report_paths: "**/target/failsafe-reports/TEST-*.xml"
require_tests: "${{ steps.images.outcome == 'failure' }}"
fail_on_failure: false
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/work_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ jobs:
with:
devenv: ${{ matrix.env.dev }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run ansible-playbook sources.yaml
run: >-
docker run --rm
--volume $(pwd):$(pwd)
--volume ~/.m2:/root/.m2
--workdir $(pwd)/baker/ansible
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook sources.yaml -v
-e devenv=${{ matrix.env.dev }}
- name: Run ansible-playbook images.yaml
id: images
run: >-
Expand All @@ -54,15 +63,15 @@ jobs:
- uses: mikepenz/[email protected]
if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }}
with:
check_name: Unit test report (${{ matrix.env.dev }})
check_name: Unit tests (${{ matrix.env.dev }})
report_paths: "**/target/surefire-reports/TEST-*.xml"
require_tests: "${{ steps.images.outcome == 'failure' }}"
fail_on_failure: false
job_summary: false
- uses: mikepenz/[email protected]
if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }}
with:
check_name: Integration test report (${{ matrix.env.dev }})
check_name: Integration tests (${{ matrix.env.dev }})
report_paths: "**/target/failsafe-reports/TEST-*.xml"
require_tests: "${{ steps.images.outcome == 'failure' }}"
fail_on_failure: false
Expand Down Expand Up @@ -104,6 +113,7 @@ jobs:
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e opsenv=${{ matrix.env.ops }}
-e repo_mode=ro
- uses: actions/[email protected]
with:
name: product-${{ matrix.purpose }}-${{ matrix.env.ops }}
Expand Down Expand Up @@ -156,10 +166,11 @@ jobs:
-e opsenv=${{ matrix.env.ops }}
-e reminder=${{ matrix.shard }}
-e modulus=2
-e repo_mode=ro
- uses: actions/[email protected]
if: ${{ !cancelled() }}
with:
name: e2e-test-report-${{ matrix.shard }}-${{ matrix.purpose }}-${{ matrix.env.ops }}
name: e2e-tests-${{ matrix.shard }}-${{ matrix.purpose }}-${{ matrix.env.ops }}
path: test/e2e/target/surefire-reports/*.xml
if-no-files-found: ignore

Expand Down Expand Up @@ -223,8 +234,8 @@ jobs:
path: artifacts
- uses: mikepenz/[email protected]
with:
check_name: E2E test report
report_paths: "artifacts/e2e-test-report-*/**/TEST-*.xml"
check_name: End-to-end tests
report_paths: "artifacts/e2e-tests-*/**/TEST-*.xml"
fail_on_failure: false
job_summary: false

Expand Down
4 changes: 2 additions & 2 deletions app/sepuling-java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM eclipse-temurin:${JAVA_RELEASE}-jre-alpine
RUN addgroup -S app && adduser -S app -G app
USER app:app
WORKDIR /home/app
COPY lib lib
COPY bin bin
COPY --chown=app:app lib lib
COPY --chown=app:app bin bin

ENTRYPOINT [ \
"java", "-classpath", "bin/*:lib/*", \
Expand Down
4 changes: 2 additions & 2 deletions app/sepuling-kotlin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM eclipse-temurin:${JAVA_RELEASE}-jre-alpine
RUN addgroup -S app && adduser -S app -G app
USER app:app
WORKDIR /home/app
COPY lib lib
COPY bin bin
COPY --chown=app:app lib lib
COPY --chown=app:app bin bin

ENTRYPOINT [ \
"java", "-classpath", "bin/*:lib/*", \
Expand Down
4 changes: 2 additions & 2 deletions baker/ansible/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{ image_status.results
| select('changed')
| map(attribute='vendor')
| map('regex_replace', '^(.*)$', 'db/\\\1/' ~ devenv)
| map('regex_replace', '^(.*)$', 'db/\1/' ~ devenv)
}}
when: image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
Expand All @@ -39,7 +39,7 @@
{{ image_status.results
| select('changed')
| map(attribute='app')
| map('regex_replace', '^(.*)$', 'app/\\\1/' ~ devenv)
| map('regex_replace', '^(.*)$', 'app/\1/' ~ devenv)
}}
when: image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
Expand Down
2 changes: 1 addition & 1 deletion baker/ansible/roles/image/tasks/clean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

- name: Kill containers
ansible.builtin.shell:
cmd: docker container rm -f $(docker ps -aq --filter label=image.key={{ item }})
cmd: docker container rm -fv $(docker ps -aq --filter label=image.key={{ item }})
strip_empty_ends: false
register: kill_outcome
failed_when: false
Expand Down
2 changes: 1 addition & 1 deletion baker/ansible/stacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
tags: [build]
when: >-
hostvars.gear.stack_status is changed and
repo_mode != 'rw'
hostvars.gear.is_virtual.rc != 0
- name: Building & Checking
hosts: product
Expand Down
2 changes: 1 addition & 1 deletion baker/ansible/tasks/gear/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
stack_tag: "{{ devenv }}-{{ stack_cid.stdout[:7] }}"
changed_when: false

- name: Capture status
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: stack_status
Expand Down
2 changes: 1 addition & 1 deletion baker/ansible/tasks/product/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
stack_tag: "{{ opsenv }}-{{ stack_cid.stdout[:7] }}"
changed_when: false

- name: Capture status
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: stack_status
Expand Down
9 changes: 6 additions & 3 deletions baker/ansible/tasks/product/check.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
---
- name: Remove stand (or part of it)
- name: Remove storages
ansible.builtin.command:
cmd: docker rm -f env-db
cmd: docker container rm -fv storage-{{ vendor }}
changed_when: false
when: hostvars.db.image_status|default({}) is changed
loop: "{{ product.databases.keys() }}"
loop_control:
loop_var: vendor
when: hostvars.db.image_status is changed

- name: Create network
ansible.builtin.shell:
Expand Down
2 changes: 1 addition & 1 deletion stack/product/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM scratch
COPY . /
COPY . .
4 changes: 4 additions & 0 deletions stack/product/compose.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ configs:
{% set database = product.databases[storage.vendor] %}
services:
storage:
container_name: storage-{{ storage.vendor }}
image: {{ storage.image }}:{{ storage.version }}-alpine
networks:
- product
Expand All @@ -30,6 +31,7 @@ services:
retries: 5

database:
container_name: database-{{ database.name }}
image: {{ image_ns }}/db/{{ storage.vendor }}:{{ hostvars.db.image_tags[storage.vendor] }}
networks:
- product
Expand All @@ -55,6 +57,7 @@ services:

{% for schema in product.schemas[storage.vendor] %}
{{ schema.name }}:
container_name: schema-{{ schema.name }}
image: {{ image_ns }}/db/{{ storage.vendor }}:{{ hostvars.db.image_tags[storage.vendor] }}
networks:
- product
Expand All @@ -79,6 +82,7 @@ services:
{% set apps = product.apps[ops[opsenv].app.lang]|selectattr('service', 'in', usages[purpose].apps) %}
{% for app in apps %}
{{ app.service }}:
container_name: app-{{ app.service }}
image: {{ image_ns }}/app/{{ app.name }}:{{ hostvars.app.image_tags[app.name] }}
networks:
- product
Expand Down

0 comments on commit 8c63631

Please sign in to comment.