Skip to content

Commit

Permalink
Add more slides
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgensd committed Nov 21, 2023
1 parent 1112fd8 commit d1c72e2
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test

on:
push:
branches: ["dokken/ci"]


jobs:
runs-on: "ubuntu:22.04"
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
test:
steps:
- name: "Use remote action"
uses: jorgensd/actions/install_dolfinx
169 changes: 167 additions & 2 deletions docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ marp: true
To ensure quality, consistency and reproducibility of your research, -->

# Continuous Integration
<center><img src="https://i.redd.it/6u77tkmyaomz.jpg" alt="works on my machine" class="bg-primary" width="400px">
<img src="https://i.redd.it/6u77tkmyaomz.jpg" alt="works on my machine" class="bg-primary" width="400px">

Source: [Reddit - Programmer Humor - Works on my Machine](https://www.reddit.com/r/ProgrammerHumor/comments/70we66/it_works_on_my_machine/)

Expand Down Expand Up @@ -54,6 +54,8 @@ on:
- "*"
tags:
- "v*"
schedule:
- cron: 0 9 * * 1
workflow_call:
workflow_dispatch:
```
Expand All @@ -67,9 +69,172 @@ on:
branches: main
```
* Workflow is triggered whenever a pull request is made against the main branch
* Can make a list of branches, or include all (`"*"`, or no branch `"!*"` or patterns `"v*"``)
* Can make a list of branches, or include all (`"*"`, or no branch `"!*"` or patterns `"v*"`)
---
### Run on push
```yaml
on:
push:
branches:
- "*"
tags:
- "v*"

```
#### Triggered whenever
* A push a commited to any branch
* A tag starting with `v` is created


---

### Run on schedule


```yaml
schedule:
- cron: 0 9 * * 1
```
* Triggered at a specific UCT time in POSIX cron syntax
* Easy interpreter at: [Crontab.guru](https://crontab.guru/#0_9_*_*_1)
---
### Run from another workflow
```yaml
on:
workflow_call:
```
* Incredibly powerful feature that makes it possible to make chains of workflows
<div style="display:contents;" data-marpit-fragment>
```yaml
jobs:
build-docs:
uses: ./.github/workflows/build_docs.yml
deploy:
needs: [build-docs, pre-commit]
```
<div/>
---
#### Chained workflow example
<img src="./chained.png" alt="Chained workflow" class="bg-primary" width="400px">
Source: [https://github.com/jorgensd/dolfinx_mpc/actions/runs/6932364745](https://github.com/jorgensd/dolfinx_mpc/actions/runs/6932364745)
---
#### Run workflow manually
```yaml
on:
workflow_dispatch:
```
- Run a workflow manually on CI
<img src="./workflow_dispatch.png" alt="Manual workflow call" class="bg-primary" width="1000px">
---
## Environment variables
```yaml
env:
PUBLISH_DIR: ./_build/html
PYTHON_VERSION: "3.10"
```
* Can be accessed as `${PUBLISH_DIR}` or `${{ env.PUBLISH_DIR }}` depending on context

---

## Setting up a set of jobs

```
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Run echo
run: echo "HELLO WORLD"
- name: Multiple commands
run: |
echo "HI"
ls
```
* Github supports [several architectures](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)
- Ubuntu (20.04, 22.04)
- Windows (2019, 2022)
- Mac (macos-11, macos-12)
---
## Complex dependencies? Use containers!
```yaml
jobs:
build:
runs-on: ubuntu-22.04
container: ghcr.io/fenics/dolfinx/dolfinx:nightly
steps:
- name: Run echo
run: python3 -c "import dolfinx; print(dolfinx.__version__)
```

* Docker containers hosted anywhere

---


## Complex steps to setup your problem? Create an action!

Github marketplace for actions: https://github.com/marketplace?category=&query=&type=actions

```yaml
jobs:
clone-repo:
runs-on: ubuntu-22.04
steps:
- name: Checkout current repo on current branch
uses: actions/checkout@v4
- name: Look at current files
run: ls

```

---

### Actions can take inputs

```yaml
jobs:
clone-repo:
runs-on: ubuntu-22.04
steps:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${PYTHON_VERSION}

```

---

### You can create your own actions
```yaml
- name: Install DOLFINx
uses: ./.github/actions/install-dolfinx
with:
dolfinx: main
ufl: main
ffcx: main
basix: main
petsc_arch: ${PETSC_ARCH}
```
Custom action available
1 change: 0 additions & 1 deletion docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,3 @@ https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring
![w:700 center](https://github.com/NilsJPWerner/autoDocstring/raw/HEAD/images/demo.gif)
---

0 comments on commit d1c72e2

Please sign in to comment.