Skip to content

Commit

Permalink
Chore/tools change detection (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok authored Mar 30, 2024
1 parent cf60926 commit ee7ef78
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 103 deletions.
5 changes: 3 additions & 2 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>smecalculus.bezmen</groupId>
<artifactId>bezmen</artifactId>
<version>latest</version>
<version>${revision}</version>
</parent>

<artifactId>app</artifactId>
Expand Down Expand Up @@ -100,8 +100,9 @@
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
<outputDirectory>${project.build.directory}/image/bin</outputDirectory>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
</configuration>
Expand Down
12 changes: 0 additions & 12 deletions app/sepuling-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>${kotlin.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down
59 changes: 19 additions & 40 deletions lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>smecalculus.bezmen</groupId>
<artifactId>bezmen</artifactId>
<version>latest</version>
<version>${revision}</version>
</parent>

<artifactId>lib</artifactId>
Expand All @@ -27,13 +27,6 @@
<spring-boot.version>3.2.4</spring-boot.version>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/smecalculus/bezmen</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -52,37 +45,37 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>abstraction-client</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>abstraction</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>essentials</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>messaging-client</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>messaging</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>storage</artifactId>
<version>${project.version}</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>testing</artifactId>
<version>latest</version>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -94,6 +87,13 @@
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-bom</artifactId>
<version>1.9.22</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
Expand Down Expand Up @@ -246,31 +246,10 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>capture</id>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>abstraction-client</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>messaging-client</artifactId>
<version>${project.version}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Expand Down
4 changes: 1 addition & 3 deletions orchestrator/ansible/binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
cmd: git hash-object --stdin
stdin: |
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=lib') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=app') }}
register: binary_cid
changed_when: false
- name: Build, check, publish
Expand All @@ -36,8 +35,7 @@
- name: Coverage
ansible.builtin.command:
cmd: >-
mvn clean
antrun:run@coverage
mvn antrun:run@coverage
--no-snapshot-updates
--batch-mode
--projects :tool
Expand Down
41 changes: 7 additions & 34 deletions orchestrator/ansible/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,17 @@
apply:
tags: [always]
tags: [always]
- ansible.builtin.include_tasks: # noqa: name[missing]
file: tasks/{{ inventory_hostname }}/build.yaml
when: hostvars[inventory_hostname].image_status is changed

- name: DATABASE IMAGES
hosts: db
tasks:
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: clean
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='vendor')
| map('regex_replace', '^(.*)$', 'db/\1/' ~ devenv)
}}
when: image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/db/build.yaml
when: image_status is changed

- name: APPLICATION IMAGES
hosts: app
tasks:
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: clean
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='app')
| map('regex_replace', '^(.*)$', 'app/\1/' ~ devenv)
}}
when: image_status is changed

# building everything without exception otherwise purely external libs will not be published
- import_playbook: binaries.yaml # noqa: name[play]
vars:
maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}"
when: hostvars.app.image_status is changed
when: >-
hostvars.app.image_status is changed or
hostvars.tool.image_status is changed
- name: ALL IMAGES
hosts: images
Expand Down
1 change: 1 addition & 0 deletions orchestrator/ansible/inventory/aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ images:
hosts:
db:
app:
tool:
stacks:
hosts:
gear:
Expand Down
11 changes: 11 additions & 0 deletions orchestrator/ansible/tasks/app/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: clean
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='app')
| map('regex_replace', '^(.*)$', 'app/\1/' ~ devenv)
}}
11 changes: 11 additions & 0 deletions orchestrator/ansible/tasks/db/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: clean
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='vendor')
| map('regex_replace', '^(.*)$', 'db/\1/' ~ devenv)
}}
- ansible.builtin.include_role: # noqa: name[missing]
name: image
tasks_from: build
Expand Down
2 changes: 0 additions & 2 deletions orchestrator/ansible/tasks/gear/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
{{ lookup('ansible.builtin.pipe', 'git rev-parse :pom.xml') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=tool') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=test') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=orchestrator') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=stack/gear/env/' ~ devenv) }}
Expand Down
16 changes: 16 additions & 0 deletions orchestrator/ansible/tasks/tool/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: clean
vars:
image_keys:
- "tool/builder/{{ devenv }}"

- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: build
vars:
image_home: "{{ project.dir }}/tool"
image_context: .
image_key: "tool/builder/{{ devenv }}"
image_tag: "tool/builder:{{ devenv }}"
24 changes: 24 additions & 0 deletions orchestrator/ansible/tasks/tool/capture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: Capture CID
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
{{ lookup('ansible.builtin.pipe', 'git rev-parse :pom.xml') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=tool') }}
register: package_cid
changed_when: false

- name: Declare tag
ansible.builtin.set_fact:
package_tag: "{{ devenv }}-{{ package_cid.stdout[:7] }}"
changed_when: false

- name: Capture status
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ image_ns }}/{{ item }}
register: image_status
failed_when: false
changed_when:
- image_status.rc != 0
loop:
- "tool/builder:{{ package_tag }}"
8 changes: 8 additions & 0 deletions orchestrator/ansible/tasks/tool/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- ansible.builtin.import_role: # noqa: name[missing]
name: image
tasks_from: publish
vars:
image_source_tag: "tool/builder:{{ devenv }}"
image_target_tags:
- "{{ image_ns }}/tool/builder:{{ hostvars.tool.package_tag }}"
Loading

0 comments on commit ee7ef78

Please sign in to comment.