Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

Commit

Permalink
Add basic build/tests
Browse files Browse the repository at this point in the history
This is taken directly from python-docker tests

We also synchronise the packages between them
  • Loading branch information
bloodearnest committed Dec 10, 2021
1 parent d68e7de commit afb5b41
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 58 deletions.
34 changes: 8 additions & 26 deletions .github/workflows/publish_docker.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
name: Tag repo; build and publish assets
name: Build and publish
on:
push:
branches:
- master
workflow_dispatch:
branches: [main]
env:
IMAGE_NAME: jupyter
jobs:
tag-new-version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.new_version }}
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Bump version and push tag
id: tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false

build-and-publish-docker-image:
runs-on: ubuntu-latest
name: Build and publish docker image
needs: tag-new-version
if: needs.tag-new-version.outputs.tag
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@master
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
run: make build
- name: Run tests
run: make test
- name: Log into GitHub Container Registry
run: docker login https://ghcr.io -u ${{ github.actor }} --password ${{ secrets.DOCKER_RW_TOKEN }}
- name: Push image to GitHub Container Registry
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Run tests
on:
pull_request:
env:
IMAGE_NAME: jupyter
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@master
- name: Build image
run: make build
- name: Run tests
run: make test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*~
*~
__pycache__
.venv
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
IMAGE_NAME ?= docker-jupyter-test
INTERACTIVE:=$(shell [ -t 0 ] && echo 1)
export DOCKER_BUILDKIT=1

.PHONY: build
build: BUILD_DATE=$(shell date +'%y-%m-%dT%H:%M:%S.%3NZ')
build: GITREF=$(shell git rev-parse --short HEAD)
build:
docker build . --tag $(IMAGE_NAME) --progress=plain \
--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ghcr.io/opensafely-core/jupyter \
--build-arg BUILD_DATE=$(BUILD_DATE) --build-arg GITREF=$(GITREF)


.PHONY: test
ifdef INTERACTIVE
test: RUN_ARGS=-it
else
test: RUN_ARGS=
endif
test:
docker run $(RUN_ARGS) --rm -v $(PWD):/tests -w /tests $(IMAGE_NAME) pytest tests -v


.PHONY: lint
lint:
@docker pull hadolint/hadolint
@docker run --rm -i hadolint/hadolint < Dockerfile



requirements.txt: requirements.in .venv/bin/pip-compile
.venv/bin/pip-compile requirements.in
Expand Down
16 changes: 15 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ jupyterlab
jupytext
bash_kernel
nbval
opensafely-matching

# Commonly-used packages provided in base docker image
pandas-gbq
pandas
numpy
ebmdatalab
matplotlib
scipy
tqdm
numba
opensafely-cohort-extractor
pyarrow
venn
kaleido
scikit-learn

# Both these required for plotly+notebooks
plotly
Expand All @@ -23,5 +31,11 @@ ipywidgets
py-spy

# Add extra per-notebook packages here
pyodbc
pillow

# Allow for projects to run tests inside the container
pytest


# interactive use on level 3
pyodbc
Loading

0 comments on commit afb5b41

Please sign in to comment.