Skip to content

Commit

Permalink
Introduce dev & ops envs
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok committed Oct 8, 2023
1 parent b3577dd commit 19e53bf
Show file tree
Hide file tree
Showing 31 changed files with 112 additions and 89 deletions.
23 changes: 23 additions & 0 deletions .dx/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
= Окружения

== Эксплуатация (opsenv)

shannon:: Клод Шеннон
lamport:: Лесли Лампорт

== Разработка (devenv)

church:: Алонзо Чёрч
turing:: Алан Тьюринг

== В запасе

brouwer:: Бертус Брауэр
godel:: Курт Гёдель
gentzen:: Герхард Генцен
girard:: Рене Жирар
milner:: Робин Мильнер
martin-lof:: Пер Мартин-Лёф
honda:: Кохэй Хонда
voevodsky:: Владимир Воеводский
nakamoto:: Сатоши Накомото
1 change: 1 addition & 0 deletions .dx/codebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# list all top level playbooks
cmd: >
ansible-lint
toolchain.yaml
codebase.yml
stacks.yml
strip_empty_ends: false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions .dx/envs/ops/lamport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
postgres_version: 16.0
config_mapping_mode: spring_config
config_file_name:
source: lamport.yaml
target: application.yaml
6 changes: 6 additions & 0 deletions .dx/envs/ops/shannon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
postgres_version: 15.4
config_mapping_mode: lightbend_config
config_file_name:
source: shannon.conf
target: application.conf
14 changes: 5 additions & 9 deletions .dx/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
organization: smecalculus
project: bezmen

opsenv: lamport
devenv: turing

usage: toy
prefs: turing

lib_cid: "{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=libs')[:7] }}"
lib_cids:
Expand All @@ -20,16 +22,10 @@ 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 }}
app_version: 0.1.0-{{ app_cid }}

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

# solution - focus on solution changes
Expand All @@ -45,8 +41,8 @@ app_images:
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 }}"
solution: "{{ image_repo }}/{{ organization }}/{{ project }}/stack/solution-{{ usage }}-{{ opsenv }}"
pipeline: "{{ image_repo }}/{{ organization }}/{{ project }}/stack/pipeline-{{ devenv }}"

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

Expand Down
1 change: 1 addition & 0 deletions .dx/inventory/aliases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ stack:
hosts:
solution:
pipeline:
toolchain:
vars:
ansible_connection: local
1 change: 0 additions & 1 deletion .dx/tasks/pipeline/status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
stdin: |
{{ dx_cid }}
{{ tool_cid }}
{{ environ_cid }}
{{ test_cid }}
register: stack_cid
changed_when: false
Expand Down
39 changes: 17 additions & 22 deletions .dx/tasks/solution/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,37 @@
state: directory
recurse: true

- name: Capture env
ansible.builtin.include_vars:
file: envs/ops/{{ opsenv }}.yaml
name: ops

- name: Build conf
ansible.builtin.command:
cmd: >
cp props/{{ ops.config_file_name.source }}
target/context/{{ ops.config_file_name.target }}
chdir: "{{ playbook_dir }}/../solutions"
changed_when: true

- name: Build spec
vars:
config_files:
turing: application.yaml
church: application.conf
config_mapping_modes:
turing: spring_config
church: lightbend_config
ansible.builtin.command:
cmd: >
docker compose
--file usages/basis.yml
--file usages/{{ usage }}.yml
--profile {{ prefs }}
--profile {{ opsenv }}
config
--output target/context/compose.yml
--no-path-resolution
strip_empty_ends: false
chdir: "{{ playbook_dir }}/../solutions"
environment:
POSTGRES_VERSION: "{{ ops.postgres_version }}"
SCHEMA_TAG: "{{ schema_cids.postgres }}"
SCHEMA_IMAGE: "{{ schema_images.postgres }}"
SEPULING_TAG: "{{ hostvars.app.image_cids.sepuling[:7] }}"
SEPULING_IMAGE: "{{ app_images.sepuling }}"
CONFIG_FILE_NAME: "{{ config_files[prefs] }}"
CONFIG_MAPPING_MODE: "{{ config_mapping_modes[prefs] }}"
changed_when: true

