From affe48ad93c01570138dd4e446591389d766fc42 Mon Sep 17 00:00:00 2001 From: Borel Wamba Date: Mon, 28 Oct 2024 16:14:17 +0100 Subject: [PATCH 1/4] Update ci_cd.yml --- .github/workflows/ci_cd.yml | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index da56e6d..df4a350 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1,16 +1,13 @@ -name: CI Workflow +name: CI/CD Workflow on: push: branches: - - master - - pull_request: - branches: + - main - master jobs: - test: + build: runs-on: ubuntu-latest steps: @@ -20,21 +17,19 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.12.7' - - - name: Find and Install Dependencies - run: | - python -m pip install --upgrade pip - # Find all requirements.txt files and install dependencies for each - for req_file in $(find . -name "requirements.txt"); do - echo "Installing dependencies from $req_file" - pip install -r "$req_file" - done + python-version: '3.12.7' - - name: Run Tests + - name: Install dependencies for each subproject run: | - # Run tests in each subproject that contains tests - for test_dir in $(find . -type d -name "tests"); do - echo "Running tests in $test_dir" - pytest "$test_dir" + # Loop through each subproject directory + for dir in projects/*; do + if [ -d "$dir" ]; then + echo "Installing dependencies for $dir" + # Check if requirements.txt exists in the subproject + if [ -f "$dir/requirements.txt" ]; then + pip install -r "$dir/requirements.txt" + else + echo "No requirements.txt found in $dir" + fi + fi done From e35350b65ccd9a0b568d34dce712b03b6e9e6c24 Mon Sep 17 00:00:00 2001 From: Borel Wamba Date: Mon, 28 Oct 2024 16:21:07 +0100 Subject: [PATCH 2/4] Update2 ci_cd.yml --- .github/workflows/ci_cd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index df4a350..3df913f 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -3,7 +3,6 @@ name: CI/CD Workflow on: push: branches: - - main - master jobs: From bcab6f78e145f67357289e97b215c71cada27bf0 Mon Sep 17 00:00:00 2001 From: Borel Wamba Date: Mon, 28 Oct 2024 20:54:58 +0100 Subject: [PATCH 3/4] New steps ci_cd.yml --- .github/workflows/ci_cd.yml | 57 +++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 3df913f..aaa06de 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -10,21 +10,31 @@ jobs: runs-on: ubuntu-latest steps: + # Step 1: Checkout Repository - name: Checkout repository uses: actions/checkout@v3 + # Step 2: Set up Python Environment - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.12.7' + python-version: '3.12.7' + # Step 3: Cache Dependencies + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('projects/**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + # Step 4: Install Dependencies for Each Subproject - name: Install dependencies for each subproject run: | - # Loop through each subproject directory for dir in projects/*; do if [ -d "$dir" ]; then echo "Installing dependencies for $dir" - # Check if requirements.txt exists in the subproject if [ -f "$dir/requirements.txt" ]; then pip install -r "$dir/requirements.txt" else @@ -32,3 +42,44 @@ jobs: fi fi done + + # Step 5: Generate README.md for New Projects + - name: Generate README.md for new projects + run: | + for dir in projects/*; do + if [ ! -f "$dir/README.md" ]; then + echo "Generating README.md for $dir" + project_name=$(basename "$dir") + cat <<- EOF > "$dir/README.md" + # $project_name + + ## Overview + This is the **$project_name** project, part of the Python project repository. This project includes functionality specific to the project's goal and is designed with modularity and reusability in mind. + + ## Setup + 1. Clone the repository and navigate to this subproject: + ```bash + git clone + cd projects/$project_name + ``` + + 2. Activate a virtual environment and install dependencies: + ```bash + python3 -m venv venv + source venv/bin/activate # or venv\Scripts\activate on Windows + pip install -r requirements.txt + ``` + + ## Usage + 1. Run the main script to see the project in action: + ```bash + python main.py + ``` + + ## Contributing + Contributions are welcome! Feel free to open issues or submit pull requests. + + Generated on $(date). + EOF + fi + done From a71954b1b6d4b48ae0fa855489ca4f008726e370 Mon Sep 17 00:00:00 2001 From: Borel Wamba Date: Mon, 28 Oct 2024 21:21:21 +0100 Subject: [PATCH 4/4] Fix script syntax error in CI/CD workflow --- .github/workflows/ci_cd.yml | 72 +++++++++++++------------------------ 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index aaa06de..01f5fab 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -10,31 +10,21 @@ jobs: runs-on: ubuntu-latest steps: - # Step 1: Checkout Repository - name: Checkout repository uses: actions/checkout@v3 - # Step 2: Set up Python Environment - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.12.7' + python-version: '3.12.7' # Set your desired Python version - # Step 3: Cache Dependencies - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('projects/**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - # Step 4: Install Dependencies for Each Subproject - name: Install dependencies for each subproject run: | + # Loop through each subproject directory for dir in projects/*; do if [ -d "$dir" ]; then echo "Installing dependencies for $dir" + # Check if requirements.txt exists in the subproject if [ -f "$dir/requirements.txt" ]; then pip install -r "$dir/requirements.txt" else @@ -43,43 +33,29 @@ jobs: fi done - # Step 5: Generate README.md for New Projects - - name: Generate README.md for new projects + - name: Run README Generation run: | + # Loop through each subproject directory to generate README files for dir in projects/*; do - if [ ! -f "$dir/README.md" ]; then - echo "Generating README.md for $dir" + if [ -d "$dir" ]; then project_name=$(basename "$dir") - cat <<- EOF > "$dir/README.md" - # $project_name - - ## Overview - This is the **$project_name** project, part of the Python project repository. This project includes functionality specific to the project's goal and is designed with modularity and reusability in mind. - - ## Setup - 1. Clone the repository and navigate to this subproject: - ```bash - git clone - cd projects/$project_name - ``` - - 2. Activate a virtual environment and install dependencies: - ```bash - python3 -m venv venv - source venv/bin/activate # or venv\Scripts\activate on Windows - pip install -r requirements.txt - ``` - - ## Usage - 1. Run the main script to see the project in action: - ```bash - python main.py - ``` - - ## Contributing - Contributions are welcome! Feel free to open issues or submit pull requests. - - Generated on $(date). - EOF + readme_file="$dir/README.md" + + # Create a README file with documentation + echo "# $project_name" > "$readme_file" + echo "" >> "$readme_file" + echo "## Description" >> "$readme_file" + echo "This is the README for the $project_name project." >> "$readme_file" + echo "" >> "$readme_file" + echo "## Installation" >> "$readme_file" + echo "To install the dependencies, run the following command:" >> "$readme_file" + echo "\`\`\`bash" >> "$readme_file" + echo "pip install -r requirements.txt" >> "$readme_file" + echo "\`\`\`" >> "$readme_file" + echo "" >> "$readme_file" + echo "## Usage" >> "$readme_file" + echo "Instructions for using the $project_name project go here." >> "$readme_file" + + echo "Generated README for $project_name" fi done