Software Engineering Summer School 2024
-
Continuous Integration:
Frequent merging of changes into main branch -
Continuous Deployment:
Automatic release of new software versions
- Running tests (dynamic and static)
- Check if new changes break any existing functionality
- Check if code follows formatting guidelines
- Building documentation
- Run Doxygen/Sphinx/etc generate documentation in pdf or html form
- Check if examples in the documentation work
- Build static websites
- Build and publish a website to GitHub Pages/ReadTheDocs/etc
- Generating pull requests for updates and other maintenance
- Update dependencies
- Fix typos and coding style
- Whatever your project needs!
- Consistent, controlled environment between runs
- Runs every PR/commit/tag/whatever you choose
- Can't be skipped or forgotten, no contributor setup
- Can run lots of OS's, Python versions, compilers, etc
- Travis CI: Very popular for years, but not anymore.
- Jenkins: A self-host only OSS solution.
- Appveyor: The original Windows CI service.
- Circle CI: The first more “modern” design.
- GitLab CI: For years, this was one of the best services. Still very good.
- Azure Pipelines: Very modular design is easy to upgrade and maintain.
- GitHub Actions (GHA): Extremely simple and popular. Actions are easy to write and share.
We first need to briefly discuss exit codes and YAML.
- Every time you run a command in a shell there is an exit code that indicates if it ran successfully, or if there was an error.
- An exit code of
0
indicates that the command ran successfully, other numbers indicate an error. - Sometimes different numbers correspond to different errors.
> mkdir test
> echo $?
0
> mkdir test
mkdir: test: File exists
> echo $?
1
> mkdir -z test
mkdir: illegal option -- z
usage: mkdir [-pv] [-m mode] directory_name ...
> echo $?
64
- CI workflows will typically stop once they encounter a non-zero exit code.
- Sometimes you may need to run a command that might fail, but you want the workflow to proceed.
- Some scripts and binaries don't respect this standard and return non-zero exit codes even when successful.
Error codes can be ignored using logical or (||)
> mkdir -z test || echo "ignore"
ignore
It is also useful to use logical and (&&) to run a command only if another one is successful.
> <command1> && <command2>
YAML (YAML Ain’t Markup Language, originally Yet Another Markup Language) is a human-readable data serialization language.
- Easy to read and use
- Very commonly used in CI configuration files.
- File extension is .yml or .yaml
Defining scalar values:
number-value: 42
boolean-value: true # can also be on or yes
string-value: "Hello world"
another-string: String without quotes
Defining lists:
colors:
- red
- green
- blue
more_colors: [black, white]
Defining dictionaries:
person:
name: John Smith
age: 33
occupation: accountant
same_person: {name: John Smith, age: 33, occupation: accountant}
Defining multi-line strings:
some-text: >
Multiple
lines
of
text
same-text: "Multiple lines of text\n"
Defining multi-line strings:
some-text: |
Multiple
lines
of
text
same-text: "Multiple\nlines\nof\ntext\n"
- Each workflow is configured by a yaml file placed in
.github/workflows
- Can be set to trigger by a wide variety of events
- Can run your own commands or use actions written by you or third-parties
This is the basic structure of a workflow file.
on: <event or list of events>
jobs:
job_1:
name: <name of job>
runs-on: <type of machine>
steps:
- run: <command1>
- name: <name of step>
run: <command 2>
job_2:
name: <name of job>
runs-on: <type of machine>
steps:
- uses: <some third-party action>
Go to the following link:
https://github.com/ariostas-talks/2024-07-31-cicd
Create a new workflow that generates these slides and publishes them to GitHub pages. Things you need:
actions/checkout
actions/setup-python
markdown-slides
from https://gitlab.com/da_doomer/markdown-slidesactions/upload-pages-artifact
actions/deploy-pages
- Repo > Settings > Pages > Source > GitHub Actions
Start by checking out the repo.
- name: Check out repo
uses: actions/checkout@v4
Then set up Python.
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
Install markdown-slides
.
- name: Install markdown slides
run: pip install git+https://gitlab.com/da_doomer/markdown-slides.git
Generate the slides.
- name: Generate slides
run: mdslides slides.md --output_dir slides
Upload pages artifact
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./slides
Deploy to GitHub Pages
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
There's many more things to learn, but with this basic knowledge there is lots of things you can do!