Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module and package structure #129

Merged
merged 34 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6918983
Rename core to essentials; rename service to domain
pavetok Sep 12, 2023
2c161de
Drop 'org' from package namespace
pavetok Sep 12, 2023
551326f
Try to create checks
pavetok Sep 16, 2023
e56ed0b
Skip codebase checks
pavetok Sep 16, 2023
d0fc46a
Add checks permission
pavetok Sep 16, 2023
39a953f
Add head sha
pavetok Sep 16, 2023
7922cfd
Single check
pavetok Sep 16, 2023
8eb6fc0
Two checks
pavetok Sep 16, 2023
43b5c75
Try to require tests in case of failure
pavetok Sep 16, 2023
cf5ae2c
Add quotes
pavetok Sep 16, 2023
14a95ec
Check outcome
pavetok Sep 16, 2023
d1913ac
One report path
pavetok Sep 16, 2023
ee5996e
Test check failure
pavetok Sep 16, 2023
1b1e39c
Test check cancel
pavetok Sep 17, 2023
7a33fe0
Fix or operator
pavetok Sep 17, 2023
9e2a32e
Test fail on empty
pavetok Sep 17, 2023
7eaf38a
Test fail on empty 2
pavetok Sep 17, 2023
66077c9
Test fail on empty 3
pavetok Sep 17, 2023
ce11175
Test fail on empty 4
pavetok Sep 17, 2023
feb8cb9
Test fail on empty 5
pavetok Sep 17, 2023
9de9022
Adapt workflows
pavetok Sep 17, 2023
0bb9e7e
Different reactors and snapshot version
pavetok Sep 18, 2023
ea4dd8c
Hardcode lib version
pavetok Sep 18, 2023
e23d5e6
Skip sources analyze
pavetok Sep 18, 2023
b664e4f
Enable sources analyze
pavetok Sep 18, 2023
d056b26
Offline not suitable
pavetok Sep 18, 2023
bd33e7e
Build in one reactor
pavetok Sep 19, 2023
e35bec5
Run tests with also-make
pavetok Sep 19, 2023
98df39f
Remove dependency analyze
pavetok Sep 19, 2023
c47dce0
Adapt codebase checking
pavetok Sep 20, 2023
879137f
Refactor codebase checking
pavetok Sep 20, 2023
6644261
Fix workflow syntax error
pavetok Sep 20, 2023
0ea2977
Need stack testing
pavetok Sep 20, 2023
e15884d
Always declare cid's
pavetok Sep 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 31 additions & 62 deletions .dx/binaries.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,36 @@
---
- name: Binaries
hosts: lib
run_once: true
tasks:
- name: Capture status
ansible.builtin.command:
# todo: try to implement more lightweight check
cmd: >
mvn
{% if binary_repo == 'local' %}
--offline
{% else %}
--define remoteRepositories=github::::https://{{ binary_repo }}/smecalculus/bezmen
{% endif %}
dependency:get
--define transitive=false
--define artifact=org.smecalculus.bezmen:libs:{{ lib_version }}:pom
chdir: "{{ playbook_dir }}/../libs"
register: binary_status
changed_when: binary_status.rc != 0
failed_when: false
- name: Status command
ansible.builtin.debug:
msg: "{{ binary_status.cmd|join(' ') }}"
when: binary_status is changed
- 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 %}
--define revision={{ lib_version }}
chdir: "{{ playbook_dir }}/../libs"
changed_when: true
when: binary_status is changed

- name: Binaries
hosts: app
run_once: true
tasks:
- name: Capture cid
- name: Capture cid's
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
{{ lib_cid }}
{{ app_cid }}
{{ app_cids[app] }}
{% for lib in app_deps[app] %}
{{ lib_cids[lib] }}
{% endfor %}
# TODO: try to choose better name
register: image_cid
changed_when: false
loop: "{{ app_images.keys() }}"
loop_control:
loop_var: app
tags: [always]
- name: Declare cid's
ansible.builtin.set_fact:
image_cids: "{{ image_cid.results|items2dict(key_name='app', value_name='stdout') }}"
tags: [always]
- name: Capture statuses
ansible.builtin.command:
cmd: docker {{ docker_entity }} inspect {{ item.value }}:{{ image_cid.stdout[:7] }}
cmd: docker {{ docker_entity }} inspect {{ app_images[app] }}:{{ image_cids[app][:7] }}
register: image_status
changed_when: image_status.rc != 0
failed_when: false
loop: "{{ app_images|dict2items }}"
loop: "{{ image_cids.keys() }}"
loop_control:
label: "{{ item.key }}"
loop_var: app
tags: [always]
- name: Status commands
ansible.builtin.debug:
Expand All @@ -80,18 +45,21 @@
--fail-fast
--batch-mode
--threads 1C
{% if not hostvars.lib.binary_status|default({}) is changed %}
--projects {{ image_status.results|select('changed')|map(attribute='item.key')|join(',') }}
{% endif %}
--projects {{
image_status.results
| select('changed')
| map(attribute='app')
| map('regex_replace', '^', 'apps/')
| join(',')
}}
--also-make
clean
{% if up_to_images|default(false) %}
verify
{% if focus == 'solution' and up_to_images|default(false) %}
deploy
{% else %}
package
{% endif %}
--define revision={{ app_version }}
--define lib.version={{ lib_version }}
chdir: "{{ playbook_dir }}/../apps"
chdir: "{{ playbook_dir }}/.."
strip_empty_ends: false
changed_when: true
when: image_status is changed
Expand All @@ -106,10 +74,11 @@
mvn
--no-snapshot-updates
--batch-mode
--projects tools,tests
--also-make
clean
test-compile
--define lib.version={{ lib_version }}
chdir: "{{ playbook_dir }}/../tests"
package
chdir: "{{ playbook_dir }}/.."
strip_empty_ends: false
changed_when: true
when: hostvars.lib.binary_status|default({}) is changed
when: focus == 'pipeline'
18 changes: 15 additions & 3 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 @@ -18,7 +29,7 @@ test_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=tests')[:7
environ: green

