Skip to content

Commit

Permalink
Merge pull request #41 from andreygubarev/direnv
Browse files Browse the repository at this point in the history
Integrate direnv
  • Loading branch information
andreygubarev authored May 10, 2024
2 parents a1002d8 + f4a3fb9 commit 5f81136
Show file tree
Hide file tree
Showing 10 changed files with 1,212 additions and 39 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
layout pipenv
12 changes: 9 additions & 3 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up direnv
uses: andreygubarev/direnv-action@v1

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pipenv'

- name: Install dependencies
run: pip install ansible-lint
- name: Install pipenv
run: pip install pipenv

- name: Lint with ansible-lint
run: ansible-lint -v
run: |
direnv allow .
direnv exec . ansible-lint -v
11 changes: 10 additions & 1 deletion .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up direnv
uses: andreygubarev/direnv-action@v1

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install pipenv
run: pip install pipenv

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -yq --no-install-recommends mkisofs qemu-system-x86 qemu-utils
- name: Run test
run: make test-platform-amd64
run: |
direnv allow .
direnv exec . ansible-galaxy collection install -r requirements.yml
direnv exec . make test-platform-amd64
14 changes: 10 additions & 4 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up direnv
uses: andreygubarev/direnv-action@v1

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pipenv'

- name: Install dependencies
run: pip install pycodestyle
- name: Install pipenv
run: pip install pipenv

- name: Lint with pycodestyle
run: python -m pycodestyle molecule_qemu
- name: Lint with ansible-lint
run: |
direnv allow .
direnv exec . pycodestyle molecule_qemu
16 changes: 11 additions & 5 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up direnv
uses: andreygubarev/direnv-action@v1

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pipenv'

- name: Install dependencies
run: python -m pip install build --user
- name: Install pipenv
run: pip install pipenv

- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Lint with ansible-lint
run: |
direnv allow .
direnv exec . python -m build --sdist --wheel --outdir dist/ .
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
35 changes: 11 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
MAKEFILE_DIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
VIRTUALENV_VENV ?= $(MAKEFILE_DIR)/.venv
VIRTUALENV_PYTHON := $(VIRTUALENV_VENV)/bin/python3
VIRTUALENV_PIP := $(VIRTUALENV_PYTHON) -m pip
VIRTUALENV_MOLECULE := $(VIRTUALENV_VENV)/bin/molecule

.PHONY: help
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

$(VIRTUALENV_VENV):
python3 -m venv $(VIRTUALENV_VENV)
$(VIRTUALENV_PIP) install \
'ansible-lint==6.16.1' \
'pycodestyle==2.10.0'

.PHONY: virtualenv
virtualenv: $(VIRTUALENV_VENV) ## Create local environment

.PHONY: lint
lint: virtualenv ## Lint
$(VIRTUALENV_VENV)/bin/ansible-lint -v molecule_qemu
$(VIRTUALENV_VENV)/bin/pycodestyle molecule_qemu
lint: ## Lint
ansible-lint -v molecule_qemu
pycodestyle molecule_qemu

.PHONY: test ## Test
test:
$(VIRTUALENV_PIP) install -e .
cd tests && $(VIRTUALENV_MOLECULE) test
.PHONY: test
test: ## Test
pip install -e .
cd tests && molecule test

.PHONY: test-%
test-%: virtualenv
$(VIRTUALENV_PIP) install -e .
cd tests && $(VIRTUALENV_MOLECULE) test -s $*
test-%:
pip install -e .
cd tests && molecule test -s $*

.PHONY: test-network
test-network: test-network-shared test-network-user ## Test network
Expand All @@ -49,4 +36,4 @@ test-platform: test-platform-amd64 test-platform-arm64 ## Test platform

.PHONY: clean
clean: ## Remove cache
rm -rf $(VIRTUALENV_VENV) build dist *.egg-info
rm -rf $(MAKEFILE_DIR)/.venv build dist *.egg-info
15 changes: 15 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
build = "*"
molecule = ">=5.0.0"

[dev-packages]
ansible-lint = ">=24.0.0,<25.0.0"
pycodestyle = ">=2.00.0,<3.00.0"

[requires]
python_version = "3.12"
Loading

0 comments on commit 5f81136

Please sign in to comment.