Skip to content

Commit

Permalink
feat: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoMagnini committed May 3, 2023
1 parent 58aa9a8 commit 49086bb
Show file tree
Hide file tree
Showing 10 changed files with 38,801 additions and 335 deletions.
20 changes: 20 additions & 0 deletions .github/scripts/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

DT=${2:-${RETRY_TIME:-5m}}
MAX=${3:-${MAX_RETRIES:-3}}

for N in `seq 1 $MAX`; do
echo "Attempt $N/$MAX: $1"
eval $1;
RESULT=$?
if [[ $RESULT -eq 0 ]]; then
exit 0
fi
if [[ $N -lt $MAX ]]; then
echo "Failed attempt $N/$MAX. Waiting $DT"
sleep $DT
else
echo "Failed attempt $N/$MAX."
exit $RESULT
fi
done
43 changes: 43 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: check
on:
push:
branches:
- main
- master
- develop
- 'feature/**'
env:
PROJECT_NAME: demo-lime
WORKFLOW: check
jobs:
run-notebooks:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
python-version:
- '3.9.12'
runs-on: ${{ matrix.os }}
name: Run notebooks on Python ${{ matrix.python-version }}, on ${{ matrix.os }}
timeout-minutes: 15
concurrency:
group: ${{ github.workflow }}-run-notebooks-${{ matrix.python-version }}-${{ matrix.os }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Checkout code
uses: actions/checkout@v3

- name: Restore Python dependencies
run: |
pip install -r requirements.txt
- name: Run notebooks
run: |
python -m treon
50 changes: 50 additions & 0 deletions .github/workflows/dockerify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: dockerify
on:
workflow_run:
workflows:
- release
types:
- completed
branches:
- main
- master
- develop
env:
PROJECT_NAME: demo-lime
WORKFLOW: dockerify
RETRY_TIME: 1m
MAX_RETRIES: 2
jobs:
dockerify:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: Dockerify with Jupyter support
steps:
- name: Docker Login
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # all history
submodules: recursive

- name: Get All Tags
run: git fetch --tags -f

- name: Get Version
id: get-version
run: echo "version=$(python setup.py get_project_version | tail -n 1)" >> $GITHUB_OUTPUT

- name: Create Docker Image
run: |
./.github/scripts/retry.sh "docker build -t pikalab/demo-lime:$TUTORIAL_VERSION --build-arg TUTORIAL_VERSION=$TUTORIAL_VERSION ."
docker tag pikalab/demo-lime:$TUTORIAL_VERSION pikalab/demo-lime:latest
shell: bash
env:
TUTORIAL_VERSION: '${{ steps.get-version.outputs.version }}'

- name: Push Image on Docker Hub
run: |
docker push pikalab/demo-lime:${{ steps.get-version.outputs.version }}
docker push pikalab/demo-lime:latest
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: release
on:
workflow_run:
workflows:
- check
types:
- completed
branches:
- main
- master
- develop
env:
PROJECT_NAME: demo-lime
WORKFLOW: release
jobs:
deploy:
runs-on: ubuntu-latest
name: Create release
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # all history

- name: Get All Tags
run: git fetch --tags -f

- name: Get Python Version
id: get-python-version
run: echo "version=$(cat .python-version)" >> $GITHUB_OUTPUT

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ steps.get-python-version.outputs.version }}

- name: Restore Python dependencies
run: |
pip install -r requirements.txt
- name: Pack
run: python -m build

- name: Archive Dist Artifacts
if: failure() || success()
uses: actions/upload-artifact@v3
with:
name: dist
path: './dist'

- name: Get Version
id: get-version
run: echo "version=$(python setup.py get_project_version | tail -n 1)" >> $GITHUB_OUTPUT

- name: Release Assets
id: upload-release-assets
run: |
set -x
ASSETS=()
for A in dist/*; do
ASSETS+=("-a" "$A")
echo "Releasing $A"
done
RELEASE_TAG='${{ steps.get-version.outputs.version }}'
hub release create "${ASSETS[@]}" -m "$RELEASE_TAG" "$RELEASE_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.12
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.9
EXPOSE 8888
RUN apt update; apt install -y -q openjdk-17-jdk
RUN pip install jupyter
RUN pip install lime
COPY requirements.txt .
RUN pip install -r requirements-demo.txt
RUN mkdir -p /root/.jupyter
ENV JUPYTER_CONF_FILE /root/.jupyter/jupyter_notebook_config.py
RUN echo "c.NotebookApp.allow_origin = '*'" > $JUPYTER_CONF_FILE
RUN echo "c.NotebookApp.ip = '0.0.0.0'" >> $JUPYTER_CONF_FILE
RUN mkdir -p /notebooks
COPY *.ipynb /notebooks/
COPY data /notebooks/data
WORKDIR /notebooks
CMD jupyter notebook --allow-root --no-browser
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.13
Loading

0 comments on commit 49086bb

Please sign in to comment.