diff --git a/.github/workflows/beyond-doubt.yaml b/.github/workflows/beyond-doubt.yaml index fe846adc..7b3b110b 100644 --- a/.github/workflows/beyond-doubt.yaml +++ b/.github/workflows/beyond-doubt.yaml @@ -9,8 +9,6 @@ on: env: IMAGE_NAME: stack/gear - BINARY_REPO: maven.pkg.github.com - IMAGE_REPO: ghcr.io jobs: up-to-images: @@ -57,8 +55,7 @@ jobs: ${{ env.IMAGE_NAME }}:${{ matrix.env.dev }} ansible-playbook images.yaml -v -e devenv=${{ matrix.env.dev }} - -e binary_repo=${{ env.BINARY_REPO }} - -e image_repo=${{ env.IMAGE_REPO }} + -e repo_mode=rw - uses: mikepenz/action-junit-report@v4.1.0 if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }} with: @@ -105,10 +102,10 @@ jobs: run: >- docker run --rm --volume $(pwd):$(pwd) + --volume /var/run/docker.sock:/var/run/docker.sock --workdir $(pwd)/baker/ansible ${{ env.IMAGE_NAME }}:${{ matrix.env.dev }} ansible-playbook stacks.yaml -t build - -e image_repo=${{ env.IMAGE_REPO }} -e devenv=${{ matrix.env.dev }} -e purpose=${{ matrix.purpose }} -e opsenv=${{ matrix.env.ops }} @@ -118,8 +115,8 @@ jobs: path: stack/product/target/image-context if-no-files-found: ignore - stack-testing: - name: Stack testing (${{ matrix.shard }}, ${{ matrix.purpose }}, ${{ matrix.env.ops }}) + stack-checking: + name: Stack checking (${{ matrix.shard }}, ${{ matrix.purpose }}, ${{ matrix.env.ops }}) timeout-minutes: 15 needs: [stack-building] strategy: @@ -149,7 +146,7 @@ jobs: with: name: product-${{ matrix.purpose }}-${{ matrix.env.ops }} path: stack/product/target/image-context - - name: Run ansible-playbook stacks.yaml -t test + - name: Run ansible-playbook stacks.yaml -t check run: >- docker run --rm --network gear @@ -158,8 +155,7 @@ jobs: --volume /var/run/docker.sock:/var/run/docker.sock --workdir $(pwd)/baker/ansible ${{ env.IMAGE_NAME }}:${{ matrix.env.dev }} - ansible-playbook stacks.yaml -t test - -e image_repo=${{ env.IMAGE_REPO }} + ansible-playbook stacks.yaml -t check -e devenv=${{ matrix.env.dev }} -e purpose=${{ matrix.purpose }} -e opsenv=${{ matrix.env.ops }} @@ -175,7 +171,7 @@ jobs: stack-publishing: name: Stack publishing (${{ matrix.purpose }}, ${{ matrix.env.ops }}) timeout-minutes: 10 - needs: [stack-testing] + needs: [stack-checking] strategy: fail-fast: false matrix: @@ -204,7 +200,7 @@ jobs: with: name: product-${{ matrix.purpose }}-${{ matrix.env.ops }} path: stack/product/target/image-context - - name: Run ansible-playbook stacks.yaml -t package + - name: Run ansible-playbook stacks.yaml -t publish run: >- docker run --rm --volume $(pwd):$(pwd) @@ -212,16 +208,16 @@ jobs: --volume ~/.docker/config.json:/root/.docker/config.json:ro --workdir $(pwd)/baker/ansible ${{ env.IMAGE_NAME }}:${{ matrix.env.dev }} - ansible-playbook stacks.yaml -t package -v - -e image_repo=${{ env.IMAGE_REPO }} + ansible-playbook stacks.yaml -t publish -v -e devenv=${{ matrix.env.dev }} -e purpose=${{ matrix.purpose }} -e opsenv=${{ matrix.env.ops }} + -e repo_mode=rw stack-reporting: name: Stack reporting timeout-minutes: 5 - needs: [stack-testing] + needs: [stack-checking] if: ${{ !cancelled() && (contains(needs.*.result, 'success') || contains(needs.*.result, 'failure')) }} runs-on: ubuntu-22.04 permissions: diff --git a/.github/workflows/convincing.yaml b/.github/workflows/convincing.yaml index 7f3bd1ec..31da92e8 100644 --- a/.github/workflows/convincing.yaml +++ b/.github/workflows/convincing.yaml @@ -53,8 +53,7 @@ jobs: ${{ env.IMAGE_NAME }}:${{ matrix.env.dev }} ansible-playbook images.yaml -v -e devenv=${{ matrix.env.dev }} - -e binary_repo=maven.pkg.github.com - -e image_repo=ghcr.io + -e repo_mode=rw - uses: mikepenz/action-junit-report@v4.1.0 if: ${{ !cancelled() && (steps.images.outcome == 'success' || steps.images.outcome == 'failure') }} with: diff --git a/app/pom.xml b/app/pom.xml index 3528c002..4bd6d59d 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -66,8 +66,8 @@ maven-dependency-plugin - dep-copy - package + deps-jars + pre-integration-test copy-dependencies @@ -78,8 +78,8 @@ - lib-copy - package + libs-jars + pre-integration-test copy-dependencies @@ -90,8 +90,8 @@ - app-copy - package + app-jar + pre-integration-test copy @@ -108,6 +108,34 @@ + + org.codehaus.mojo + exec-maven-plugin + + + app-image + pre-integration-test + + exec + + + + + docker + + build + ${project.build.directory}/image-context + --file + ${project.basedir}/Dockerfile + --tag + app/${project.artifactId}:${devenv} + --label + image.key=app/${project.artifactId}/${devenv} + --build-arg + JAVA_RELEASE=${maven.compiler.release} + + + diff --git a/app/sepuling-java/pom.xml b/app/sepuling-java/pom.xml index fbeeee92..03e60aa6 100644 --- a/app/sepuling-java/pom.xml +++ b/app/sepuling-java/pom.xml @@ -56,6 +56,10 @@ org.apache.maven.plugins maven-dependency-plugin + + org.codehaus.mojo + exec-maven-plugin + diff --git a/app/sepuling-kotlin/pom.xml b/app/sepuling-kotlin/pom.xml index 6d9e6721..35e88389 100644 --- a/app/sepuling-kotlin/pom.xml +++ b/app/sepuling-kotlin/pom.xml @@ -77,6 +77,10 @@ org.apache.maven.plugins maven-dependency-plugin + + org.codehaus.mojo + exec-maven-plugin + diff --git a/baker/ansible/binaries.yaml b/baker/ansible/binaries.yaml index ce645e1e..d351e0a8 100644 --- a/baker/ansible/binaries.yaml +++ b/baker/ansible/binaries.yaml @@ -1,71 +1,9 @@ --- -- name: Binaries +- name: Building & Checking hosts: app run_once: true tasks: - - name: Capture cids - ansible.builtin.command: - cmd: git hash-object --stdin - stdin: | - {{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=lib') }} - {{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=app/' ~ app) }} - register: image_cid - changed_when: false - loop: "{{ product.apps.values()|flatten|map(attribute='binary') }}" - loop_control: - loop_var: app - tags: [always] - - name: Declare tags - ansible.builtin.set_fact: - image_tags: >- - {{ dict(image_cid.results - |map(attribute='stdout') - |map('truncate', 7, True, '') - |map('regex_replace', '^', devenv ~ '-') - |zip(image_cid.results|map(attribute='app')) - |map('reverse')) - }} - tags: [always] - - name: Capture statuses - ansible.builtin.command: - cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ app.image }}:{{ image_tags[app.binary] }} - register: image_status - changed_when: - - image_status.rc != 0 - failed_when: false - loop: "{{ product.apps.values()|flatten }}" - loop_control: - loop_var: app - label: "{{ app.binary }}" - tags: [always] - - name: Status commands - ansible.builtin.debug: - msg: "{{ image_status.results|map(attribute='cmd')|map('join', ' ') }}" - when: image_status is changed - tags: [always] - - name: Create binaries - ansible.builtin.command: - cmd: >- - mvn - --no-snapshot-updates - --fail-fast - --batch-mode - --threads 2 - --projects {{ - image_status.results - | select('changed') - | map(attribute='app.binary') - | map('regex_replace', '^', ':') - | join(',') - }} - --also-make - clean - {{ maven_phase | default('package') }} - --define maven.compiler.release={{ dev[devenv].jdk.release }} - {% if dev[devenv].kotlin is defined %} - --define kotlin.version={{ dev[devenv].kotlin.version }} - {% endif %} - chdir: "{{ project.dir }}" - strip_empty_ends: false - changed_when: true - when: image_status is changed + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/app/build-and-check.yaml + vars: + maven_phase: package diff --git a/baker/ansible/images.yaml b/baker/ansible/images.yaml index fd1e97b1..f636db7a 100644 --- a/baker/ansible/images.yaml +++ b/baker/ansible/images.yaml @@ -1,72 +1,57 @@ --- -- import_playbook: binaries.yaml # noqa: name[play] - vars: - maven_phase: "{{ 'install' if binary_repo == 'local' else 'deploy' }}" - tags: [binaries, deps] - -- name: Images +- name: Building hosts: db run_once: true tasks: - - name: Capture statuses - ansible.builtin.command: - cmd: >- - docker {{ docker_entity }} inspect - {{ image_ns }}/{{ product.databases[storage].image }}:{{ product.databases[storage].cid }} - register: image_status - changed_when: image_status.rc != 0 - failed_when: false - loop: "{{ product.schemas.keys() }}" - loop_control: - loop_var: storage - - name: Status commands - ansible.builtin.debug: - msg: "{{ image_status.results|map(attribute='cmd')|map('join', ' ') }}" - when: image_status is changed - - name: Create images - ansible.builtin.include_role: + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/db/capture.yaml + tags: [always] + - ansible.builtin.import_role: # noqa: name[missing] name: image + tasks_from: clean vars: - image_tag: "{{ product.databases[storage].cid }}" - image_name: "{{ image_ns }}/{{ product.databases[storage].image }}" - image_home: "{{ project.dir }}/db/{{ storage }}" - image_key: "{{ product.databases[storage].image }}" - image_push: "{{ image_repo != 'local' }}" - loop: "{{ image_status.results|select('changed')|map(attribute='storage') }}" - loop_control: - loop_var: storage + image_keys: >- + {{ image_status.results + | select('changed') + | map(attribute='db.image') + | map('regex_replace', '$', '/' ~ devenv) + }} + when: image_status is changed + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/db/build.yaml + when: image_status is changed -- name: Images +- name: Building & Checking hosts: app run_once: true tasks: - - name: Analyze coverage - ansible.builtin.command: - cmd: >- - mvn - --no-snapshot-updates - --batch-mode - --projects tool - clean - antrun:run@coverage - chdir: "{{ project.dir }}" - strip_empty_ends: false - changed_when: true - when: image_status is changed - - name: Create images - ansible.builtin.include_role: + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/app/capture.yaml + tags: [always] + - ansible.builtin.import_role: # noqa: name[missing] name: image + tasks_from: clean vars: - image_tag: "{{ image_tags[app.binary] }}" - image_name: "{{ image_ns }}/{{ app.image }}" - image_home: "{{ project.dir }}/app/{{ app.binary }}" - image_context: target/image-context - image_key: "{{ app.image }}/{{ devenv }}" - image_push: "{{ image_repo != 'local' }}" - image_args: - JAVA_RELEASE: "{{ dev[devenv].jdk.release }}" - loop: "{{ image_status.results|select('changed')|map(attribute='app') }}" - loop_control: - loop_var: app - label: "{{ app.binary }}" + image_keys: >- + {{ image_status.results + | select('changed') + | map(attribute='app.image') + | map('regex_replace', '$', '/' ~ devenv) + }} when: image_status is changed + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/app/build-and-check.yaml + vars: + maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}" + when: image_status is changed + +- name: Publishing + hosts: image + run_once: true + tasks: + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/db/publish.yaml + when: hostvars.db.image_status is changed + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/app/publish.yaml + when: hostvars.app.image_status is changed diff --git a/baker/ansible/inventory/aliases.yaml b/baker/ansible/inventory/aliases.yaml index 5230392f..de0868c7 100644 --- a/baker/ansible/inventory/aliases.yaml +++ b/baker/ansible/inventory/aliases.yaml @@ -4,13 +4,14 @@ sources: java: ansible: github: +image: + hosts: + db: + app: stack: hosts: gear: product: all: - hosts: - db: - app: vars: ansible_connection: local diff --git a/baker/ansible/inventory/group_vars/all/all.yaml b/baker/ansible/inventory/group_vars/all/all.yaml new file mode 100644 index 00000000..dae5b31f --- /dev/null +++ b/baker/ansible/inventory/group_vars/all/all.yaml @@ -0,0 +1,13 @@ +--- +project: + name: bezmen + org: smecalculus + dir: "{{ playbook_dir }}/../.." + +binary_repo: maven.pkg.github.com +image_repo: ghcr.io +repo_mode: n/a # values: rw, ro, n/a + +image_ns: "{{ image_repo }}/{{ project.org }}/{{ project.name }}" + +docker_entity: "{{ 'image' if repo_mode == 'n/a' else 'manifest' }}" diff --git a/baker/ansible/inventory/group_vars/all/envs.yaml b/baker/ansible/inventory/group_vars/all/envs.yaml index 21137db5..a292d83b 100644 --- a/baker/ansible/inventory/group_vars/all/envs.yaml +++ b/baker/ansible/inventory/group_vars/all/envs.yaml @@ -1,17 +1,5 @@ --- devenv: turing -dev: - church: - jdk: - release: 21 - kotlin: - version: 2.0.0-Beta4 - turing: - jdk: - release: 21 - godel: - jdk: - release: 17 opsenv: durkheim ops: diff --git a/baker/ansible/inventory/group_vars/all/vars.yaml b/baker/ansible/inventory/group_vars/all/vars.yaml deleted file mode 100644 index a6a18b77..00000000 --- a/baker/ansible/inventory/group_vars/all/vars.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -project: - name: bezmen - org: smecalculus - dir: "{{ playbook_dir }}/../.." - -binary_repo: local -image_repo: local - -image_ns: "{{ image_repo }}/{{ project.org }}/{{ project.name }}" - -docker_entity: "{{ 'image' if image_repo == 'local' else 'manifest' }}" diff --git a/baker/ansible/roles/image/defaults/main.yaml b/baker/ansible/roles/image/defaults/main.yaml index 48f0fa1a..028f44bb 100644 --- a/baker/ansible/roles/image/defaults/main.yaml +++ b/baker/ansible/roles/image/defaults/main.yaml @@ -1,5 +1,3 @@ --- -image_tag: latest image_context: . -image_push: false image_args: {} diff --git a/baker/ansible/roles/image/tasks/build.yaml b/baker/ansible/roles/image/tasks/build.yaml new file mode 100644 index 00000000..39a30b84 --- /dev/null +++ b/baker/ansible/roles/image/tasks/build.yaml @@ -0,0 +1,22 @@ +--- +- name: Check inputs + ansible.builtin.assert: + quiet: true + that: + - image_home is defined + - image_key is defined + - image_tag is defined + +- name: Build image + ansible.builtin.command: + cmd: >- + docker build {{ image_context }} + --file Dockerfile + --label image.key={{ image_key }} + --tag {{ image_tag }} + {% for key, value in image_args.items() %} + --build-arg {{ key }}={{ value }} + {% endfor %} + strip_empty_ends: false + chdir: "{{ image_home }}" + changed_when: true diff --git a/baker/ansible/roles/image/tasks/clean.yaml b/baker/ansible/roles/image/tasks/clean.yaml new file mode 100644 index 00000000..ce462875 --- /dev/null +++ b/baker/ansible/roles/image/tasks/clean.yaml @@ -0,0 +1,22 @@ +--- +- name: Check inputs + ansible.builtin.assert: + quiet: true + that: + - image_keys is defined + +- name: Kill containers + ansible.builtin.shell: + cmd: docker container rm -f $(docker ps -aq --filter label=image.key={{ item }}) + strip_empty_ends: false + changed_when: false + failed_when: false + loop: "{{ image_keys }}" + +- name: Remove images + ansible.builtin.shell: + cmd: docker image rm -f $(docker images -q --filter label=image.key={{ item }}) + strip_empty_ends: false + changed_when: false + failed_when: false + loop: "{{ image_keys }}" diff --git a/baker/ansible/roles/image/tasks/main.yaml b/baker/ansible/roles/image/tasks/main.yaml deleted file mode 100644 index 60d21797..00000000 --- a/baker/ansible/roles/image/tasks/main.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- name: Check vars - ansible.builtin.assert: - quiet: true - that: - - image_name is defined - - image_home is defined - - image_key is defined - -- name: Kill containers - ansible.builtin.shell: - cmd: docker container rm -f $(docker ps -aq --filter label=image.key={{ image_key }}) - strip_empty_ends: false - changed_when: false - failed_when: false - no_log: true - -- name: Remove outdated - ansible.builtin.shell: - cmd: docker image rm -f $(docker images -q --filter label=image.key={{ image_key }}) - strip_empty_ends: false - changed_when: false - failed_when: false - no_log: true - -- name: Build fresh - ansible.builtin.command: - cmd: >- - docker build {{ image_context }} --file Dockerfile - --tag {{ image_name }}:{{ image_tag }} - --label image.key={{ image_key }} - {% for key, value in image_args.items() %} - --build-arg {{ key }}={{ value }} - {% endfor %} - chdir: "{{ image_home }}" - strip_empty_ends: false - changed_when: true - -- name: Push built - ansible.builtin.command: - cmd: docker image push {{ image_name }}:{{ image_tag }} - strip_empty_ends: false - changed_when: true - when: image_push|bool diff --git a/baker/ansible/roles/image/tasks/publish.yaml b/baker/ansible/roles/image/tasks/publish.yaml new file mode 100644 index 00000000..7d65c0f5 --- /dev/null +++ b/baker/ansible/roles/image/tasks/publish.yaml @@ -0,0 +1,22 @@ +--- +- name: Check inputs + ansible.builtin.assert: + quiet: true + that: + - image_source_tag is defined + - image_target_tags is defined + +- name: Tag images + ansible.builtin.command: + cmd: docker tag {{ image_source_tag }} {{ item }} + strip_empty_ends: false + changed_when: true + loop: "{{ image_target_tags }}" + +- name: Push images + ansible.builtin.command: + cmd: docker push {{ item }} + strip_empty_ends: false + changed_when: true + loop: "{{ image_target_tags }}" + when: repo_mode == 'rw' diff --git a/baker/ansible/sources.yaml b/baker/ansible/sources.yaml index b33d9ea5..97a74dcd 100644 --- a/baker/ansible/sources.yaml +++ b/baker/ansible/sources.yaml @@ -1,5 +1,5 @@ --- -- name: Sources +- name: Checking hosts: java run_once: true tasks: @@ -14,16 +14,16 @@ pmd:check compiler:compile spotbugs:check - --define maven.compiler.release={{ dev[devenv].jdk.release }} + --define devenv={{ devenv }} chdir: "{{ project.dir }}" strip_empty_ends: false changed_when: false -- name: Sources +- name: Checking hosts: ansible run_once: true tasks: - - name: Analyze + - name: Linting ansible.builtin.command: # list all top level playbooks cmd: >- @@ -33,11 +33,11 @@ strip_empty_ends: false changed_when: false -- name: Sources +- name: Checking hosts: github run_once: true tasks: - - name: Analyze + - name: Linting ansible.builtin.command: cmd: yamllint {{ project.dir }}/.github strip_empty_ends: false diff --git a/baker/ansible/stacks.yaml b/baker/ansible/stacks.yaml index 90ce5a84..e938da24 100644 --- a/baker/ansible/stacks.yaml +++ b/baker/ansible/stacks.yaml @@ -7,19 +7,25 @@ run_once: true tasks: - ansible.builtin.import_tasks: # noqa: name[missing] - file: tasks/product/status.yaml + file: tasks/product/capture.yaml tags: [always] -- name: Capturing +- name: Capturing & Building hosts: gear run_once: true tasks: - ansible.builtin.import_tasks: # noqa: name[missing] - file: tasks/gear/status.yaml + file: tasks/gear/capture.yaml tags: [always] + - ansible.builtin.import_tasks: # noqa: name[missing] + file: tasks/gear/build.yaml + tags: [build] + when: >- + hostvars.gear.stack_status is changed and + repo_mode != 'rw' -- name: Testing - hosts: stack +- name: Building & Checking + hosts: product run_once: true vars: stack_dir: "{{ project.dir }}/stack/product" @@ -31,26 +37,26 @@ hostvars.product.stack_status is changed or hostvars.gear.stack_status is changed - ansible.builtin.import_tasks: # noqa: name[missing] - file: tasks/product/test.yaml - tags: [test] + file: tasks/product/check.yaml + tags: [check] when: >- hostvars.product.stack_status is changed or hostvars.gear.stack_status is changed -- name: Packaging +- name: Publishing hosts: product run_once: true tasks: - ansible.builtin.import_tasks: # noqa: name[missing] - file: tasks/product/package.yaml - tags: [package] - when: stack_status is changed + file: tasks/product/publish.yaml + tags: [publish] + when: hostvars.product.stack_status is changed -- name: Packaging +- name: Publishing hosts: gear run_once: true tasks: - ansible.builtin.import_tasks: # noqa: name[missing] - file: tasks/gear/package.yaml - tags: [package] - when: stack_status is changed + file: tasks/gear/publish.yaml + tags: [publish] + when: hostvars.gear.stack_status is changed diff --git a/baker/ansible/tasks/app/build-and-check.yaml b/baker/ansible/tasks/app/build-and-check.yaml new file mode 100644 index 00000000..56e9bc16 --- /dev/null +++ b/baker/ansible/tasks/app/build-and-check.yaml @@ -0,0 +1,36 @@ +--- +- name: Build binaries + ansible.builtin.command: + cmd: >- + mvn + --no-snapshot-updates + --batch-mode + --fail-fast + --threads 2 + --projects {{ + image_status.results + | select('changed') + | map(attribute='app.binary') + | map('regex_replace', '^', ':') + | join(',') + }} + --also-make + clean + {{ maven_phase | mandatory }} + --define devenv={{ devenv }} + chdir: "{{ project.dir }}" + strip_empty_ends: false + changed_when: true + +- name: Analyze coverage + ansible.builtin.command: + cmd: >- + mvn + --no-snapshot-updates + --batch-mode + --projects tool + clean + antrun:run@coverage + chdir: "{{ project.dir }}" + strip_empty_ends: false + changed_when: true diff --git a/baker/ansible/tasks/app/capture.yaml b/baker/ansible/tasks/app/capture.yaml new file mode 100644 index 00000000..54e40080 --- /dev/null +++ b/baker/ansible/tasks/app/capture.yaml @@ -0,0 +1,36 @@ +--- +- name: Capture CID's + ansible.builtin.command: + cmd: git hash-object --stdin + stdin: | + {{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=lib') }} + {{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=app/' ~ app.binary) }} + register: image_cid + changed_when: false + loop: "{{ product.apps.values()|flatten }}" + loop_control: + loop_var: app + label: "{{ app.image }}" + +- name: Declare tags + ansible.builtin.set_fact: + image_tags: >- + {{ dict(image_cid.results + | map(attribute='stdout') + | map('truncate', 7, True, '') + | map('regex_replace', '^', devenv ~ '-') + | zip(image_cid.results|map(attribute='app.binary')) + | map('reverse')) + }} + +- name: Capture statuses + ansible.builtin.command: + cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ app.image }}:{{ image_tags[app.binary] }} + register: image_status + changed_when: + - image_status.rc != 0 + failed_when: false + loop: "{{ product.apps.values()|flatten }}" + loop_control: + loop_var: app + label: "{{ app.image }}:{{ image_tags[app.binary] }}" diff --git a/baker/ansible/tasks/app/publish.yaml b/baker/ansible/tasks/app/publish.yaml new file mode 100644 index 00000000..868d701a --- /dev/null +++ b/baker/ansible/tasks/app/publish.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.include_role: # noqa: name[missing] + name: image + tasks_from: publish + vars: + image_source_tag: "{{ app.image }}:{{ devenv }}" + image_target_tags: + - "{{ image_ns }}/{{ app.image }}:{{ hostvars.app.image_tags[app.binary] }}" + loop: "{{ hostvars.app.image_status.results|select('changed')|map(attribute='app') }}" + loop_control: + loop_var: app + label: "{{ app.image }}" diff --git a/baker/ansible/tasks/db/build.yaml b/baker/ansible/tasks/db/build.yaml new file mode 100644 index 00000000..ce645497 --- /dev/null +++ b/baker/ansible/tasks/db/build.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.include_role: # noqa: name[missing] + name: image + tasks_from: build + vars: + image_home: "{{ project.dir }}/{{ db.image }}" + image_key: "{{ db.image }}/{{ devenv }}" + image_tag: "{{ db.image }}:{{ devenv }}" + loop: "{{ hostvars.db.image_status.results|select('changed')|map(attribute='db') }}" + loop_control: + loop_var: db + label: "{{ db.image }}" diff --git a/baker/ansible/tasks/db/capture.yaml b/baker/ansible/tasks/db/capture.yaml new file mode 100644 index 00000000..2c61778d --- /dev/null +++ b/baker/ansible/tasks/db/capture.yaml @@ -0,0 +1,11 @@ +--- +- name: Capture statuses + ansible.builtin.command: + cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ db.image }}:{{ db.cid }} + register: image_status + changed_when: image_status.rc != 0 + failed_when: false + loop: "{{ product.databases.values() }}" + loop_control: + loop_var: db + label: "{{ db.image }}:{{ db.cid }}" diff --git a/baker/ansible/tasks/db/publish.yaml b/baker/ansible/tasks/db/publish.yaml new file mode 100644 index 00000000..c4eb4c87 --- /dev/null +++ b/baker/ansible/tasks/db/publish.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.include_role: # noqa: name[missing] + name: image + tasks_from: publish + vars: + image_source_tag: "{{ db.image }}:{{ devenv }}" + image_target_tags: + - "{{ image_ns }}/{{ db.image }}:{{ db.cid }}" + loop: "{{ hostvars.db.image_status.results|select('changed')|map(attribute='db') }}" + loop_control: + loop_var: db + label: "{{ db.image }}" diff --git a/baker/ansible/tasks/gear/build.yaml b/baker/ansible/tasks/gear/build.yaml index 35232e43..60be7f7b 100644 --- a/baker/ansible/tasks/gear/build.yaml +++ b/baker/ansible/tasks/gear/build.yaml @@ -1,11 +1,15 @@ --- - ansible.builtin.import_role: # noqa: name[missing] name: image + tasks_from: clean vars: - image_tag: "{{ gear_tag }}" - image_name: "{{ image_ns }}/{{ gear.image }}" - image_home: "{{ project.dir }}/stack/gear/{{ devenv }}" + image_keys: + - "{{ gear.image }}/{{ devenv }}" + +- ansible.builtin.import_role: # noqa: name[missing] + name: image + tasks_from: build + vars: + image_home: "{{ project.dir }}/stack/gear" image_key: "{{ gear.image }}/{{ devenv }}" - image_push: false - image_args: - DOCKER_VERSION: "{{ lookup('ansible.builtin.pipe', 'docker version --format {% raw %}{{.Client.Version}}{% endraw %}') }}" # noqa: yaml[line-length] + image_tag: "{{ gear.image }}:{{ devenv }}" diff --git a/baker/ansible/tasks/gear/status.yaml b/baker/ansible/tasks/gear/capture.yaml similarity index 76% rename from baker/ansible/tasks/gear/status.yaml rename to baker/ansible/tasks/gear/capture.yaml index da51e6c3..6b279ce7 100644 --- a/baker/ansible/tasks/gear/status.yaml +++ b/baker/ansible/tasks/gear/capture.yaml @@ -1,5 +1,5 @@ --- -- name: Capture cid +- name: Capture CID ansible.builtin.command: cmd: git hash-object --stdin stdin: | @@ -12,11 +12,11 @@ - name: Declare tag ansible.builtin.set_fact: - gear_tag: "{{ devenv }}-{{ stack_cid.stdout[:7] }}" + stack_tag: "{{ devenv }}-{{ stack_cid.stdout[:7] }}" - name: Capture status ansible.builtin.command: - cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ gear.image }}:{{ gear_tag }} + cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ gear.image }}:{{ stack_tag }} register: stack_status changed_when: - stack_status.rc != 0 @@ -26,3 +26,10 @@ ansible.builtin.debug: msg: "{{ stack_status.cmd|join(' ') }}" when: stack_status is changed + +- name: Capture env + ansible.builtin.command: + cmd: test -f /.dockerenv + register: is_virtual + changed_when: false + failed_when: false diff --git a/baker/ansible/tasks/gear/package.yaml b/baker/ansible/tasks/gear/package.yaml deleted file mode 100644 index d3128bc7..00000000 --- a/baker/ansible/tasks/gear/package.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- ansible.builtin.import_role: # noqa: name[missing] - name: image - vars: - image_tag: "{{ gear_tag }}" - image_name: "{{ image_ns }}/{{ gear.image }}" - image_home: "{{ project.dir }}/stack/gear/{{ devenv }}" - image_key: "{{ gear.image }}/{{ devenv }}" - image_push: "{{ image_repo != 'local' }}" diff --git a/baker/ansible/tasks/gear/publish.yaml b/baker/ansible/tasks/gear/publish.yaml new file mode 100644 index 00000000..794f8781 --- /dev/null +++ b/baker/ansible/tasks/gear/publish.yaml @@ -0,0 +1,8 @@ +--- +- ansible.builtin.import_role: # noqa: name[missing] + name: image + tasks_from: publish + vars: + image_source_tag: "{{ gear.image }}:{{ devenv }}" + image_target_tags: + - "{{ image_ns }}/{{ gear.image }}:{{ hostvars.gear.stack_tag }}" diff --git a/baker/ansible/tasks/product/status.yaml b/baker/ansible/tasks/product/capture.yaml similarity index 86% rename from baker/ansible/tasks/product/status.yaml rename to baker/ansible/tasks/product/capture.yaml index 40450cd5..31959060 100644 --- a/baker/ansible/tasks/product/status.yaml +++ b/baker/ansible/tasks/product/capture.yaml @@ -1,5 +1,5 @@ --- -- name: Capture cid +- name: Capture CID ansible.builtin.command: cmd: git hash-object --stdin stdin: | @@ -12,11 +12,11 @@ - name: Declare tag ansible.builtin.set_fact: - product_tag: "{{ purpose }}-{{ opsenv }}-{{ stack_cid.stdout[:7] }}" + stack_tag: "{{ opsenv }}-{{ stack_cid.stdout[:7] }}" - name: Capture status ansible.builtin.command: - cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ product.image }}:{{ product_tag }} + cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ product.image }}:{{ stack_tag }} register: stack_status changed_when: - stack_status.rc != 0 diff --git a/baker/ansible/tasks/product/test.yaml b/baker/ansible/tasks/product/check.yaml similarity index 92% rename from baker/ansible/tasks/product/test.yaml rename to baker/ansible/tasks/product/check.yaml index 0538730d..34724be1 100644 --- a/baker/ansible/tasks/product/test.yaml +++ b/baker/ansible/tasks/product/check.yaml @@ -34,12 +34,14 @@ --batch-mode --threads 2 --projects test/e2e - {% if image_repo != 'local' %} + {% if hostvars.gear.is_virtual.rc == 0 %} --activate-profiles docker {% endif %} --also-make clean test + --define devenv={{ devenv }} + --define skipUnits=true --define props={{ opsenv }} {% if reminder is defined %} --define testing.sharding.reminder={{ reminder }} @@ -47,8 +49,6 @@ {% if modulus is defined %} --define testing.sharding.modulus={{ modulus }} {% endif %} - --define maven.compiler.release={{ dev[devenv].jdk.release }} - --define skipUnits=true chdir: "{{ project.dir }}" strip_empty_ends: false changed_when: true diff --git a/baker/ansible/tasks/product/package.yaml b/baker/ansible/tasks/product/package.yaml deleted file mode 100644 index 8c589bc0..00000000 --- a/baker/ansible/tasks/product/package.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- ansible.builtin.import_role: # noqa: name[missing] - name: image - vars: - image_tag: "{{ product_tag }}" - image_name: "{{ image_ns }}/{{ product.image }}" - image_home: "{{ project.dir }}/stack/product" - image_context: target/image-context - image_key: "{{ product.image }}/{{ purpose }}-{{ opsenv }}" - image_push: "{{ image_repo != 'local' }}" diff --git a/baker/ansible/tasks/product/publish.yaml b/baker/ansible/tasks/product/publish.yaml new file mode 100644 index 00000000..37f3bece --- /dev/null +++ b/baker/ansible/tasks/product/publish.yaml @@ -0,0 +1,24 @@ +--- +- ansible.builtin.import_role: # noqa: name[missing] + name: image + tasks_from: clean + vars: + image_keys: + - "{{ product.image }}/{{ opsenv }}" + +- ansible.builtin.import_role: # noqa: name[missing] + name: image + tasks_from: build + vars: + image_home: "{{ project.dir }}/stack/product" + image_context: target/image-context + image_key: "{{ product.image }}/{{ opsenv }}" + image_tag: "{{ product.image }}:{{ opsenv }}" + +- ansible.builtin.import_role: # noqa: name[missing] + name: image + tasks_from: publish + vars: + image_source_tag: "{{ product.image }}:{{ opsenv }}" + image_target_tags: + - "{{ image_ns }}/{{ product.image }}:{{ hostvars.product.stack_tag }}" diff --git a/pom.xml b/pom.xml index 64f25b06..4c253e46 100644 --- a/pom.xml +++ b/pom.xml @@ -21,16 +21,57 @@ 1.18.30 1.5.5.Final 6.1.3 - 1.9.22 + 1.8.22 0.8.11 - - false - - ${skipTests} + godel + false + ${skipTests} 17 UTF-8 + + + experimental + + + devenv + church + + + + 21 + 2.0.0-Beta4 + + + + stable + + + devenv + turing + + + + 21 + 1.9.22 + + + + deprecated + + + devenv + godel + + + + 17 + 1.8.22 + + + + @@ -233,6 +274,16 @@ ${skipUnits} + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.1 + + + org.codehaus.mojo + exec-maven-plugin + 3.1.1 + org.apache.maven.plugins maven-failsafe-plugin @@ -284,11 +335,6 @@ - - org.apache.maven.plugins - maven-dependency-plugin - 3.6.1 - org.apache.maven.plugins maven-jar-plugin diff --git a/stack/gear/Dockerfile b/stack/gear/Dockerfile new file mode 100644 index 00000000..65f8bd1e --- /dev/null +++ b/stack/gear/Dockerfile @@ -0,0 +1,3 @@ +# native environment lightweight image +FROM scratch +COPY Dockerfile .