More elaborated worksteps:
Lab: Setting Up and Using GitHub Issues and GitHub Actions for CI/CD
This lab guides students through:
- creating a GitHub repository
setting up GitHub Actions for Continuous Integration (CI) managing GitHub Issues to simulate practical DevOps workflows Objectives
Create a GitHub repository and upload a TypeScript code base. Set up a basic GitHub Actions workflow to automate builds and tests. Use GitHub Issues to track and resolve issues, simulating Agile DevOps practices. Prerequisites
Basic knowledge of TypeScript. A completed codebase from a previous assignment. Part 1: GitHub Repository Setup and Code Upload
Create a New GitHub Repository Click on the New button to create a new repository. Name the repository (e.g., devops-pipeline-lab), add a description, and make it Public or Private as needed. Check the box to initialize with a README (optional).
git clone <your-repository-URL>
Copy your TypeScript code files from Assignment 1 into this repository folder. bash
Copy code
git add .
git commit -m "Initial code upload"
git push origin main
Verify that the code is now in your GitHub repository by refreshing the repository page. Validate: Confirm that all files are present in the repository and that no errors occurred during the upload. Part 2: Setting Up GitHub Actions for CI/CD
Navigate to GitHub Actions In your repository, click on the Actions tab. Select Set up a workflow yourself. Name the file .github/workflows/ci.yml. Copy the following YAML configuration for basic CI/CD automation: yaml
Copy code
name: CI Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Lint code
run: npm run lint
Save the file to initiate the workflow setup. Configure Your Project’s Scripts In your package.json, ensure you have the following scripts for testing and linting: json
Copy code
"scripts": {
"test": "jest",
"lint": "eslint ."
}
Validate: Push changes and confirm that the GitHub Action triggers automatically. View the Actions tab to check if the workflow passed. Part 3: Managing Issues on GitHub
Navigate to the Issues tab in your repository. Click on New issue to create an issue. Title the issue (e.g., “Fix broken tests” or “Implement Docker setup”). Add a detailed description, including the expected behavior, any observed issues, and potential solutions. Assign the issue to yourself or a team member. Label the issue appropriately (e.g., bug, enhancement, documentation). Linking Issues to Commits and Pull Requests When working on an issue, create a new branch with the issue name: bash
Copy code
git checkout -b issue-<issue-number>
Make the necessary code changes. Commit changes with a message referencing the issue: bash
Copy code
git commit -m "Fixes #<issue-number>: Description of the fix"
Push the branch and open a Pull Request (PR) on GitHub, linking it to the issue. Tracking and Resolving Issues In the Pull Request page, request a review if working in teams. Once approved, merge the PR, which automatically closes the linked issue. Validate: Confirm the issue is closed, and the code changes are visible on the main branch. Part 4: Expanding the Pipeline with Docker Integration (Optional)
In the root of your repository, add a Dockerfile: dockerfile
Copy code
FROM node:16
WORKDIR /app
COPY . .
RUN npm install
CMD ["npm", "start"]
Update the GitHub Actions Workflow Modify your ci.yml to include Docker build steps: yaml
Copy code
- name: Build Docker Image
run: docker build -t myapp:latest .
Validate: Ensure the Docker image builds successfully on GitHub Actions. Part 5: Documenting the Workflow and Final Report
Create a Traceability Matrix Use a simple table (e.g., in a markdown file) to link issues, code changes, and tests. Write the README and Documentation Include instructions for: Setting up the project locally. Running tests and linting. Final Validation: Review all documentation and ensure all elements of the pipeline work as expected. Submission Checklist
GitHub repository with CI/CD pipeline, Docker configuration, and Jest tests. Documentation with a traceability matrix, README, and issue logs. Confirmation of automated testing and issue tracking setup. This lab exercises fundamental DevOps principles, guiding students to automate, document, and manage software in a streamlined, hands-on environment.