Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chiruzzimarco committed Aug 4, 2022
0 parents commit b1a8f43
Show file tree
Hide file tree
Showing 46 changed files with 2,025 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[bumpversion]
current_version = 0.0.1
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.dev(?P<dev>\d+))?
serialize =
{major}.{minor}.{patch}.dev{dev}
{major}.{minor}.{patch}
commit-args = --no-verify

[bumpversion:file:setup.py]

[bumpversion:file:derex/mfe_profile/__init__.py]

[bumpversion:file:docker_build/Dockerfile]
search = DEREX_MFE_LEARNING_VERSION={current_version}
replace = DEREX_MFE_LEARNING_VERSION={new_version}
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ [ -x "$(command -v python3.10)" ] && layout_python python3.10 && echo Using python3.10; } ||
{ [ -x "$(command -v python3.9)" ] && layout_python python3.9 && echo Using python3.9; } ||
{ [ -x "$(command -v python3.8)" ] && layout_python python3.8 && echo Using python3.8; } ||
{ [ -x "$(command -v python3.7)" ] && layout_python python3.7 && echo Using python3.7; } ||
{ echo No suitable python version found. Exiting; exit 1 ; }

export DOCKER_BUILDKIT=1
export DOCKER_CLI_EXPERIMENTAL=enabled
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- Derex Profile Microfrontend version:
- Python version:
- Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
25 changes: 25 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
inputs:
DEVELOPMENT_MODE:
description: "Wheter the package should be installed in development mode. Defaults to false"
default: "false"
required: true

runs:
using: "composite"
steps:
- name: Setup python dependencies
run: |
set -x
pip install --cache-dir ${{ github.workspace }}/.cache/pip -U pip setuptools
pip install --cache-dir ${{ github.workspace }}/.cache/pip -r requirements.txt
shell: bash

- name: Install this package
run: |
set -x
if [ ${{ inputs.DEVELOPMENT_MODE }} == true ]; then
pip install --cache-dir ${{ github.workspace }}/.cache/pip -e .
else
pip install --cache-dir ${{ github.workspace }}/.cache/pip .
fi
shell: bash
208 changes: 208 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: "CI workflow"
on:
push:
# This will avoid multiple pipelines for being started when pushing
# to a PR branch.
# It will run the pipeline when the PR is merged though
branches:
- master
pull_request:
# We need to specify we want to run only on branch pushes
# and not tags
branches:
- "**"

env:
CACHE_VERSION: 1
PYTHON_VERSION: 3.8
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
OPENEDX_VERSION: ["lilac"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup pip cache
uses: actions/cache@v2
with:
path: "${{ github.workspace }}/.cache/pip"
key: ${{ env.CACHE_VERSION }}-${{ env.PYTHON_VERSION }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ env.CACHE_VERSION }}-${{ env.PYTHON_VERSION }}-pip-

- name: Setup derex
uses: ./.github/actions/setup
with:
DEVELOPMENT_MODE: true

- name: Setup submodules
run: |
git submodule init
git submodule update
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: |
set -x
export DOCKER_BUILDKIT=1
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
derex build mfe-profile ${{ matrix.OPENEDX_VERSION }}
docker save $(derex build mfe-profile --only-print-image-name) -o mfe-docker-build.tar
- name: Upload built docker image
uses: actions/upload-artifact@v2
with:
name: mfe-docker-build
path: examples/${{ matrix.OPENEDX_VERSION }}/minimal/mfe-docker-build.tar

test:
name: Test
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
PYTHON_VERSION: [3.7, 3.7, 3.8, 3.9, 3.10]
OPENEDX_VERSION: ["lilac"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup pip cache
uses: actions/cache@v2
with:
path: "${{ github.workspace }}/.cache/pip"
key: ${{ env.CACHE_VERSION }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ env.CACHE_VERSION }}-${{ matrix.PYTHON_VERSION }}-pip-

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Download built docker image
uses: actions/download-artifact@v2
with:
name: mfe-docker-build
path: /tmp

- name: Load image
run: |
docker load --input /tmp/mfe-docker-build.tar
docker image ls -a
- name: Setup derex
uses: ./.github/actions/setup

- name: "Start services"
run: ddc-services up -d

- name: "Prime Mysql, Rabbitmq and Elasticsearch"
run: |
set -ex
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
derex mysql reset --force
derex reset-rabbitmq
- name: "Start lms and profile MFE"
run: |
set -ex
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
ddc-project config
derex build final
ddc-project up -d lms mfe-profile
# Give the containers some time to boot
sleep 10
- name: "Show logs"
run: |
set -ex
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
ddc-project logs
- name: "Test that the profile MFE is working"
run: |
echo "TODO"
push:
name: Push
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
OPENEDX_VERSION: ["lilac"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- name: Setup pip cache
uses: actions/cache@v2
with:
path: "${{ github.workspace }}/.cache/pip"
key: ${{ env.CACHE_VERSION }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ env.CACHE_VERSION }}-${{ matrix.PYTHON_VERSION }}-pip-

- name: Setup derex
uses: ./.github/actions/setup
with:
DEVELOPMENT_MODE: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Download built docker image
uses: actions/download-artifact@v2
with:
name: mfe-docker-build
path: /tmp

- name: Load image
run: |
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
docker load --input /tmp/mfe-docker-build.tar
docker image ls -a
- name: Tag image as latest if on master
if: ${{ github.ref == 'refs/heads/master' }}
run: |
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
docker tag \
$(derex build mfe-profile ${{ matrix.OPENEDX_VERSION }} --only-print-image-name) \
$(derex build mfe-profile ${{ matrix.OPENEDX_VERSION }} --only-print-image-name | sed 's/:.*/:latest/')
- name: Do not tag image if we are not on master
if: ${{ github.ref != 'refs/heads/master' }}
run: |
echo "You are not on master ! Infact you are on ${{ github.ref }}"
- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image to docker registry
run: |
cd examples/${{ matrix.OPENEDX_VERSION }}/minimal/
docker push $(derex build mfe-profile ${{ matrix.OPENEDX_VERSION }} --only-print-image-name | sed 's/:.*//') -a
Loading

0 comments on commit b1a8f43

Please sign in to comment.