Why? To securely connect the CLI to your GitHub account.
Action: Log in using your Personal Access Token (PAT):
gh auth login
Select HTTPS when prompted.
Paste your PAT when asked for the password. {You created your PAT in class last week}
Expected Result: CLI displays “You are logged in as [username].”
3. Create a New GitHub Repository {or use a previous one such as your TEAM GitHUB Repository}
Why? To host your project code and track changes.
Action: Create a repository and clone it locally:
gh repo create <repository-name> --public
gh repo clone <username>/<repository-name>
cd <repository-name>
Expected Result: A new folder is created locally, and the GitHub repo is live.
4. Prepare Your JavaScript Project
Why? To have a functional project with Jest tests to automate.
Action: Add a simple Jest test:
npm init -y
npm install jest --save-dev
mkdir __tests__
touch __tests__/example.test.js
Add this code to __tests__/example.test.js:
javascript
Copy code
test('adds 1 + 2 to equal 3', () => {
expect(1 + 2).toBe(3);
});
Expected Result: Your project runs tests successfully:
npx jest
5. Commit and Push Code to GitHub
Why? To synchronize your local project with the GitHub repository.
Action:
git add .
git commit -m "Initial project setup"
git push -u origin main
Expected Result: Code appears in your GitHub repository under the main branch.
6. Set Up GitHub Actions Workflow
Why? To automate Jest tests on every push.
Action:
Create the workflow file:
mkdir -p .github/workflows
touch .github/workflows/ci.yml
Add this content to ci.yml:
yaml
Copy code
name: Jest CI
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm install
- run: npm test
Commit and push:
git add .github/workflows/ci.yml
git commit -m "Add CI workflow"
git push
Expected Result: GitHub Actions tab shows the workflow running on each push.
7. Test the Workflow
Why? To ensure your automation works.
Action: Make a small change in your code and push:
echo "// Test change" >> index.js
git add .
git commit -m "Test workflow"
git push
Expected Result:
Go to the Actions tab on GitHub.
Observe the Jest test results as pass or fail.
Note: In a complete implementation, you could run your JEST tests from here. Challenge yourself to do this as an extenion if you like, but for now, just the console log message is sufficient.
8. Document Your Work
Why? To make the process reproducible.
Action: Update your README.md with:
Steps to set up GitHub CLI and Actions.
Screenshots of:
Workflow logs.
Console output for test pass and fail.
Grading Rubric: Assignment 4
Category
Points
Criteria
Category
Points
Criteria
1
GitHub CLI Setup
20
CLI installed and authenticated successfully.
2
GitHub Actions Setup
40
Functional workflow automates Jest tests and logs results.
3
Testing Results
20
Clear pass/fail logs in the GitHub Actions tab.
4
Documentation
20
Detailed README.md with steps and screenshots.
There are no rows in this table
Part 2: Final Project – Extend and Publish to npmjs.com
Goal: Enhance the workflow, publish your project to npmjs.com, and write a LinkedIn blog post.
Step-by-Step Task Checklist for the Final Project
Enhance the Workflow:
Add a new test:
test('subtracts 5 - 2 to equal 3', () => {
expect(5 - 2).toBe(3);
});
Modify the workflow to include a success message:
yaml
- name: Notify on success
if: success()
run: echo "All tests passed!"
Publish the Project (Optional):
Publish to npm:
npm publish
Note the npm URL for submission to the Assignment Box on Moodle in a text file with team members’ details included.
Write a LinkedIn Blog Post: [This will count as the remainder of your Blog Entries: each student do your blog individually and record the url in the submission text file along with your NPM PUBLISH url for the project.]
Structure:
Intro: What you did and why it matters.
Process: How to set up CI/CD with GitHub Actions.
Results: Challenges, solutions, and screenshots.
Call to Action: Link to your GitHub repo.
Submit Your Work:
Upload to the Moodle Assignment Page a text file, named as your Team Name, with:
team members’ names and Student IDs
GitHub repository URL.
LinkedIn blog URL. for each student
npm package URL : from NPM -publish.
Grading Rubric: Final Project
Category
Points
Criteria
Category
Points
Criteria
1
Enhancements
30
Additional test cases and success logging added to workflow.
2
Screenshots
20
Relevant screenshots showing workflow operation.
3
LinkedIn Blog
30
Professional, well-written blog with visuals and links.
4
Documentation
20
Polished README.md covering all necessary details.
There are no rows in this table
This version breaks every action into precise steps, ties actions to results, and eliminates ambiguity, making the process intuitive and foolproof.
This combined document simplifies your workflow while ensuring all necessary components are covered.
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (