Skip to content

Commit

Permalink
Build in one reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok committed Sep 19, 2023
1 parent d056b26 commit bd33e7e
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 114 deletions.
48 changes: 12 additions & 36 deletions .dx/binaries.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
---
- name: Binaries
hosts: lib
run_once: true
tasks:
- name: Create binaries
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--fail-fast
--batch-mode
--threads 1C
clean
{% if focus == 'solution' %}
deploy
{% else %}
install
{% endif %}
chdir: "{{ playbook_dir }}/../libs"
changed_when: true

- name: Binaries
hosts: app
run_once: true
Expand Down Expand Up @@ -62,25 +41,19 @@
--fail-fast
--batch-mode
--threads 1C
--projects {{ image_status.results|select('changed')|map(attribute='item.app')|join(',') }}
--projects {{ image_status.results|select('changed')|map(attribute='item.app')|map('regex_replace', '^', 'apps/')|join(',') }}
--also-make
clean
{% if focus == 'solution' and up_to_images|default(false) %}
deploy
{% else %}
package
chdir: "{{ playbook_dir }}/../apps"
{% endif %}
chdir: "{{ playbook_dir }}/.."
strip_empty_ends: false
changed_when: true
when: image_status is changed

# {% if hostvars.lib.binary_status|default({}) is changed %}
# --also-make
# {% endif %}
# {% if not up_to_images|default(false) %}
# package
# {% elif focus == 'pipeline' %}
# install
# {% else %}
# deploy
# {% endif %}

- name: Binaries
hosts: test
run_once: true
Expand All @@ -91,8 +64,11 @@
mvn
--no-snapshot-updates
--batch-mode
--projects tools,tests
--also-make
clean
test-compile
chdir: "{{ playbook_dir }}/../tests"
package
chdir: "{{ playbook_dir }}/.."
strip_empty_ends: false
changed_when: true
when: focus == 'pipeline'
24 changes: 11 additions & 13 deletions .dx/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ usage: toy
prefs: turing

lib_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs')[:7] }}"
lib_cids:
client: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs/client')[:7] }}"
construction: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs/construction')[:7] }}"
data: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs/data')[:7] }}"
essentials: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs/essentials')[:7] }}"
messaging: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs/messaging')[:7] }}"
testing: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs/testing')[:7] }}"
app_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=apps')[:7] }}"
app_cids:
foo: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:apps/foo')[:7] }}"
schema_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=schemas')[:7] }}"
schema_cids:
postgres: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=schemas/postgres')[:7] }}"
solution_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=solutions')[:7] }}"

lib_version: 0.1.0-{{ lib_cid }}
Expand All @@ -32,26 +43,13 @@ image_repo: local

app_images:
foo: "{{ image_repo }}/{{ organization }}/{{ project }}/app/foo"

schema_images:
postgres: "{{ image_repo }}/{{ organization }}/{{ project }}/schema/postgres"

stack_images:
solution: "{{ image_repo }}/{{ organization }}/{{ project }}/stack/solution-{{ usage }}-{{ prefs }}"
pipeline: "{{ image_repo }}/{{ organization }}/{{ project }}/stack/pipeline-{{ environ }}"

docker_entity: "{{ 'image' if image_repo == 'local' else 'manifest' }}"

app_cids:
foo: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:apps/foo')[:7] }}"

app_deps:
foo: [essentials, construction, client, messaging, data]

lib_cids:
client: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:libs/client')[:7] }}"
construction: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:libs/construction')[:7] }}"
data: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:libs/data')[:7] }}"
essentials: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:libs/essentials')[:7] }}"
messaging: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:libs/messaging')[:7] }}"
testing: "{{ lookup('ansible.builtin.pipe', 'git rev-parse HEAD:libs/testing')[:7] }}"
24 changes: 13 additions & 11 deletions .dx/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
tasks:
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ item.value }}:{{ schema_cid }}
cmd: docker {{ docker_entity }} inspect {{ schema_images[schema] }}:{{ schema_cids[schema] }}
register: image_status
changed_when: image_status.rc != 0
failed_when: false
loop: "{{ schema_images|dict2items }}"
loop: "{{ schema_images.keys() }}"
loop_control:
label: "{{ item.key }}"
loop_var: schema
- name: Status commands
ansible.builtin.debug:
msg: "{{ image_status.results|map(attribute='cmd')|map('join', ' ') }}"
Expand All @@ -25,11 +25,13 @@
ansible.builtin.include_role:
name: image
vars:
image_tag: "{{ schema_cid }}"
image_name: "{{ item.value }}"
image_home: "{{ playbook_dir }}/../schemas/{{ item.key }}"
image_tag: "{{ schema_cids[schema] }}"
image_name: "{{ schema_images[schema] }}"
image_home: "{{ playbook_dir }}/../schemas/{{ schema }}"
image_push: "{{ focus == 'solution' }}"
loop: "{{ image_status.results|select('changed')|map(attribute='item') }}"
loop: "{{ image_status.results|select('changed')|map(attribute='schema') }}"
loop_control:
loop_var: schema

- name: Images
hosts: app
Expand All @@ -43,17 +45,17 @@
--batch-mode
clean
antrun:run@coverage
chdir: "{{ playbook_dir }}/../.tools"
chdir: "{{ playbook_dir }}/../tools"
strip_empty_ends: false
changed_when: true
when: image_status is changed
- name: Create images
ansible.builtin.include_role:
name: image
vars:
image_tag: "{{ image_cid.stdout[:7] }}"
image_name: "{{ item.value }}"
image_home: "{{ playbook_dir }}/../apps/{{ item.key }}"
image_tag: "{{ item.stdout[:7] }}"
image_name: "{{ app_images[item.app] }}"
image_home: "{{ playbook_dir }}/../apps/{{ item.app }}"
image_context: target/docker-context
image_push: "{{ focus == 'solution' }}"
loop: "{{ image_status.results|select('changed')|map(attribute='item') }}"
Expand Down
29 changes: 4 additions & 25 deletions apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<artifactId>maven-install-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -140,30 +143,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<verbose>true</verbose>
<failOnWarning>true</failOnWarning>
<ignoreUnusedRuntime>true</ignoreUnusedRuntime>
<ignoredUnusedDeclaredDependencies combine.children="append">
<ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter-engine
</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>*:*</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down
19 changes: 0 additions & 19 deletions libs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,25 +430,6 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<verbose>true</verbose>
<failOnWarning>true</failOnWarning>
<ignoreUnusedRuntime>true</ignoreUnusedRuntime>
<ignoredUsedUndeclaredDependencies>
<ignoredUsedUndeclaredDependency>*:*</ignoredUsedUndeclaredDependency>
</ignoredUsedUndeclaredDependencies>
<ignoredUnusedDeclaredDependencies combine.children="append">
<ignoredUnusedDeclaredDependency>org.projectlombok:lombok</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter-engine
</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
<execution>
<id>reset</id>
<phase>clean</phase>
Expand Down
38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<packaging>pom</packaging>

<groupId>smecalculus.bezmen</groupId>
<artifactId>root</artifactId>
<version>latest</version>

<modules>
<module>libs</module>
<module>apps</module>
<module>tools</module>
<module>tests</module>
</modules>

<build>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
11 changes: 1 addition & 10 deletions tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<properties>
<prefs>turing</prefs>
<lib.version>LATEST</lib.version>
<lombok.version>1.18.28</lombok.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -28,20 +27,12 @@
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>libs</artifactId>
<version>${lib.version}</version>
<version>0.1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit bd33e7e

Please sign in to comment.