انتقل إلى المحتوى
أمين أبوزيد
JNR-051

مقدمة في CI/CD

  • 7 درس
  • 3 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • GitHub Actions أو GitLab CI
  • خط البناء والاختبار (Pipeline)
  • المخرجات (Artifacts)

تعلّم أولًا

3 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Explain continuous integration, delivery, and deployment.
  2. Write a GitHub Actions workflow that builds, runs all tests (including Testcontainers), and caches dependencies.
  3. Publish build artifacts (JAR, container image) to a registry with version tags.
  4. Protect main with required checks.

الدروس

  1. 01CI وCD وCD
  2. 02تشريح GitHub Actions
  3. 03خط البناء والاختبار
  4. 04المخرجات ونشر الصور (Images)
  5. 05حماية الفروع (Branch protection)
  6. 06عرض عملي: بناء خط Shop في GitHub Actions
  7. 07عرض عملي: نشر صورة موسومة عند الدمج

المختبر والتمارين

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)

IDOutcomeTask
JNR-051-EX011Explain CI, continuous delivery, and continuous deployment in one sentence each, with a Shop example.
JNR-051-EX022Write a workflow that checks out, sets up Java 21 with Maven cache, and runs ./mvnw -B verify on pull requests.
JNR-051-EX032Confirm Testcontainers tests run in the workflow and find the test count in the log.
JNR-051-EX043Add a job that builds the image and pushes it to ghcr.io tagged with the commit SHA on pushes to main.
JNR-051-EX054Configure branch protection requiring a PR, one review, and the build check.
JNR-051-EX062Given 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; steps actions/checkout, actions/setup-java with cache: maven, run: ./mvnw -B verify.
  • EX03 Runners have Docker; the Surefire/Failsafe summary shows "Tests run: N"; N must be above zero.
  • EX04 if the event is a push to main; permissions: packages: write; docker/login-action with GITHUB_TOKEN; docker/build-push-action with tags: 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, add permissions: packages: write for 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.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1Continuous deployment means:O1
  2. 2Continuous integration mainly:O1
  3. 3Workflow files live in:O2
  4. 4A step that uses a reusable action starts with:O2
  5. 5Why cache dependencies?O2
  6. 6A pipeline that passes with zero tests run is:O2
  7. 7A safe tag for traceability is:O3
  8. 8To push to GHCR from Actions use:O3
  9. 9To stop failing PRs from merging:O4
  10. 10Branch protection can also:O4

الجزء العملي

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).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.