BM: Baca dalam Bahasa Melayu
World C2: Container Pipelines
Run tests inside containers
You will learn: to taste-test the same lunchbox your customers get.
Checked with GitHub Actions 2026-10 on 31 Oct 2026
The problem
The tests pass on the runner. Then the image crashes in production: a system library is missing. How could the belt catch that?
Pick one answer.
Watch
Tap the line where the test stage starts.
0 of 1 found
One recipe, two dishes. The test stage keeps the test tools. The app stage is what customers get. Both grow from the same base layers.
Try it
Put the belt’s steps in order.
First at the top. Put these in order. Use the arrows, or drag.
- Run npm test inside that image
- Build the test stage, and load it into Docker
- Set up Buildx
- Build the app stage and push it
Predict
One test fails inside the container. Tap the station that will stop the line, then press Run.
Which station will stop the line? Tap it, then press Run.
Workflow file .github/workflows/test.yml
name: Test on: pull_request: permissions: contents: read jobs: test: runs-on: ubuntu-latest steps: - uses: docker/setup-buildx-action@v4 - uses: docker/build-push-action@v7 with: target: test load: true tags: kedai-kancil:test - run: docker run --rm kedai-kancil:test npm test
The line
Pull request · feature → main
Check
The build step says load: true. Why?
Pick one answer.
You did it!
You can now run your tests inside the image you ship.
Go deeper (optional)
Another way: put RUN npm test in the test stage. Then a failing test fails the build itself. Keep test tools out of the app stage. The shipped image stays small.
Real rep (optional), in a public practice repo:
Real mission
docker build --target test -t myapp:test .docker run --rm myapp:test
0 of 4 steps done · Your ticks are saved.
Bahasa Melayu
Ujian lulus di runner. Kemudian image itu rosak di production: satu pustaka sistem tiada. Macam mana tali sawat boleh tangkap masalah itu?
Satu resipi, dua hidangan. Peringkat ujian simpan alat ujian. Peringkat app ialah apa yang pelanggan dapat. Kedua-duanya tumbuh dari layer base yang sama.
Susun langkah tali sawat ikut urutan.
Satu ujian gagal di dalam container. Ketik stesen yang akan hentikan talian, kemudian tekan Run.
Langkah build tulis load: true. Kenapa?
Kini anda boleh jalankan ujian di dalam image yang anda hantar.
You finished this before. Practice is always welcome!
Official docs: Docker docs: test before push with GitHub Actions · Docker docs: multi-stage builds
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?