diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index a97b876..921ad60 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -68,8 +68,6 @@ jobs: - name: Install dependencies run: | - # Install pre-commit and CI dependencies - pip install pre-commit pip install -r requirements-ci.txt - name: Cache pre-commit environments diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 522bacc..fcdfb60 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -223,12 +223,39 @@ breaking_changes: ```bash # Install Ansible collection dependencies -ansible-galaxy collection install -r requirements.yml - -# Install Python development dependencies +export ANSIBLE_GALAXY_SERVER_LIST=upstream_galaxy,automation_hub_certified,automation_hub_validated +export ANSIBLE_GALAXY_SERVER_UPSTREAM_GALAXY_URL=https://galaxy.ansible.com/ +export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_CERTIFIED_URL=https://console.redhat.com/api/automation-hub/content/published/ +export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_CERTIFIED_AUTH_URL=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token +export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_CERTIFIED_TOKEN="ADD_YOUR_TOKEN_HERE" +export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_VALIDATED_URL=https://console.redhat.com/api/automation-hub/content/validated/ +export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_VALIDATED_AUTH_URL=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token +export ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_VALIDATED_TOKEN="ADD_YOUR_TOKEN_HERE" +ansible-galaxy collection install -r requirements-dev.yml + +# Install Python development dependencies and tooling pip install -r requirements-dev.txt +pip install -r requirements-ci.txt ``` +#### macOS-Specific Requirements + +If you're developing on macOS, ensure you have the following tools installed: + +```bash +# Install required tools via Homebrew +brew install python3 bash gnu-sed coreutils + +# Ensure bash is available at /usr/bin/bash (required for pre-commit hooks) +# If not, create a symlink (requires admin privileges): +sudo ln -sf /bin/bash /usr/bin/bash + +# Or use setup script provided in the repository +./scripts/setup_env.sh +``` + +**Note**: The repository's shell scripts are compatible with both GNU (Linux) and BSD (macOS) utilities. However, pre-commit hooks may require bash to be available at `/usr/bin/bash`. + ### Running Tests Locally ```bash @@ -251,7 +278,6 @@ pre-commit run --all-files This repository uses pre-commit hooks for code quality. Install them to run checks automatically before each commit: ```bash -pip install pre-commit pre-commit install ``` diff --git a/README.md b/README.md index 4c468e7..46e37fa 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ansible for OpenShift Virtualization Migration +# OpenShift Virtualization Migration Collection ![GitHub Release](https://img.shields.io/github/v/release/redhat-cop/openshift_virtualization_migration?include_prereleases&style=flat-square) [![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/redhat-cop/openshift_virtualization_migration/ci.yml?style=flat-square&label=release)](https://github.com/redhat-cop/openshift_virtualization_migration/actions) @@ -7,7 +7,7 @@ -- [Ansible for OpenShift Virtualization Migration](#ansible-for-openshift-virtualization-migration) +- [OpenShift Virtualization Migration Collection](#openshift-virtualization-migration-collection) - [Description](#description) - [Documentation](#documentation) - [Release Notes](#release-notes) @@ -102,7 +102,7 @@ Note that if you install any collections from Ansible Galaxy, they will not be u To upgrade the collection to the latest available version, run the following command: -``` +```shell ansible-galaxy collection install infra.openshift_virtualization_migration --upgrade ``` @@ -114,9 +114,12 @@ collections: - name: infra.openshift_virtualization_migration # If you need a specific version of the collection, you can specify like this: # version: ... +... ``` -See [using Ansible collections](https://docs.ansible.com/ansible/devel/user_guide/collections_using.html) for more details. +See +[Using Ansible Collections](https://docs.ansible.com/projects/ansible/latest/collections_guide/index.html) +for more details. ## Use Cases diff --git a/requirements-ci.txt b/requirements-ci.txt index 7a13399..294b1c1 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -4,3 +4,4 @@ antsibull-changelog==0.35.0 docsible==0.8.0 python-semantic-release==10.5.3 md-toc>=9.0.0 +pre-commit diff --git a/scripts/setup_env.sh b/scripts/setup_env.sh index 09c585e..2f84659 100755 --- a/scripts/setup_env.sh +++ b/scripts/setup_env.sh @@ -25,8 +25,9 @@ source "$VENV_DIR/bin/activate" echo -e "${GREEN}Upgrading pip...${RESET}" pip install --upgrade pip -echo -e "${GREEN}Installing Ansible core, Ansible Lint, and Pre-commit...${RESET}" +echo -e "${GREEN}Installing Ansible core, Ansible Lint, Pre-commit, and more...${RESET}" pip install -r requirements-dev.txt +pip install -r requirements-ci.txt echo -e "${GREEN}Installing pre-commit hooks${RESET}" diff --git a/scripts/update-documentation.sh b/scripts/update-documentation.sh index ce2216f..577134d 100755 --- a/scripts/update-documentation.sh +++ b/scripts/update-documentation.sh @@ -20,15 +20,19 @@ mv README.md.bkp README.md # Generate role list from metadata echo "Generating role list from role metadata..." -ROLE_LIST=$(python3 ${ROLE_LIST_GENERATOR}) +ROLE_LIST_FILE=$(mktemp) +python3 ${ROLE_LIST_GENERATOR} > "${ROLE_LIST_FILE}" # Injecting role list into Roles section echo "Building Roles section..." README_TMP=$(mktemp) -awk -v roles="$ROLE_LIST" ' +awk ' // { print $0 - print roles + while ((getline line < "'"${ROLE_LIST_FILE}"'") > 0) { + print line + } + close("'"${ROLE_LIST_FILE}"'") in_roles=1 next } @@ -38,7 +42,7 @@ awk -v roles="$ROLE_LIST" ' !in_roles { print } ' README.md > "${README_TMP}" mv "${README_TMP}" README.md -rm -f "${README_TMP}" +rm -f "${README_TMP}" "${ROLE_LIST_FILE}" # Generate/update TOC in README.md (in-place, GitHub flavor) echo "Generating table of contents for README.md"