OpsForDevs
devops bootcamp material that I have taught at previous companies
Project maintained by debaghtk
Hosted on GitHub Pages — Theme by mattgraham
Exercise 3: Setting Up a Continuous Integration Pipeline
Objective
Set up a Continuous Integration (CI) pipeline that runs on every commit and pull request. The pipeline should validate the codebase by running tests, checking code style, and performing linting and formatting checks.
Instructions
- Choose a CI Tool
Select one of the following CI tools:
- GitHub Actions
- Jenkins
- CircleCI
- GitLab CI
- Travis CI
- Azure DevOps
-
Set Up Your CI Configuration
Create a configuration file for your chosen CI tool. The exact filename and location will depend on your chosen tool.
-
Define the CI Pipeline
Your CI pipeline should include the following steps:
a. Code Validation
- Run all unit tests
- Check code style (e.g., PEP 8 for Python)
- Perform linting (e.g., pylint for Python)
- Verify code formatting (e.g., Black for Python)
b. Trigger Conditions
- Configure the pipeline to run on every commit to the main branch
- Configure the pipeline to run on every pull request
- Implement the Pipeline
- Write the necessary configuration to implement each step of the pipeline
- Ensure that the pipeline fails if any step fails
- Test the Pipeline
- Make a commit that should pass all checks
- Make a commit that should fail one or more checks
- Create a pull request and verify that the CI pipeline runs
- Review and Iterate
- Review the output of your CI pipeline
- Make any necessary adjustments to improve its effectiveness or efficiency
Bonus Tasks
- Add code coverage reporting to your CI pipeline
- Implement automatic deployment to a staging environment on successful CI runs
- Set up notifications (e.g., Slack, email) for pipeline results
Deliverables
- CI configuration file
- Brief explanation of your CI setup and any challenges faced
- Screenshots or logs showing successful and failed pipeline runs
Remember, the goal is to catch issues early and often. Your CI pipeline should provide quick feedback to developers about the quality and correctness of their code.