Skip to content

shekar369/python-cicd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is the project to implement simple CICD setup using GitHub Codespaces. It includes a description of the project and detailed steps for setting up and running it


Python CI/CD Example with GitHub Codespaces

This is a simple Python project to demonstrate how to set up CI/CD (Continuous Integration/Continuous Deployment) using GitHub Actions and GitHub Codespaces. The project includes a basic Python script and unit tests to verify its functionality.

The CI/CD pipeline automatically tests the code and ensures quality on every push or pull request to the main branch.


Project Structure

python-cicd-example/
│
├── .devcontainer/                   # GitHub Codespaces configuration
│   ├── devcontainer.json            # Configuration for the development container
│
├── .github/                         # GitHub Actions workflows
│   └── workflows/
│       └── ci-cd.yml                # CI/CD pipeline configuration
│
├── main.py                          # Python script with main functionality
├── test_main.py                     # Unit tests for main.py
├── requirements.txt                 # Python dependencies
└── README.md                        # Project documentation

Features

  1. GitHub Codespaces Configuration:
    • Ensures a consistent development environment.
    • Automatically installs dependencies in a containerized setup.
  2. CI/CD with GitHub Actions:
    • Runs unit tests on every push or pull request.
    • Verifies code quality before deployment.

How to Set Up the Project

Follow these steps to set up and run the project:

1. Clone the Repository

  1. Fork this repository to your GitHub account.
  2. Clone the repository to your local machine:
    git clone https://github.com/<your-username>/python-cicd-example.git
    cd python-cicd-example

2. Install Python

Ensure you have Python 3.10 or later installed on your system. Check the version with:

python --version

3. Set Up a Virtual Environment (Optional but recommended)

  1. Create a virtual environment:
    python -m venv venv
  2. Activate the virtual environment:
    • On Linux/Mac:
      source venv/bin/activate
    • On Windows:
      venv\Scripts\activate

4. Install Dependencies

Install the required dependencies:

pip install -r requirements.txt

5. Run the Project

  1. Execute the main script:

    python main.py

    You should see the output:

    Hello, GitHub Codespaces!
    
  2. Run the unit tests:

    python -m unittest discover

    The tests should pass successfully.


How to Enable CI/CD

  1. Commit and push changes to the repository:

    git add .
    git commit -m "Initial project setup"
    git push origin main
  2. Navigate to the Actions tab in your GitHub repository.

  3. You will see the CI/CD workflow running automatically. It tests the code and ensures all checks pass.


How to Use GitHub Codespaces

  1. Open the repository in GitHub.
  2. Click on the Code button and select Open with Codespaces.
  3. GitHub Codespaces will launch a development container with the pre-configured environment.
  4. Run the project or tests directly in Codespaces:
    python main.py
    python -m unittest discover

Contributing

Feel free to fork the repository, create a feature branch, and submit a pull request. Contributions are welcome!


License

This project is licensed under the MIT License.


FAQ

  1. What if I encounter errors while running the tests?

    • Ensure all dependencies are installed and Python 3.10 or later is used.
    • Verify that requirements.txt does not include built-in libraries like unittest.
  2. Can I use a Python version other than 3.10?

    • Yes, but ensure compatibility with your environment and update the ci-cd.yml file to match the Python version.

Contact

For any questions or issues, please raise an issue in the GitHub repository.


This README file provides all necessary instructions for others to set up and use the project, including CI/CD and Codespaces configuration. Let me know if you need further enhancements!

About

This is the project to implement simple CICD setup using GitHub Codespaces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages