Skip to content

Commit cb15342

Browse files
authored
Initial commit
0 parents  commit cb15342

19 files changed

+686
-0
lines changed

.github/workflows/binder.yaml.disable

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html
2+
name: Test this PR on Binder Badge
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
permissions:
8+
pull-requests:
9+
write
10+
11+
jobs:
12+
binder:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: comment on PR with Binder link
16+
uses: actions/github-script@v3
17+
with:
18+
github-token: ${{secrets.GITHUB_TOKEN}}
19+
script: |
20+
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
21+
var PR_HEAD_REF = process.env.PR_HEAD_REF;
22+
github.issues.createComment({
23+
issue_number: context.issue.number,
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}) :point_left: Test this PR on Binder`
27+
})
28+
env:
29+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
30+
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Build and push container image, and push update to datahub repo if needed
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
env:
11+
DOCKER_CONFIG: $HOME/.docker
12+
IMAGE: ${{ vars.IMAGE }}
13+
outputs:
14+
image-tag: ${{ steps.build-and-push.outputs.IMAGE_SHA_TAG }}
15+
16+
steps:
17+
- name: Cleanup disk space
18+
run: |
19+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
20+
df -h
21+
22+
- name: Check out the image repo
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
26+
27+
- name: Get changed files
28+
id: changed-files
29+
uses: tj-actions/changed-files@v44
30+
with:
31+
files_ignore: |
32+
README.md
33+
CONTRIBUTING.md
34+
LICENSE
35+
.github/**
36+
images/**
37+
38+
- name: Log in to GAR
39+
if: steps.changed-files.outputs.any_changed == 'true'
40+
uses: docker/login-action@v3
41+
with:
42+
registry: us-central1-docker.pkg.dev
43+
username: _json_key
44+
password: ${{ secrets.GAR_SECRET_KEY }}
45+
46+
- name: Build the image and push to artifact registry
47+
id: build-and-push
48+
if: steps.changed-files.outputs.any_changed == 'true'
49+
uses: jupyterhub/repo2docker-action@master
50+
with:
51+
DOCKER_REGISTRY: us-central1-docker.pkg.dev
52+
IMAGE_NAME: ${{ env.IMAGE }}
53+
# Disable pushing a 'latest' tag, as this often just causes confusion
54+
LATEST_TAG_OFF: true
55+
# Put repo contents in /srv/repo, rather than the default (/home/jovyan). The home directory
56+
# is mounted over by persistent storage when we are using the built image in a JupyterHub, and
57+
# so all contents put in /home/jovyan are lost. This particularly prevents any 'start' script from
58+
# working, as it is needed in runtime.
59+
REPO_DIR: /srv/repo
60+
61+
# Lets us monitor disks getting full as images get bigger over time
62+
- name: Show how much disk space is left
63+
run: df -h
64+
65+
update-deployment-image-tag:
66+
runs-on: ubuntu-latest
67+
needs: build-and-push
68+
env:
69+
HUB: ${{ vars.HUB }}
70+
IMAGE: ${{ vars.IMAGE }}
71+
IMAGE_TAG: ${{ needs.build-and-push.outputs.image-tag }}
72+
73+
steps:
74+
- name: Checkout the datahub repo
75+
if: ${{ env.IMAGE_TAG }}
76+
uses: actions/checkout@v4
77+
with:
78+
token: ${{ secrets.DATAHUB_CREATE_PR }}
79+
fetch-depth: 0
80+
repository: 'berkeley-dsep-infra/datahub'
81+
sparse-checkout: |
82+
deployments/
83+
hub/
84+
85+
- name: Set git identity
86+
if: ${{ env.IMAGE_TAG }}
87+
run: |
88+
git config --global user.email "${{ vars.IMAGE_BUILDER_BOT_EMAIL }}"
89+
git config --global user.name "${{ vars.IMAGE_BUILDER_BOT_NAME }}"
90+
91+
- name: Update the tag for any deployments that use this image
92+
if: ${{ env.IMAGE_TAG }}
93+
run: |
94+
for deployment in $(grep -lr ${IMAGE} deployments/ | grep hubploy.yaml); do
95+
old_hash=$(grep ${IMAGE} ${deployment} | awk -F":" '{print $3}')
96+
new_hash=${IMAGE_TAG}
97+
sed -i -e "s/${old_hash}/${new_hash}/g" ${deployment}
98+
echo "Updated ${deployment} with new image tag ${new_hash}"
99+
done
100+
101+
- name: Create feature branch, add, commit and push changes
102+
if: ${{ env.IMAGE_TAG }}
103+
run: |
104+
CHANGED_FILES=$(git status --porcelain -uno | awk '{print $2}')
105+
git diff
106+
git checkout -b update-${HUB}-image-tag-${IMAGE_TAG}
107+
# to be safe, only add files that have changed
108+
for file in $(echo -e ${CHANGED_FILES}); do
109+
git add ${file}
110+
done
111+
git commit -m "update ${HUB} image tag to ${IMAGE_TAG}: ${CHANGED_FILES}"
112+
git push origin update-${HUB}-image-tag-${IMAGE_TAG}
113+
114+
- name: Print out a message if no PR is created
115+
if: ${{ ! env.IMAGE_TAG }}
116+
run: |
117+
echo "Image not updated, no push to datahub repo required"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and test container image
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
test-build:
8+
runs-on: ubuntu-latest
9+
env:
10+
DOCKER_CONFIG: $HOME/.docker
11+
steps:
12+
- name: cleanup disk space
13+
run: |
14+
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
15+
df -h
16+
17+
- name: Checkout files in repo
18+
uses: actions/checkout@v4
19+
20+
- name: See if the image config changed
21+
id: changed-files
22+
uses: tj-actions/changed-files@v44
23+
with:
24+
files_ignore: |
25+
README.md
26+
CONTRIBUTING.md
27+
LICENSE
28+
.github/**
29+
images/**
30+
31+
- name: What files changed?
32+
if: steps.changed-files.outputs.any_changed == 'true'
33+
env:
34+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
35+
run: |
36+
echo "One or more image file(s) has changed:"
37+
echo "$CHANGED_FILES"
38+
39+
- name: Build and test the image if any image file(s) changed
40+
if: steps.changed-files.outputs.any_changed == 'true'
41+
uses: jupyterhub/repo2docker-action@master
42+
with:
43+
REPO_DIR: /srv/repo
44+
NO_PUSH: true
45+
46+
# Lets us monitor disks getting full as images get bigger over time
47+
- name: Show how much disk space is left
48+
run: df -h

.github/workflows/yaml-lint.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Yaml lint"
2+
on:
3+
- pull_request # yamllint disable-line rule:truthy
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Install yamllint
12+
run: pip install yamllint==1.35.1
13+
14+
- name: Lint YAML files
15+
run: yamllint --no-warnings .

.gitignore

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

.yamllint.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This config represents running the command `yamllint -d relaxed .` with the
2+
# following extra rules:
3+
#
4+
# new-line-at-end-of-file:
5+
# level: warning
6+
# trailing-spaces:
7+
# level: warning
8+
#
9+
# We also ignore the cookiecutter directories as these often contain
10+
# jinja-style templating functions that yamllint doesn't play nicely with
11+
#
12+
# cribbed from https://github.com/2i2c-org/infrastructure/blob/main/.yamllint.yaml
13+
---
14+
extends: default
15+
16+
ignore: |
17+
**/template/**
18+
**/templates/**
19+
20+
rules:
21+
braces:
22+
level: warning
23+
max-spaces-inside: 1
24+
brackets:
25+
level: warning
26+
max-spaces-inside: 1
27+
colons:
28+
level: warning
29+
commas:
30+
level: warning
31+
comments: disable
32+
comments-indentation: disable
33+
document-start: disable
34+
empty-lines:
35+
level: warning
36+
hyphens:
37+
level: warning
38+
indentation:
39+
level: warning
40+
indent-sequences: consistent
41+
line-length: disable
42+
new-line-at-end-of-file:
43+
level: warning
44+
trailing-spaces:
45+
level: warning
46+
truthy: disable

0 commit comments

Comments
 (0)