dx_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=.dx')[:7] }}"
tool_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=.tools')[:7] }}"
tool_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=tools')[:7] }}"
environ_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=.environs/' ~ environ)[:7] }}"
pipeline_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=.github')[:7] }}"

Expand All @@ -32,12 +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_deps:
foo: [essentials, construction, client, messaging, data]
28 changes: 16 additions & 12 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,18 +45,20 @@
--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: "{{ image_cids[app][:7] }}"
image_name: "{{ app_images[app] }}"
image_home: "{{ playbook_dir }}/../apps/{{ app }}"
image_context: target/docker-context
image_push: "{{ focus == 'solution' }}"
loop: "{{ image_status.results|select('changed')|map(attribute='item') }}"
loop: "{{ image_status.results|select('changed')|map(attribute='app') }}"
loop_control:
loop_var: app
when: image_status is changed
9 changes: 7 additions & 2 deletions .dx/inventory/aliases.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
---
all:
hosts:
lib:
app:
schema:
test:
dx:
vars:
ansible_connection: local
codebase:
hosts:
java:
ansible:
github:
vars:
ansible_connection: local
stack:
Expand Down
53 changes: 18 additions & 35 deletions .dx/sources.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Sources
hosts: lib
- name: Codebase
hosts: java
run_once: true
tasks:
- name: Analyze
Expand All @@ -9,44 +9,20 @@
mvn
--no-snapshot-updates
--batch-mode
{% if focus == 'solution' %}
--projects apps/foo
{% elif focus == 'pipeline' %}
--projects tests/e2e
{% endif %}
--also-make
enforcer:enforce
spotless:check
chdir: "{{ playbook_dir }}/../libs"
chdir: "{{ playbook_dir }}/.."
strip_empty_ends: false
changed_when: false

- name: Sources
hosts: app
run_once: true
tasks:
- name: Analyze
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--batch-mode
spotless:check
chdir: "{{ playbook_dir }}/../apps"
strip_empty_ends: false
changed_when: false

- name: Sources
hosts: test
run_once: true
tasks:
- name: Analyze
ansible.builtin.command:
cmd: >
mvn
--no-snapshot-updates
--batch-mode
spotless:check
chdir: "{{ playbook_dir }}/../tests"
strip_empty_ends: false
changed_when: false

- name: Sources
hosts: pipeline
- name: Codebase
hosts: ansible
run_once: true
tasks:
- name: Analyze
Expand All @@ -58,8 +34,15 @@
stacks.yml
strip_empty_ends: false
changed_when: false
when: focus != 'solution'

- name: Codebase
hosts: github
run_once: true
tasks:
- name: Analyze
ansible.builtin.command:
cmd: yamllint ../.github
strip_empty_ends: false
changed_when: false
when: focus != 'solution'
4 changes: 2 additions & 2 deletions .dx/tasks/solution/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
strip_empty_ends: false
chdir: "{{ playbook_dir }}/../solutions"
environment:
SCHEMA_TAG: "{{ schema_cid }}"
SCHEMA_TAG: "{{ schema_cids.postgres }}"
SCHEMA_IMAGE: "{{ schema_images.postgres }}"
FOO_TAG: "{{ hostvars.app.image_cid.stdout[:7] }}"
FOO_TAG: "{{ hostvars.app.image_cids.foo[:7] }}"
FOO_IMAGE: "{{ app_images.foo }}"
changed_when: true

Expand Down
10 changes: 6 additions & 4 deletions .dx/tasks/solution/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@
mvn
--no-snapshot-updates
--batch-mode
--projects e2e
--threads 1C
--projects tests/e2e
--activate-profiles {{ usage }}
--define lib.version={{ lib_version }}
--also-make
clean
test
--define prefs={{ prefs }}
{% if test_failure_ignore is defined %}
--define maven.test.failure.ignore={{ test_failure_ignore }}
{% endif %}
--define prefs={{ prefs }}
{% if reminder is defined %}
--define bezmen.sharding.reminder={{ reminder }}
{% endif %}
{% if modulus is defined %}
--define bezmen.sharding.modulus={{ modulus }}
{% endif %}
chdir: "{{ playbook_dir }}/../tests"
--define skipUnits=true
chdir: "{{ playbook_dir }}/.."
strip_empty_ends: false
changed_when: true
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ updates:
schedule:
interval: "weekly"
ignore:
- dependency-name: "org.smecalculus.bezmen:*"
- dependency-name: "smecalculus.bezmen:*"
- package-ecosystem: "maven"
directory: "/tests"
schedule:
interval: "weekly"
ignore:
- dependency-name: "org.smecalculus.bezmen:*"
- dependency-name: "smecalculus.bezmen:*"
- package-ecosystem: "maven"
directory: "/.tools"
directory: "/tools"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
Expand Down
Loading