مقدمة في CI/CD
في هذه الصفحة 8 موضوعات
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
نظرة عامة
الموضوعات
- GitHub Actions أو GitLab CI
- خط البناء والاختبار (Pipeline)
- المخرجات (Artifacts)
تعلّم أولًا
3 ساعة تدريب (تقدير)
مخرجات التعلم
- Explain continuous integration, delivery, and deployment.
- Write a GitHub Actions workflow that builds, runs all tests (including Testcontainers), and caches dependencies.
- Publish build artifacts (JAR, container image) to a registry with version tags.
- Protect
mainwith required checks.
الدروس
المختبر والتمارين
Lab
JNR-051-LAB1 · Shop pipeline
Outcomes: 1–4 · Time: ~3 h Every PR runs the full suite (including Testcontainers) with caching; merges to main publish a tagged image; main is protected with required checks. Acceptance: a PR with a failing test cannot be merged.
Exercises (assessment: fix a broken workflow)
| ID | Outcome | Task |
|---|---|---|
| JNR-051-EX01 | 1 | Explain CI, continuous delivery, and continuous deployment in one sentence each, with a Shop example. |
| JNR-051-EX02 | 2 | Write a workflow that checks out, sets up Java 21 with Maven cache, and runs ./mvnw -B verify on pull requests. |
| JNR-051-EX03 | 2 | Confirm Testcontainers tests run in the workflow and find the test count in the log. |
| JNR-051-EX04 | 3 | Add a job that builds the image and pushes it to ghcr.io tagged with the commit SHA on pushes to main. |
| JNR-051-EX05 | 4 | Configure branch protection requiring a PR, one review, and the build check. |
| JNR-051-EX06 | 2 | Given a broken workflow (wrong indentation, -DskipTests, missing permissions), find and fix each defect. |
أظهر الحلول
- EX01 CI: merge often and test automatically. Delivery: every green build is releasable, a human approves. Deployment: every green build goes live automatically.
- EX02
on: pull_request; stepsactions/checkout,actions/setup-javawithcache: maven,run: ./mvnw -B verify. - EX03 Runners have Docker; the Surefire/Failsafe summary shows "Tests run: N"; N must be above zero.
- EX04
ifthe event is a push tomain;permissions: packages: write;docker/login-actionwithGITHUB_TOKEN;docker/build-push-actionwithtags: ghcr.io/${{ github.repository }}:${{ github.sha }}. - EX05 Settings, Branches (or Rulesets): require pull request, 1 approval, status check
build, block force pushes. - EX06 Fix YAML indentation, remove
-DskipTests, addpermissions: packages: writefor pushing images. - Common mistakes (secrets printed in logs, zero tests run) are checked in the EX06 review.
الاختبار
Outcomes: O1 CI/CD concepts · O2 workflows · O3 artifacts and images · O4 branch protection.
اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.
الجزء العملي
Six exercises JNR-051-EX01 to EX06 plus the lab; for the assessment, fix a broken workflow. Pass: quiz 8/10, at least five exercises correct, and a failing-test PR blocked from merging.
أخطاء شائعة
Secrets printed in logs; pipelines that pass with zero tests run.
التقييم
Fix a broken workflow.
الصلة بالمسار الوظيفي
CI/CD advanced (MID-055).