diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..8d81162 --- /dev/null +++ b/.github/workflows/test.yaml @@ -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 diff --git a/docs/ci.md b/docs/ci.md index de35024..c1edb54 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -17,7 +17,7 @@ marp: true To ensure quality, consistency and reproducibility of your research, --> # Continuous Integration -
works on my machine +works on my machine Source: [Reddit - Programmer Humor - Works on my Machine](https://www.reddit.com/r/ProgrammerHumor/comments/70we66/it_works_on_my_machine/) @@ -54,6 +54,8 @@ on: - "*" tags: - "v*" + schedule: + - cron: 0 9 * * 1 workflow_call: workflow_dispatch: ``` @@ -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 + +
+ +```yaml +jobs: + build-docs: + uses: ./.github/workflows/build_docs.yml + deploy: + needs: [build-docs, pre-commit] +``` +
--- +#### Chained workflow example + +Chained workflow + +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 +Manual workflow call --- + +## 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 diff --git a/docs/documentation.md b/docs/documentation.md index 73e188b..4d20ef2 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -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) ----