Skip to content

Commit 52fc462

Browse files
committed
migrate CI build workflow to repo
1 parent 979f4c9 commit 52fc462

8 files changed

Lines changed: 247 additions & 46 deletions

File tree

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
# Check for updates to GitHub Actions every day
12+
interval: "daily"
13+
time: "09:00"
14+
timezone: "UTC"
15+
assignees:
16+
- "jimboid"

.github/workflows/build.yaml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: ci/cd
2+
on:
3+
pull_request:
4+
repository_dispatch:
5+
types: [build]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
platform:
14+
- linux/amd64
15+
- linux/arm64
16+
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-24.04' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
17+
name: build ${{ matrix.platform }}
18+
outputs:
19+
tag: ${{ steps.envvars.outputs.tag }}
20+
steps:
21+
- name: checkout
22+
uses: actions/checkout@v5.0.0
23+
24+
- name: Prepare env
25+
id: envvars
26+
run: |
27+
platform=${{ matrix.platform }}
28+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
29+
if [ ${{ github.event.client_payload.tag }} != 'null' ]; then
30+
echo "tag=${{ github.event.client_payload.tag }}" >> $GITHUB_OUTPUT
31+
else
32+
echo "tag=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
33+
fi
34+
35+
- name: Metadata
36+
id: meta
37+
uses: docker/metadata-action@v5.8.0
38+
with:
39+
images: ghcr.io/${{ github.repository }}
40+
41+
- name: Authenticate with GHCR
42+
id: auth
43+
uses: docker/login-action@v3.5.0
44+
with:
45+
registry: ghcr.io
46+
username: ${{github.actor}}
47+
password: ${{secrets.BUILD_TOKEN}}
48+
49+
- name: Set up Docker Buildx
50+
id: buildx
51+
uses: docker/setup-buildx-action@v3.11.1
52+
53+
- name: Build and push by digest
54+
id: build
55+
uses: docker/build-push-action@v6.18.0
56+
with:
57+
platforms: ${{ matrix.platform }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
tags: ghcr.io/${{ github.repository }}
60+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
61+
62+
- name: Export digest
63+
run: |
64+
mkdir -p ${{ runner.temp }}/digests
65+
digest="${{ steps.build.outputs.digest }}"
66+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
67+
68+
- name: Upload digest
69+
uses: actions/upload-artifact@v4.6.2
70+
with:
71+
name: digests-${{ env.PLATFORM_PAIR }}
72+
path: ${{ runner.temp }}/digests/*
73+
if-no-files-found: error
74+
retention-days: 1
75+
76+
merge:
77+
runs-on: ubuntu-24.04
78+
name: merge into multiarch manifest
79+
needs:
80+
- build
81+
steps:
82+
- name: Download digests
83+
uses: actions/download-artifact@v5.0.0
84+
with:
85+
path: ${{ runner.temp }}/digests
86+
pattern: digests-*
87+
merge-multiple: true
88+
89+
- name: Authenticate with GHCR
90+
id: auth
91+
uses: docker/login-action@v3.5.0
92+
with:
93+
registry: ghcr.io
94+
username: ${{github.actor}}
95+
password: ${{secrets.BUILD_TOKEN}}
96+
97+
- name: Set up Docker Buildx
98+
id: buildx
99+
uses: docker/setup-buildx-action@v3.11.1
100+
101+
- name: Metadata
102+
id: meta
103+
uses: docker/metadata-action@v5.8.0
104+
with:
105+
images: ghcr.io/${{ github.repository }}
106+
tags: dev
107+
108+
- name: Create manifest list and push
109+
id: annotate
110+
continue-on-error: true
111+
working-directory: ${{ runner.temp }}/digests
112+
run: |
113+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
114+
--annotation='index:org.opencontainers.image.description=${{ github.event.repository.description }}' \
115+
--annotation='index:org.opencontainers.image.licenses=MIT' \
116+
--annotation='index:org.opencontainers.image.created=${{ steps.timestamp.outputs.timestamp }}' \
117+
--annotation='index:org.opencontainers.image.url=${{ github.event.repository.url }}' \
118+
--annotation='index:org.opencontainers.image.source=${{ github.event.repository.url }}' \
119+
$(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)
120+
121+
- name: Create manifest list and push without annotations
122+
if: steps.annotate.outcome == 'failure'
123+
working-directory: ${{ runner.temp }}/digests
124+
run: |
125+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
126+
$(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)
127+
128+
- name: Inspect image
129+
run: |
130+
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:dev
131+
132+
tests:
133+
strategy:
134+
fail-fast: false
135+
matrix:
136+
platform:
137+
- linux/amd64
138+
- linux/arm64
139+
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
140+
name: testing on ${{ matrix.platform }}
141+
timeout-minutes: 360
142+
needs:
143+
- build
144+
- merge
145+
steps:
146+
147+
- name: Test notebooks
148+
shell: bash
149+
run: |
150+
docker run -t ghcr.io/${{ github.repository }}:dev bash -c " \
151+
pip install pytest nbmake; \
152+
find . -name '*.ipynb' | pytest --nbmake --nbmake-timeout=3600; "
153+
154+
tags:
155+
runs-on: ubuntu-24.04
156+
if: github.event_name != 'pull_request'
157+
name: add tags
158+
needs:
159+
- build
160+
- tests
161+
steps:
162+
- name: Authenticate with GHCR
163+
id: auth
164+
uses: docker/login-action@v3.5.0
165+
with:
166+
registry: "ghcr.io"
167+
username: ${{github.actor}}
168+
password: ${{secrets.BUILD_TOKEN}}
169+
170+
- name: tag release versions
171+
shell: bash
172+
run: |
173+
docker buildx imagetools create \
174+
--tag ghcr.io/${{ github.repository }}:latest \
175+
--tag ghcr.io/${{ github.repository }}:${{ needs.build.outputs.tag }} \
176+
ghcr.io/${{ github.repository }}:dev
177+
178+
- name: Post version update to dash
179+
uses: peter-evans/repository-dispatch@v3.0.0
180+
with:
181+
token: ${{ secrets.BUILD_TOKEN }}
182+
repository: jimboid/biosim-workshops-dash
183+
event-type: build
184+
client-payload: '{"repo": "${{ github.event.repository.name }}", "tag": "${{ needs.build.outputs.tag }}"}'

Dockerfile

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
# CCP-BioSim Training Course: Basic MD data analysis with MDTraj
2-
IPython (Jupyter) notebooks are a great environment in which to do exploratory analysis of MD data. This workshop illustrates how two key Python packages - *numpy* and *matplotlib* - can be used with the MD analysis package [mdtraj](http://mdtraj.org/1.9.3/) for some simple standard analysis tasks.
1+
# CCPBioSim Basic Analysis Workshop
32

4-
## Requirements
5-
A basic knowledge of Python and MD simulation methods.
3+
[![build](https://github.com/ccpbiosim/basic-analysis-workshop/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/ccpbiosim/basic-analysis-workshop/actions/workflows/build.yaml)
64

7-
## Training material
8-
A Jupyter notebook and example data files.
5+
## Docker
6+
7+
This container is derived from the CCPBioSim JupyterHub image. This container
8+
adds the necessary software packages and notebook content to form a deployable
9+
course container. The source content for this course can be found at
10+
https://github.com/CCPBioSim/basic-analysis-workshop
11+
12+
## How to Use
13+
14+
In our containers we are using the JupyterHub default port 8888, so you should
15+
forward this port when deploying locally::
16+
17+
docker run -p 8888:8888 ghcr.io/jimboid/biosim-basic-analysis-workshop:latest
918

1019
## Contact
1120
Please direct all questions and feedback to [Charlie Laughton](mailto:charles.laughton@nottingham.ac.uk)

_config.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

docker/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Start with BioSim base image.
2+
ARG BASE_IMAGE=latest
3+
FROM ghcr.io/ccpbiosim/jupyterhub-base:$BASE_IMAGE
4+
5+
LABEL maintainer="James Gebbie-Rayet <james.gebbie@stfc.ac.uk>"
6+
LABEL org.opencontainers.image.source=https://github.com/ccpbiosim/biosim-basic-analysis-workshop
7+
LABEL org.opencontainers.image.description="A container environment for the ccpbiosim workshop on basic analysis."
8+
LABEL org.opencontainers.image.licenses=MIT
9+
10+
# Switch to jovyan user.
11+
USER $NB_USER
12+
WORKDIR $HOME
13+
14+
# Install workshop deps
15+
RUN conda install matplotlib numpy nglview ipywidgets -y
16+
RUN pip install mdtraj
17+
18+
# Get workshop files and move them to jovyan directory.
19+
COPY --chown=1000:100 . .
20+
RUN rm -r AUTHORS LICENSE README.md docker .git .github
21+
22+
# Copy lab workspace
23+
COPY --chown=1000:100 docker/default-37a8.jupyterlab-workspace /home/jovyan/.jupyter/lab/workspaces/default-37a8.jupyterlab-workspace
24+
25+
# UNCOMMENT THIS LINE FOR REMOTE DEPLOYMENT
26+
COPY docker/jupyter_notebook_config.py /etc/jupyter/
27+
28+
# Always finish with non-root user as a precaution.
29+
USER $NB_USER
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"tab-area","currentIndex":0,"widgets":["notebook:Basic analysis.ipynb"]},"current":"notebook:Basic analysis.ipynb"},"left":{"collapsed":false,"current":"filebrowser","widgets":["filebrowser","running-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"]},"right":{"collapsed":true,"widgets":["jp-property-inspector"]}},"notebook:Basic analysis.ipynb":{"data":{"path":"Basic analysis.ipynb","factory":"Notebook"}}},"metadata":{"id":"default"}}

docker/jupyter_notebook_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
c.JupyterHub.authenticator_class = 'tmpauthenticator.TmpAuthenticator'

0 commit comments

Comments
 (0)