Friday, 5 pm, release time
A team has to release by hand. They copy files. They run tests, if they remember. They upload.
Today they forget one file. The app breaks for all users. Everyone goes home late.
A good team does not do this by hand. A machine does it the same way every time.
Key words
| Word | What it means | Example |
|---|---|---|
| Front end | The part the user sees and touches. | HTML, CSS, JavaScript |
| Back end | The part on a server that holds the rules and data. | Python, a database |
| Package | To put a product's files together so it can be installed. | |
| Framework | Ready-made code you build your app inside. | |
| Executable | One file that a computer can run directly. | game.exe |
| Continuous integration | Joining and checking every change straight away. Short name: CI. | |
| Continuous deployment | Putting a change live by itself once it passes. Short name: CD. | |
| Pipeline | A line of automatic steps that every change goes through. | |
| Compile | Turn code you write into code the computer can run. | |
| Automation | A machine doing a job the same way every time. | |
| Database | An organised store of data that programs can search and change. | |
| Build | To turn source code into something that runs. | |
| Unit test | A small test of one part of the code. |
The cells students fill in are left blank in this preview.
Many files, one product
A product has a front end and a back end. The front end may be HTML, CSS and a framework (ready-made code).
The back end may be Python and a database.
To give it to users you package it: you put every file in the right place. You can also compile the code and join it into one executable file.
The user does not want ten files and a list of steps. They want one thing that works.
Check: packaging a product
Have a go
Check: packaging a product
3 questionsWays to package
| Way | What the user gets | Example |
|---|---|---|
| Web product | A web address. The files sit on a server | HTML, CSS and JavaScript served with a Python back end |
| Compiled executable | One file. The code is compiled and joined into it | A game you install on a PC |
| Installer | A file that puts everything in place | A setup file for a desktop app |
| Container | A box with the program and what it needs | A back end that runs on any server |
The cells students fill in are left blank in this preview.
CI and CD
Continuous integration (CI): every time a developer saves a change, a machine joins it to the main code, builds it and tests it.
Continuous deployment (CD): if all checks pass, the change goes live by itself.
The line of automatic steps is a pipeline. A bad change stops in the pipeline. Users never see it.
The five stages of a pipeline
flowchart LR
src[1 Source code control: a change is pushed] --> build[2 Build automation: make the program]
build --> unit[3 Unit test automation: run all tests]
unit -->|all pass| deploy[4 Deployment automation: put it live]
unit -->|a test fails| stop([Stop and tell the team])
deploy --> watch[5 Monitoring: watch for problems]
watch -.->|a problem is found| src
Match the stage to its job
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
What each stage does
| Stage | Job | Example tool |
|---|---|---|
| Source code control | Keeps the code and starts the pipeline on every push | Git, Gitea, GitHub |
| Build automation | Makes the program from the code | GitHub Actions, Jenkins, Maven |
| Unit test automation | Runs every test. Stops if one fails | pytest, JUnit |
| Deployment automation | Puts the new version live, the same way each time | Docker, a deploy script |
| Monitoring | Watches the live product and sends an alert on a problem | Logs, uptime checks, dashboards |
The cells students fill in are left blank in this preview.
A real pipeline file, line by line
| A line in the file | What it tells the machine |
|---|---|
| on: push | Start every time somebody pushes code |
| runs-on: ubuntu-latest | Use a fresh Linux computer for the job |
| run: pip install flask pytest | Install the libraries the product needs (the build) |
| run: pytest | Run every unit test. A failed test stops the pipeline |
| run: ./deploy.sh | Put the new version live. It only runs if the tests passed |
The cells students fill in are left blank in this preview.
A pipeline stops at the first failure
def build():
print("Building...")
return True
def test():
print("Testing...")
return False # change to True
def deploy():
print("Deploying...")
return True
for name, step in [("build", build), ("test", test), ("deploy", deploy)]:
if not step():
print("Stopped at", name)
break
Make a free account to save your work and track your progress.
Build a pipeline runner
Write the heart of a pipeline. run_pipeline runs each stage in order and stops at the first one that fails. report_line gives a short message for the team. Press Run Tests.
def run_pipeline(stages):
# stages is a list of pairs: (name, check). check is a function that gives back True or False.
# Run the stages in order. Stop at the first one that gives back False.
# Give back a dictionary:
# {"ran": [names of stages that were run, in order],
# "passed": True if every stage passed, else False,
# "failed_at": the name of the stage that failed, or None}
return None
def report_line(result):
# Give back "Pipeline passed" when result["passed"] is True.
# Otherwise give back "Pipeline stopped at <name>", for example: Pipeline stopped at test
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Exit quiz
Have a go