Skip to content

Commit

Permalink
Feature/api focus (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok authored Mar 2, 2024
1 parent 9c179ac commit 0072477
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 173 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/task_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Task proposal

on:
pull_request:
branches-ignore:
- main
branches-ignore: [main]
workflow_dispatch:

env:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/work_change.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Work change

on:
pull_request:
branches: [main]
types: [synchronize]
branches:
- main
workflow_dispatch:

env:
Expand Down
41 changes: 21 additions & 20 deletions .github/workflows/work_proposal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ name: Work proposal

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

env:
Expand Down Expand Up @@ -75,7 +76,7 @@ jobs:
strategy:
fail-fast: false
matrix:
purpose: [func]
focus: [api]
env:
- dev: godel
ops: marx
Expand All @@ -102,23 +103,23 @@ jobs:
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook stacks.yaml -t build -v
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e focus=${{ matrix.focus }}
-e opsenv=${{ matrix.env.ops }}
-e repo_mode=ro
- uses: actions/[email protected]
with:
name: product-${{ matrix.purpose }}-${{ matrix.env.ops }}
path: stack/product/target/image-context
name: product-${{ matrix.focus }}-${{ matrix.env.ops }}
path: stack/product/target/${{ matrix.focus }}
if-no-files-found: ignore

stack-checking:
name: Stack checking (${{ matrix.shard }}, ${{ matrix.purpose }}, ${{ matrix.env.ops }})
name: Stack checking (${{ matrix.shard }}, ${{ matrix.focus }}, ${{ matrix.env.ops }})
timeout-minutes: 15
needs: [stack-building]
strategy:
fail-fast: false
matrix:
purpose: [func]
focus: [api]
shard: [0, 1]
env:
- dev: godel
Expand All @@ -140,8 +141,8 @@ jobs:
- uses: actions/[email protected]
continue-on-error: true # it's ok because stack building can be skipped
with:
name: product-${{ matrix.purpose }}-${{ matrix.env.ops }}
path: stack/product/target/image-context
name: product-${{ matrix.focus }}-${{ matrix.env.ops }}
path: stack/product/target/${{ matrix.focus }}
- name: Run ansible-playbook stacks.yaml -t check
run: >-
docker run --rm
Expand All @@ -153,26 +154,26 @@ jobs:
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook stacks.yaml -t check -v
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e focus=${{ matrix.focus }}
-e opsenv=${{ matrix.env.ops }}
-e reminder=${{ matrix.shard }}
-e modulus=2
-e repo_mode=ro
- uses: actions/[email protected]
if: ${{ !cancelled() }}
with:
name: e2e-tests-${{ matrix.shard }}-${{ matrix.purpose }}-${{ matrix.env.ops }}
name: e2e-tests-${{ matrix.focus }}-${{ matrix.shard }}-${{ matrix.env.ops }}
path: test/e2e/target/surefire-reports/*.xml
if-no-files-found: ignore

stack-publishing:
name: Stack publishing (${{ matrix.purpose }}, ${{ matrix.env.ops }})
name: Stack publishing (${{ matrix.focus }}, ${{ matrix.env.ops }})
timeout-minutes: 10
needs: [stack-checking]
strategy:
fail-fast: false
matrix:
purpose: [func]
focus: [api]
env:
- dev: godel
ops: marx
Expand All @@ -195,8 +196,8 @@ jobs:
- uses: actions/[email protected]
continue-on-error: true # it's ok because stack building can be skipped
with:
name: product-${{ matrix.purpose }}-${{ matrix.env.ops }}
path: stack/product/target/image-context
name: product-${{ matrix.focus }}-${{ matrix.env.ops }}
path: stack/product/target/${{ matrix.focus }}
- name: Run ansible-playbook stacks.yaml -t publish
run: >-
docker run --rm
Expand All @@ -207,7 +208,7 @@ jobs:
${{ env.IMAGE_NAME }}:${{ matrix.env.dev }}
ansible-playbook stacks.yaml -t publish -v
-e devenv=${{ matrix.env.dev }}
-e purpose=${{ matrix.purpose }}
-e focus=${{ matrix.focus }}
-e opsenv=${{ matrix.env.ops }}
-e repo_mode=rw
Expand Down
3 changes: 1 addition & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ devenv: turing
[source,bash]
----
cd baker/ansible
ansible-playbook sources.yaml
ansible-playbook stacks.yaml
----
. Создаем пул-реквест.
Expand Down Expand Up @@ -75,7 +74,7 @@ ansible-playbook stacks.yaml
- Новый инструмент сборки бинарников. Сейчас только Apache Maven.
- Новый инструмент управления образами. Сейчас только Docker Engine.
- Новый инструмент раскатки стеков. Сейчас только Docker Compose.
- Новое целевое использование (purpose) продукта (product) или снаряжения (gear).
- Новый фокус (focus) продукта (product) или снаряжения (gear).
- Новая обвязка построения дерева хешей. Сейчас связка Git и Ansible.

=== Непредсказуемая сложность
Expand Down
7 changes: 6 additions & 1 deletion baker/ansible/inventory/group_vars/all/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ project:
org: smecalculus
dir: "{{ playbook_dir }}/../.."

repo_mode: n/a # values: rw, ro, n/a

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' }}"

devenv: turing
focus: api
opsenv: durkheim
41 changes: 0 additions & 41 deletions baker/ansible/inventory/group_vars/all/envs.yaml

This file was deleted.

23 changes: 5 additions & 18 deletions baker/ansible/inventory/group_vars/all/stacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ pipeline:
image: stack/pipeline

product:
name: "{{ project.name }}"
image: stack/product
config:
file_name: "application.{{ config_exts[ops[opsenv].config.mapping_mode] }}"
mapping_mode: "{{ ops[opsenv].config.mapping_mode }}"
storages:
postgres:
image: "docker.io/library/postgres"
Expand All @@ -25,18 +21,9 @@ product:
name: "{{ project.name }}"
schemas:
postgres:
- name: sepulkarium
name: sepulkarium
apps:
java:
- service: sepuling
name: sepuling-java
kotlin:
- service: sepuling
name: sepuling-kotlin
libs:
- name: abstraction-client
- name: messaging-client

config_exts:
lightbend_config: conf
spring_config: yaml
sepuling-java:
service: sepuling
sepuling-kotlin:
service: sepuling
11 changes: 0 additions & 11 deletions baker/ansible/inventory/group_vars/all/usages.yaml

This file was deleted.

7 changes: 3 additions & 4 deletions baker/ansible/tasks/app/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
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.name) }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=app/' ~ app) }}
register: image_cid
changed_when: false
loop: "{{ product.apps.values()|flatten }}"
loop: "{{ product.apps.keys() }}"
loop_control:
loop_var: app
label: "{{ app.name }}"

- name: Declare tags
ansible.builtin.set_fact:
Expand All @@ -19,7 +18,7 @@
| map(attribute='stdout')
| map('truncate', 7, True, '')
| map('regex_replace', '^', devenv ~ '-')
| zip(image_cid.results|map(attribute='app.name'))
| zip(image_cid.results|map(attribute='app'))
| map('reverse'))
}}
changed_when: false
Expand Down
10 changes: 5 additions & 5 deletions baker/ansible/tasks/product/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

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

- name: Build conf
ansible.builtin.template:
src: "{{ stack_dir }}/{{ product.config.mapping_mode }}.j2"
dest: "{{ stack_dir }}/target/image-context/application.{{ config_exts[product.config.mapping_mode] }}"
src: "{{ stack_dir }}/focus/{{ focus }}/{{ ops.config.mapping_mode }}.j2"
dest: "{{ stack_dir }}/target/{{ focus }}/{{ ops.config.file_name }}"
lstrip_blocks: yes
trim_blocks: yes
mode: "644"

- name: Build spec
ansible.builtin.template:
src: "{{ stack_dir }}/compose.j2"
dest: "{{ stack_dir }}/target/image-context/compose.yaml"
src: "{{ stack_dir }}/focus/{{ focus }}/compose.j2"
dest: "{{ stack_dir }}/target/{{ focus }}/compose.yaml"
lstrip_blocks: yes
trim_blocks: yes
mode: "644"
10 changes: 8 additions & 2 deletions baker/ansible/tasks/product/capture.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=db') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=lib') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=app') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=stack/product') }}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=stack/product/focus/' ~ focus) }}
{{ lookup('ansible.builtin.pipe', 'git rev-parse :stack/product/env/' ~ opsenv ~ '.yaml') }}
{{ lookup('ansible.builtin.pipe', 'git rev-parse :stack/product/Dockerfile') }}
register: stack_cid
changed_when: false

- name: Declare tag
ansible.builtin.set_fact:
stack_tag: "{{ opsenv }}-{{ stack_cid.stdout[:7] }}"
stack_tag: "{{ focus }}-{{ opsenv }}-{{ stack_cid.stdout[:7] }}"
changed_when: false

- name: Capture statuses
Expand All @@ -24,3 +26,7 @@
- stack_status.rc != 0
loop:
- "{{ product.image }}:{{ stack_tag }}"

- ansible.builtin.include_vars: # noqa: name[missing]
file: "{{ project.dir }}/stack/product/env/{{ opsenv }}.yaml"
name: ops
2 changes: 1 addition & 1 deletion baker/ansible/tasks/product/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
--quiet-pull
--no-deps
--detach
chdir: "{{ stack_dir }}/target/image-context"
chdir: "{{ stack_dir }}/target/{{ focus }}"
strip_empty_ends: false
changed_when: true

Expand Down
2 changes: 1 addition & 1 deletion baker/ansible/tasks/product/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
tasks_from: build
vars:
image_home: "{{ project.dir }}/{{ product.image }}"
image_context: target/image-context
image_context: target/{{ focus }}
image_key: "{{ product.image }}/{{ opsenv }}"
image_tag: "{{ product.image }}:{{ opsenv }}"

Expand Down
10 changes: 10 additions & 0 deletions stack/product/env/commons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
storage:
vendor: postgres
version: 16.0
mapping_mode: spring_data
app:
name: sepuling-java
config:
mapping_mode: spring_config
file_name: application.yaml
10 changes: 10 additions & 0 deletions stack/product/env/durkheim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
storage:
vendor: postgres
version: 15.4
mapping_mode: my_batis
app:
name: sepuling-kotlin
config:
mapping_mode: lightbend_config
file_name: application.conf
10 changes: 10 additions & 0 deletions stack/product/env/marx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
storage:
vendor: postgres
version: 14.9
mapping_mode: my_batis
app:
name: sepuling-java
config:
mapping_mode: lightbend_config
file_name: application.conf
Loading

0 comments on commit 0072477

Please sign in to comment.