Skip to content

Commit

Permalink
feat: Add initial version of Envers (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Dec 15, 2023
1 parent 36b708e commit b07bc47
Show file tree
Hide file tree
Showing 16 changed files with 965 additions and 265 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
run: |
makim tests.unit
- name: Run smoke tests
run: |
makim tests.smoke
- name: Run style checks
run: |
pre-commit install
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ ENV/
# IDE settings
.vscode/
.idea/

.envers/
42 changes: 42 additions & 0 deletions .makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ groups:
mkdocs build --config-file docs/mkdocs.yaml
tests:
env:
TEST_TMP: /tmp/envers

targets:
linter:
help: Run linter tools
Expand All @@ -56,10 +59,49 @@ groups:
run: |
pytest {{ args.path }} {{ args.params }}
smoke-setup:
help: "Smoke test for envers init"
shell: bash
run: |
export TEST_TMP="{{ env.TEST_TMP }}"
rm -rf "${TEST_TMP}"
mkdir -p "${TEST_TMP}"
cd "${TEST_TMP}"
smoke-init:
help: "Smoke test for envers init"
dependencies:
- target: tests.smoke-setup
shell: bash
run: |
export TEST_TMP="{{ env.TEST_TMP }}"
cd "${TEST_TMP}"
envers init
test -f "${TEST_TMP}/.envers/specs.yaml"
smoke-draft:
help: "Smoke test for envers draft"
shell: bash
run: |
export CURRENT_PATH="$(pwd)"
export TEST_DATA="${CURRENT_PATH}/tests/data"
export TEST_TMP="{{ env.TEST_TMP }}"
cd "${TEST_TMP}"
envers init
envers draft 1.0
envers draft 2.0
smoke:
help: "Smoke tests"
dependencies:
- target: tests.smoke-init
- target: tests.smoke-draft

ci:
help: run the sames tests executed on CI
dependencies:
- target: tests.unit
- target: tests.smoke
- target: tests.linter

package:
Expand Down
20 changes: 11 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ repos:

- repo: local
hooks:
# NOTE: This is a total unnecessary check, just used as part of the
# template. Remove this after creating the template.
- id: check-python
name: check-python
entry: python --version

- id: ruff-format
name: ruff-format
entry: ruff format
language: system
pass_filenames: no
pass_filenames: true
files: "./"
types:
- python

- id: ruff
name: ruff
entry: ruff --fix
- id: ruff-check
name: ruff-check
entry: ruff check --fix
language: system
pass_filenames: true
files: "./"
Expand Down
27 changes: 6 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,21 @@ Below are the initial subcommands for `envers`:
Create a new version draft in the spec file. Some variants of this command:
- `envers draft <spec version number> --from <previous spec version number>`
- `envers draft <spec version number> --from-env .env`
- `envers profile set --profile <profile_name> --spec <version_number>`:
- `envers profile-set --profile <profile_name> --spec <version_number>`:
Add new content.
- `envers profile update --profile <profile_name> --spec <version_number>`:
Update existing content.
- `envers profile load --profile prod --spec <spec version>`:
Load a specific environment profile to files
- `envers profile versions --profile <profile_name> --spec <spec version>`:
Return all the version for the contents for a specific profile and
specific spec version

> Note: In some cases, `--spec <spec version>` in the command line is
> can be ommitted, and the latest spec version will be used.
`envers init` creates the spec file at `.envers/.specs.yaml`.


`envers init` creates some files:

- `.envers/.specs.yaml`
- `.envers/.data.lock`

`.envers/.data.lock` shouldn't be changed manually. It is auto-generated by
`envers` command. It is used to check any changes in the
`.envers/.specs.yaml` file.
`envers deploy` creates the file `.envers/.data.lock`. This file is auto-generated by
`envers` command, and it is encrypted.

The initial version of `./.envers/.specs.yaml` would look like this:

```yaml
version: 0.1 # the envers spec version
release:
releases:
```
As you can see, it doesn't have too much information.
Expand All @@ -80,7 +67,7 @@ After this command, the `.envers/specs.yaml` file should look like this:

```yaml
version: 0.1 # the spec version
release:
releases:
# placeholder: the version for the environment variables.
# if the status is draft, feel free to change the version number
1.0:
Expand Down Expand Up @@ -110,7 +97,6 @@ release:
ENV:
type: string # options are: string, int, bool, path
default: dev # in the case that the variable is not defined
encrypted: false # this parameter is optional, by default it is false
```
Now, you can deploy your first version of environment variables:
Expand All @@ -134,7 +120,6 @@ $ envers profile set --profile base --spec 1.0
`envers` will ask you via prompt the value for each variable defined in the
spec for version `1.0`.


## Roadmap

- Integration with Ansible Vault for encryption.
Expand Down
2 changes: 1 addition & 1 deletion conda/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ channels:
dependencies:
- python >=3.8.1,<3.12
- pip
- poetry >=1.5
- poetry 1.5.*
- nodejs # used by semantic-release
- shellcheck
Loading

0 comments on commit b07bc47

Please sign in to comment.