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
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.
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
- GitHub Codespaces Configuration:
- Ensures a consistent development environment.
- Automatically installs dependencies in a containerized setup.
- CI/CD with GitHub Actions:
- Runs unit tests on every push or pull request.
- Verifies code quality before deployment.
Follow these steps to set up and run the project:
- Fork this repository to your GitHub account.
- Clone the repository to your local machine:
git clone https://github.com/<your-username>/python-cicd-example.git cd python-cicd-example
Ensure you have Python 3.10 or later installed on your system. Check the version with:
python --version- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
- On Linux/Mac:
source venv/bin/activate - On Windows:
venv\Scripts\activate
- On Linux/Mac:
Install the required dependencies:
pip install -r requirements.txt-
Execute the main script:
python main.py
You should see the output:
Hello, GitHub Codespaces! -
Run the unit tests:
python -m unittest discover
The tests should pass successfully.
-
Commit and push changes to the repository:
git add . git commit -m "Initial project setup" git push origin main
-
Navigate to the Actions tab in your GitHub repository.
-
You will see the CI/CD workflow running automatically. It tests the code and ensures all checks pass.
- Open the repository in GitHub.
- Click on the Code button and select Open with Codespaces.
- GitHub Codespaces will launch a development container with the pre-configured environment.
- Run the project or tests directly in Codespaces:
python main.py python -m unittest discover
Feel free to fork the repository, create a feature branch, and submit a pull request. Contributions are welcome!
This project is licensed under the MIT License.
-
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.txtdoes not include built-in libraries likeunittest.
-
Can I use a Python version other than 3.10?
- Yes, but ensure compatibility with your environment and update the
ci-cd.ymlfile to match the Python version.
- Yes, but ensure compatibility with your environment and update the
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!