- name: Build conf
vars:
config_extensions:
turing: yaml
church: conf
ansible.builtin.command:
cmd: >
cp prefs/{{ prefs }}.{{ config_extensions[prefs] }}
target/context/application.{{ config_extensions[prefs] }}
chdir: "{{ playbook_dir }}/../solutions"
CONFIG_FILE_NAME: "{{ ops.config_file_name.target }}"
CONFIG_MAPPING_MODE: "{{ ops.config_mapping_mode }}"
changed_when: true
7 changes: 3 additions & 4 deletions .dx/tasks/solution/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
# todo: think about backward compatibility aspect
- name: Remove stand (or part of it)
ansible.builtin.command:
cmd: docker rm -f env-db
Expand All @@ -11,7 +10,7 @@
cmd: >
docker compose
--file compose.yml
--profile {{ prefs }}
--profile {{ opsenv }}
up
--remove-orphans
--quiet-pull
Expand All @@ -27,13 +26,13 @@
mvn
--no-snapshot-updates
--batch-mode
--threads 1C
--threads 2
--projects tests/e2e
--activate-profiles {{ usage }}
--also-make
clean
test
--define prefs={{ prefs }}
--define props={{ opsenv }}
{% if reminder is defined %}
--define bezmen.sharding.reminder={{ reminder }}
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
name:
description: Environment name
required: true
default: green
default: turing
tools:
description: Tools to prepare
required: true
Expand All @@ -18,15 +18,15 @@ runs:
- id: dotenv
uses: falti/[email protected]
with:
path: .environs/${{ inputs.name }}/.env
path: .dx/envs/dev/${{ inputs.name }}/.env
- uses: actions/[email protected]
if: ${{ contains(inputs.tools, 'python') }}
with:
python-version: ${{ steps.dotenv.outputs.python_version }}
cache: 'pip'
- shell: bash
if: ${{ contains(inputs.tools, 'python') }}
run: pip install -r .environs/${{ inputs.name }}/requirements.txt
run: pip install -r .dx/envs/dev/${{ inputs.name }}/requirements.txt
- uses: actions/[email protected]
if: ${{ contains(inputs.tools, 'java') }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ updates:
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/.environs/green"
directory: "/.dx/envs/dev/turing"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/.environs/amber"
directory: "/.dx/envs/dev/church"
schedule:
interval: "weekly"
ignore:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pipeline-beyond-doubt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ on:

jobs:
everything:
name: Everything in ${{ matrix.environ.name }} environ
name: Everything in ${{ matrix.devenv.name }} devenv
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
environ:
- name: green
devenv:
- name: turing
os: ubuntu-22.04
- name: amber
- name: church
os: ubuntu-20.04
runs-on: ${{ matrix.environ.os }}
runs-on: ${{ matrix.devenv.os }}
permissions:
packages: write
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/prepare
with:
name: ${{ matrix.environ.name }}
name: ${{ matrix.devenv.name }}
tools: python java docker
token: ${{ secrets.GITHUB_TOKEN }}
- run: ansible-playbook codebase.yml -e focus=pipeline
Expand All @@ -38,7 +38,7 @@ jobs:
ansible-playbook stacks.yml
-e binary_repo=maven.pkg.github.com
-e image_repo=ghcr.io
-e environ=${{ matrix.environ.name }}
-e devenv=${{ matrix.devenv.name }}
-e focus=pipeline
working-directory: .dx
env:
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/pipeline-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ on:
- main
paths: # waiting for https://github.com/actions/runner/issues/2324
- .dx/**
- .environs/**
- .github/**
- tools/**
workflow_dispatch:

jobs:
up-to-binaries:
name: Up to binaries in ${{ matrix.environ.name }} environ
name: Up to binaries in ${{ matrix.devenv.name }} devenv
timeout-minutes: 5
strategy:
matrix:
environ:
- name: green
devenv:
- name: turing
os: ubuntu-22.04
- name: amber
- name: church
os: ubuntu-20.04
runs-on: ${{ matrix.environ.os }}
runs-on: ${{ matrix.devenv.os }}
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/prepare
with:
revision: ${{ matrix.environ.name }}
name: ${{ matrix.devenv.name }}
tools: python java
token: ${{ secrets.GITHUB_TOKEN }}
- run: ansible-playbook codebase.yml -e focus=pipeline
working-directory: .dx
env:
Expand All @@ -38,6 +38,7 @@ jobs:
- run: >
ansible-playbook binaries.yml
-e binary_repo=maven.pkg.github.com
-e devenv=${{ matrix.devenv.name }}
-e focus=pipeline
working-directory: .dx
env:
Expand Down
Loading

0 comments on commit 19e53bf

Please sign in to comment.