Skip to content

Commit

Permalink
Feature/library binaries publishing (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok authored Feb 27, 2024
1 parent 9bc3008 commit a39935d
Show file tree
Hide file tree
Showing 21 changed files with 145 additions and 159 deletions.
2 changes: 0 additions & 2 deletions .github/Dockerfile

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/task_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ jobs:
docker run --rm
--volume $(pwd):$(pwd)
--volume ~/.m2:/root/.m2
--env GITHUB_ACTOR=${{ github.actor }}
--env GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
--workdir $(pwd)/baker/ansible
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook binaries.yaml -v
-e devenv=${{ matrix.env.dev }}
-e repo_mode=ro
- uses: mikepenz/[email protected]
if: ${{ !cancelled() && (steps.binaries.outcome == 'success' || steps.binaries.outcome == 'failure') }}
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/work_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
name: Work proposal

on:
merge_group:
branches:
- main
pull_request:
types: [opened, reopened]
branches:
- main
merge_group:
branches:
- main
workflow_dispatch:

env:
Expand Down
50 changes: 43 additions & 7 deletions baker/ansible/binaries.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
---
- name: Building and checking
hosts: app
- name: JVM BINARIES
hosts: jvm
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/java/check.yaml
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/app/build-and-check.yaml
vars:
maven_phase: package
file: tasks/jvm/check.yaml
- name: Capture CID
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') }}
register: binary_cid
changed_when: false
- name: Build, check, publish
ansible.builtin.command:
cmd: >-
mvn {{ maven_phase | default('package') }}
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
--fail-fast
--threads 2
{% if maven_projects is defined %}
--also-make
--projects {{ maven_projects | map('regex_replace', '^', ':') | join(',') }}
{% else %}
--projects -:e2e
{% endif %}
{% if repo_mode == 'rw' %}
--define revision={{ devenv }}-{{ binary_cid.stdout[:7] }}
{% endif %}
chdir: "{{ project.dir }}"
strip_empty_ends: false
changed_when: true
- name: Coverage
ansible.builtin.command:
cmd: >-
mvn clean
antrun:run@coverage
--no-snapshot-updates
--batch-mode
--projects :tool
chdir: "{{ project.dir }}"
strip_empty_ends: false
changed_when: true
39 changes: 15 additions & 24 deletions baker/ansible/images.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Capturing
- name: ALL IMAGES
hosts: images
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
Expand All @@ -8,7 +8,7 @@
tags: [always]
tags: [always]

- name: Building
- name: DATABASE IMAGES
hosts: db
tasks:
- ansible.builtin.import_role: # noqa: name[missing]
Expand All @@ -17,45 +17,36 @@
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='vendor')
| map('regex_replace', '^(.*)$', 'db/\1/' ~ devenv)
| 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: Building and checking
- name: APPLICATION IMAGES
hosts: app
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/java/check.yaml
vars:
maven_projects: >-
{{ image_status.results
| select('changed')
| map(attribute='app')
}}
when: image_status is changed
- 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)
| select('changed')
| map(attribute='app')
| map('regex_replace', '^(.*)$', 'app/\1/' ~ 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
- import_playbook: binaries.yaml # noqa: name[play]
vars:
maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}"
when: hostvars.app.image_status is changed

- name: ALL IMAGES
hosts: images
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
Expand Down
4 changes: 2 additions & 2 deletions baker/ansible/inventory/aliases.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
sources:
hosts:
java:
jvm:
ansible:
github:
yaml:
images:
hosts:
db:
Expand Down
3 changes: 3 additions & 0 deletions baker/ansible/inventory/group_vars/all/stacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ product:
kotlin:
- service: sepuling
name: sepuling-kotlin
libs:
- name: abstraction-client
- name: messaging-client

config_exts:
lightbend_config: conf
Expand Down
2 changes: 1 addition & 1 deletion baker/ansible/sources.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Checking
- name: ALL SOURCES
hosts: sources
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
Expand Down
12 changes: 6 additions & 6 deletions baker/ansible/stacks.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- import_playbook: images.yaml # noqa: name[play]

- name: Capturing
- name: ALL STACKS
hosts: stacks
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
Expand All @@ -10,7 +10,7 @@
tags: [always]
tags: [always]

- name: Building
- name: GEAR STACK
hosts: gear
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
Expand All @@ -24,15 +24,15 @@
stack_status is changed and
is_virtual.rc != 0
- name: Checking
- name: PIPELINE STACK
hosts: pipeline
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/github/check.yaml
file: tasks/yaml/check.yaml
tags: [build]
when: stack_status is changed

- name: Building and checking
- name: PRODUCT STACK
hosts: product
vars:
stack_dir: "{{ project.dir }}/stack/product"
Expand All @@ -50,7 +50,7 @@
hostvars.product.stack_status is changed or
hostvars.gear.stack_status is changed
- name: Publishing
- name: ALL STACKS
hosts: stacks
tasks:
- ansible.builtin.include_tasks: # noqa: name[missing]
Expand Down
43 changes: 0 additions & 43 deletions baker/ansible/tasks/app/build-and-check.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion baker/ansible/tasks/app/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
image_source_tag: "app/{{ app }}:{{ devenv }}"
image_target_tags:
- "{{ image_ns }}/app/{{ app }}:{{ hostvars.app.image_tags[app] }}"
loop: "{{ hostvars.app.image_status.results|select('changed')|map(attribute='app') }}"
loop: "{{ hostvars.app.image_status.results | select('changed') | map(attribute='app') }}"
loop_control:
loop_var: app
2 changes: 1 addition & 1 deletion baker/ansible/tasks/db/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
image_home: "{{ project.dir }}/db/{{ vendor }}"
image_key: "db/{{ vendor }}/{{ devenv }}"
image_tag: "db/{{ vendor }}:{{ devenv }}"
loop: "{{ hostvars.db.image_status.results|select('changed')|map(attribute='vendor') }}"
loop: "{{ hostvars.db.image_status.results | select('changed') | map(attribute='vendor') }}"
loop_control:
loop_var: vendor
2 changes: 1 addition & 1 deletion baker/ansible/tasks/db/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
image_source_tag: "db/{{ vendor }}:{{ devenv }}"
image_target_tags:
- "{{ image_ns }}/db/{{ vendor }}:{{ hostvars.db.image_tags[vendor] }}"
loop: "{{ hostvars.db.image_status.results|select('changed')|map(attribute='vendor') }}"
loop: "{{ hostvars.db.image_status.results | select('changed') | map(attribute='vendor') }}"
loop_control:
loop_var: vendor
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
--batch-mode
--threads 2
{% if maven_projects is defined %}
--projects {{
maven_projects
| map('regex_replace', '^', ':')
| join(',')
}}
--also-make
--projects {{ maven_projects | map('regex_replace', '^', ':') | join(',') }}
{% endif %}
chdir: "{{ project.dir }}"
strip_empty_ends: false
Expand Down
1 change: 1 addition & 0 deletions baker/ansible/tasks/pipeline/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
tasks_from: build
vars:
image_home: "{{ project.dir }}/{{ pipeline.image }}"
image_context: .
image_key: "{{ pipeline.image }}"
image_tag: "{{ pipeline.image }}:{{ devenv }}"

Expand Down
2 changes: 2 additions & 0 deletions baker/ansible/tasks/product/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
ansible.builtin.file:
path: "{{ stack_dir }}/target"
state: absent
changed_when: false

- name: Create directories
ansible.builtin.file:
path: "{{ stack_dir }}/target/image-context"
state: directory
recurse: true
changed_when: false

- name: Build conf
ansible.builtin.template:
Expand Down
File renamed without changes.
41 changes: 11 additions & 30 deletions lib/abstraction-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,15 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>publish</id>
<activation>
<jdk>17</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit a39935d

Please sign in to comment.