Skip to content

Commit 1e68724

Browse files
authored
Refactor Project Structure and Makefile Targets (vitabaks#357)
* 🔧 chore(config): add yamllint and ansible-lint configuration files ✨ feat(config): add make targets for testing and bootstrapping development environment 🔧 chore(config): move dev requirements to a separate file 🔧 chore(config): update make targets to include development environment The commit adds configuration files for yamllint and ansible-lint. It also adds make targets for testing and bootstrapping the development environment. The development environment is now bootstrapped separately from the production environment. The make targets have been updated to include the development environment. The dev requirements have been moved to a separate file. * 🔥 chore(workflows): remove Ansible-lint and Yamllint workflows ✨ feat(workflows): add linters workflow to run all linters and improve code quality The Ansible-lint and Yamllint workflows have been removed as they are no longer needed. A new linters workflow has been added to run all linters and improve code quality. This new workflow runs on every push and pull request to the master branch. It sets the TERM environment variable, checks out the code, sets up Python 3.10, installs dependencies, and runs all linters using the `make lint` command. * ✨ chore(github): add Ansible-lint, Flake8, and Yamllint workflows to improve code quality The Ansible-lint, Flake8, and Yamllint workflows have been added to the project to improve code quality. These workflows will run on every push and pull request to the master branch. The Ansible-lint workflow checks for syntax errors and best practices in Ansible code, the Flake8 workflow checks for PEP8 compliance and other code quality issues in Python code, and the Yamllint workflow checks for syntax errors and best practices in YAML files. The README.md file has also been updated to reflect the changes in the project. * 🔀 chore(README.md): reformat index and cluster types sections for better readability The index and cluster types sections were reformatted to improve readability and make it easier to navigate the document. The changes include removing unnecessary characters, reordering the sections, and changing the formatting of the sub-sections. 🎨 style(README.md): reformat table for better readability The table was reformatted to improve readability and make it easier to compare the test results across different distributions. * 📝 chore(README.md): reformat table of test results for better readability The table of test results has been reformatted to improve readability. The table now has a cleaner look and is easier to read.
1 parent e69f203 commit 1e68724

29 files changed

+115
-50
lines changed

Diff for: .yamllint renamed to .config/.yamllint

File renamed without changes.

Diff for: .ansible-lint renamed to .config/ansible-lint.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
skip_list:
23
- yaml
34
- role-name
@@ -25,7 +26,7 @@ skip_list:
2526
- var-naming[no-role-prefix]
2627

2728
exclude_paths:
28-
- roles/consul/ # TODO - https://github.com/ansible-community/ansible-consul/pull/520
29-
- .venv
29+
- ../roles/consul/ # TODO - https://github.com/ansible-community/ansible-consul/pull/520
30+
- ../.venv
3031
# https://ansible-lint.readthedocs.io/configuring/
3132
# https://ansible-lint.readthedocs.io/rules/

Diff for: .config/make/docker.mak

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ docker-build: ## Run docker build image in local
55

66
.PHONY: docker-lint
77
docker-lint: ## Run hadolint command to lint Dokerfile
8-
docker run --rm -i hadolint/hadolint < .config/gitpod/Dockerfile
8+
docker run --rm -i hadolint/hadolint < .config/gitpod/Dockerfile
9+
10+
.PHONY: docker-tests
11+
docker-tests: ## Run tests for docker
12+
$(MAKE) docker-build
13+
$(MAKE) docker-lint

Diff for: .config/make/linters.mak

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ACTIVATE_VENV = source .venv/bin/activate
55

66
# Configuration files
7-
YAMLLINT_CONFIG = .yamllint
7+
YAMLLINT_CONFIG = .config/.yamllint
88
FLAKE8_CONFIG = .config/.flake8
99

1010
.PHONY: linter-yamllint
@@ -17,7 +17,7 @@ linter-yamllint: ## Lint YAML files using yamllint
1717
linter-ansible-lint: ## Lint Ansible files using ansible-lint
1818
echo "ansible-lint #########################################################"
1919
$(ACTIVATE_VENV) && \
20-
ansible-lint --force-color --offline --parseable
20+
ansible-lint --force-color --parseable
2121

2222
.PHONY: linter-flake8
2323
linter-flake8: ## Lint Python files using flake8

Diff for: .config/make/python.mak

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Python default launcher
22
python_launcher ?= python3.10
33
python_requirements_file ?= requirements.txt
4-
python_requirements_dev_file ?= .config/requirements.dev.txt
4+
python_requirements_dev_file ?= .config/python/dev/requirements.txt
55

66
## —— Python —————————————————————————————————————————————————————————————————————————————————————
77
.PHONY: python-bootstrap
File renamed without changes.

Diff for: .github/workflows/ansible-lint.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: Ansible-lint
2+
name: "Ansible-lint"
33

44
on:
55
push:
@@ -17,10 +17,16 @@ jobs:
1717
- name: Set TERM environment variable
1818
run: echo "TERM=xterm" >> $GITHUB_ENV
1919

20-
- name: Git clone repo postgresql_cluster
21-
uses: actions/checkout@v2
20+
- name: Checkout
21+
uses: actions/checkout@v3
2222

23-
- name: Lint Ansible Playbook
24-
uses: ansible/ansible-lint-action@v6
23+
- name: Set up Python 3.10
24+
uses: actions/setup-python@v4
2525
with:
26-
path: "roles/"
26+
python-version: "3.10"
27+
28+
- name: Install dependencies
29+
run: make bootstrap-dev
30+
31+
- name: Run Ansible-lint
32+
run: make linter-ansible-lint

Diff for: .github/workflows/flake8.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: "Flake8"
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
branches:
10+
- master
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Set TERM environment variable
18+
run: echo "TERM=xterm" >> $GITHUB_ENV
19+
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Python 3.10
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.10"
27+
28+
- name: Install dependencies
29+
run: make bootstrap-dev
30+
31+
- name: Run Flake8
32+
run: make linter-flake8

Diff for: .github/workflows/molecule.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
python-version: "3.10"
7373

7474
- name: Install dependencies
75-
run: make bootstrap
75+
run: make bootstrap-dev
7676

7777
- name: Run Molecule tests
7878
run: make molecule-test

Diff for: .github/workflows/molecule_pgpro.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
python-version: "3.10"
3333

3434
- name: Install dependencies
35-
run: make bootstrap
35+
run: make bootstrap-dev
3636

3737
- name: Run Molecule tests for PostgresPro
3838
run: make molecule-test-scenario

Diff for: .github/workflows/schedule_pg_almalinux8.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_almalinux9.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_centos8.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_centosstream8.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_centosstream9.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_debian10.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_debian11.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_oracle_linux8.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_oracle_linux9.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_rockylinux8.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_rockylinux9.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_ubuntu1804.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_ubuntu2004.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/schedule_pg_ubuntu2204.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: "3.10"
2323

2424
- name: Install dependencies
25-
run: make bootstrap
25+
run: make bootstrap-dev
2626

2727
- name: Run Molecule tests
2828
run: make molecule-test

Diff for: .github/workflows/yamllint.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
3-
name: 'Yamllint'
2+
name: "Yamllint"
43

54
on:
65
push:
@@ -17,17 +16,17 @@ jobs:
1716
steps:
1817
- name: Set TERM environment variable
1918
run: echo "TERM=xterm" >> $GITHUB_ENV
20-
21-
- name: 'Checkout'
22-
uses: actions/checkout@v2
2319

24-
- name: 'Run yamllint'
25-
uses: karancode/yamllint-github-action@master
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Set up Python 3.10
24+
uses: actions/setup-python@v4
2625
with:
27-
yamllint_file_or_dir: '.'
28-
yamllint_strict: true
29-
yamllint_comment: true
30-
env:
31-
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
python-version: "3.10"
27+
28+
- name: Install dependencies
29+
run: make bootstrap-dev
3230

33-
...
31+
- name: Run Yamllint
32+
run: make linter-yamllint

Diff for: .gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ image:
33
file: .config/gitpod/Dockerfile
44

55
tasks:
6-
- init: make bootstrap
6+
- init: make bootstrap-dev

Diff for: CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Use Gitpod for a cloud-based development environment:
3636
3. Open your fork in Gitpod: `https://gitpod.io/#https://github.com/username/postgresql_cluster`
3737
4. Create a new branch: `git checkout -b my-feature-branch`
3838
5. Make your changes and commit: `git add .` and `git commit -m "Description of changes"`
39-
6. Test with Molecule: `make molecule-test` or `make molecule-converge`
40-
7. Test with linters(otpional): `make lint`
39+
6. Test with Molecule: `make tests` or `make tests-fast`
40+
7. Test with linters: `make lint`
4141
8. Push your changes: `git push origin my-feature-branch`
4242
9. Create a pull request on GitHub
4343
10. Wait for a review
@@ -48,7 +48,7 @@ Keep your Gitpod workspace synced with the main repository.
4848

4949
Install [make](https://www.gnu.org/software/make/), [Python3.10](https://www.python.org/), [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/), and [docker](https://docs.docker.com/engine/install/ubuntu/).
5050

51-
Run `make` for Makefile help. Initialize virtualenv and install dependencies with `make reinitialization` or `make bootstrap`. Test your changes with `make molecule-test` or `make molecule-converge`.
51+
Run `make` for Makefile help. Initialize virtualenv and install dependencies with `make reinitialization-dev` or `make bootstrap-dev`. Test your changes with `make tests` or `make molecule-converge`.
5252

5353
To test a specific distribution, set `distro`, `tag`, and `namespace`:
5454

Diff for: Makefile

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all test SHELL
1+
.PHONY: all SHELL
22

33
# Makefile global config
44
.DEFAULT_GOAL:=help
@@ -38,23 +38,44 @@ python_launcher := python$(shell cat .config/python_version.config | cut -d '='
3838

3939
-include $(addsuffix /*.mak, $(shell find .config/make -type d))
4040

41+
## —— Tests collection ———————————————————————————————————————————————————————————————————————
42+
.PHONY: tests
43+
tests: ## tests Ansible collection
44+
$(MAKE) docker-tests
45+
$(MAKE) lint
46+
$(MAKE) molecule-test-all
47+
48+
.PHONY: tests-fast
49+
tests-fast: ## tests Ansible collection quickly
50+
$(MAKE) lint
51+
$(MAKE) molecule-converge
52+
4153
## —— Bootstrap collection ———————————————————————————————————————————————————————————————————————
4254
.PHONY: bootstrap
4355
bootstrap: ## Bootstrap Ansible collection
4456
$(MAKE) python-bootstrap
57+
58+
.PHONY: bootstrap-dev
59+
bootstrap-dev: ## Bootstrap Ansible collection for development
60+
$(MAKE) bootstrap
4561
$(MAKE) python-bootstrap-dev
4662

4763
## —— Virtualenv ————————————————————————————————————————————————————————————————————————————————
4864
.PHONY: reinitialization
4965
reinitialization: ## Return to an initial state of Bootstrap Ansible collection
50-
rm -rf .venv/
51-
rm -rf vendor/
52-
rm -f *.mak
66+
$(MAKE) clean
5367
$(MAKE) bootstrap
5468

69+
.PHONY: reinitialization-dev
70+
reinitialization-dev: ## Return to an initial state of Bootstrap Ansible collection for development
71+
$(MAKE) reinitialization
72+
$(MAKE) bootstrap-dev
73+
5574
.PHONY: clean
5675
clean: ## Clean collection
5776
rm -rf .venv/
77+
rm -rf vendor/
78+
rm -f *.mak
5879
rm -rf .pytest_cache/
5980
rm -rf scripts/.pytest_cache/
6081
rm -rf scripts/tests/__pycache__/

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-vitabaks.postgresql_cluster-success.svg)](https://galaxy.ansible.com/vitabaks/postgresql_cluster)
44
[<img src="https://github.com/vitabaks/postgresql_cluster/workflows/Ansible-lint/badge.svg?branch=master">](https://github.com/vitabaks/postgresql_cluster/actions?query=workflow%3AAnsible-lint)
55
[<img src="https://github.com/vitabaks/postgresql_cluster/workflows/Yamllint/badge.svg?branch=master">](https://github.com/vitabaks/postgresql_cluster/actions?query=workflow%3AYamllint)
6+
[<img src="https://github.com/vitabaks/postgresql_cluster/workflows/Flake8/badge.svg?branch=master">](https://github.com/vitabaks/postgresql_cluster/actions?query=workflow%3AFlake8)
67
[<img src="https://github.com/vitabaks/postgresql_cluster/workflows/Molecule/badge.svg?branch=master">](https://github.com/vitabaks/postgresql_cluster/actions?query=workflow%3AMolecule)
78
[![GitHub license](https://img.shields.io/github/license/vitabaks/postgresql_cluster)](https://github.com/vitabaks/postgresql_cluster/blob/master/LICENSE)
89
![GitHub stars](https://img.shields.io/github/stars/vitabaks/postgresql_cluster)
@@ -594,4 +595,4 @@ USDT (TRC20): `TSTSXZzqDCUDHDjZwCpuBkdukjuDZspwjj`
594595
---
595596

596597
## Feedback, bug-reports, requests, ...
597-
Are [welcome](https://github.com/vitabaks/postgresql_cluster/issues)!
598+
Are [welcome](https://github.com/vitabaks/postgresql_cluster/issues)!

0 commit comments

Comments
 (0)