Skip to content

Commit

Permalink
Merge pull request #1 from endlessm/ci
Browse files Browse the repository at this point in the history
Initial github-actions configuration
  • Loading branch information
manuq authored Jan 18, 2021
2 parents 1339605 + 383fe3e commit c6a0aaf
Show file tree
Hide file tree
Showing 30 changed files with 434 additions and 185 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('kolibri-tools/.eslintrc');
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
lint:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Lint
run: tox -e lint
24 changes: 24 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Yarn build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
node10:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Node10
run: tox -e node10.x
29 changes: 29 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test python

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
py:
runs-on: ubuntu-18.04
strategy:
matrix:
python: [ 2.7, 3.5, 3.6, 3.7, 3.8 ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: python
env:
PYTHON: py${{ matrix.python }}
run: tox -e $PYTHON
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
*.swp

node_modules/*
kolibri_explore_plugin/static/*
kolibri_explore_plugin/build/*
kolibri_explore_plugin/__pycache__
build/*
dist/*
kolibri_explore_plugin.egg-info/*

# virtual environment
venv/
.python-version
.envrc
.env
Pipfile
1 change: 1 addition & 0 deletions .htmlhintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('kolibri-tools/.htmlhintrc');
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
exclude: (\.git/|\.tox/|\.venv/|build/|static/|dist/|node_modules/)
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: trailing-whitespace
- id: flake8
- id: check-yaml
- id: check-added-large-files
- id: debug-statements
- id: end-of-file-fixer
exclude: '^.+?(\.json|\.po)$'
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.3.3
hooks:
- id: reorder-python-imports
language_version: python2.7
- repo: local
hooks:
- id: lint-frontend
name: Linting of JS, Vue, SCSS and CSS files
description: This hook handles all frontend linting for Kolibri
entry: yarn run lint-frontend:format
language: system
files: \.(js|vue|scss|css)$

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('kolibri-tools/.prettierrc');
1 change: 1 addition & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('kolibri-tools/.stylelintrc');
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,30 @@ Deployment
----------

1. Clone this repo.
2. Open terminal in your Kolibri repo.
3. Run the following commands, with your Kolibri development virtual env
enabled:
2. Install dependencies with pipenv

```
pipenv --python 3
pipenv shell
pip install -r requirements.txt --upgrade
```

3. Install node.js and yarn

```
nodeenv -p --node=10.15.3
npm install -g yarn
```

3. Install plugin javascript dependencies and build

```
yarn install
```

4. Now that all dependencies are installed, it's possible to build using make

```
make dist
```

Expand All @@ -51,13 +69,7 @@ folder.

5. Upload to PyPi:

You should have python `twine` package installed:

```
pip install twine
```

Then you can publish the generated `dist/kolibri_explore_plugin*.whl` to pypi
You can publish the generated `dist/kolibri_explore_plugin*.whl` to pypi
just running:

```
Expand All @@ -83,3 +95,12 @@ calling the `make dist` again, you should remove the `kolibri_explore_plugin`:
```
pip uninstall kolibri_explore_plugin
```

Configure precommit hook
------------------------

To run lint before any commit just run this command:

```
pre-commit install -f --install-hooks
```
2 changes: 1 addition & 1 deletion kolibri_explore_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.1'
__version__ = "0.0.1"
7 changes: 6 additions & 1 deletion kolibri_explore_plugin/assets/src/app.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import router from 'kolibri.coreVue.router';
import KolibriApp from 'kolibri_app';
import RootVue from './views/ExploreIndex';
import routes from './routes';
import { setFacilitiesAndConfig } from './modules/coreExplore/actions';
import pluginModule from './modules/pluginModule';
import KolibriApp from 'kolibri_app';

/* eslint-disable class-methods-use-this */
class ExploreModule extends KolibriApp {
get stateSetters() {
return [setFacilitiesAndConfig];
}

get routes() {
return routes;
}

get RootVue() {
return RootVue;
}

get pluginModule() {
return pluginModule;
}

ready() {
// after every navigation, block double-clicks
router.afterEach((toRoute, fromRoute) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ export function pageMode(state) {
PageNames.TOPICS_TOPIC,
PageNames.TOPICS_CONTENT,
];
const pageNameMatches = page => page === state.pageName;

function pageNameMatches(page) {
return page === state.pageName;
}

if (topicsPages.some(pageNameMatches)) {
return PageModes.TOPICS;
}
return undefined;

return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function normalizeContentNode(node) {
return {
...node,
kind: node.parent ? node.kind : ContentNodeKinds.CHANNEL,
thumbnail: getContentNodeThumbnail(node) || undefined,
thumbnail: getContentNodeThumbnail(node) || null,
breadcrumbs: tail(node.ancestors),
progress: Math.min(node.progress_fraction || 0, 1.0),
};
Expand Down
68 changes: 33 additions & 35 deletions kolibri_explore_plugin/assets/src/modules/topicsRoot/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export function showChannels(store) {
const rootNodes = channels
.map(channel => {
const node = _collectionState(channelCollection).find(n => n.channel_id === channel.id);
if (node) {
// The `channel` comes with additional data that is
// not returned from the ContentNodeResource.
// Namely thumbnail, description and tagline (so far)
node.thumbnail = channel.thumbnail;
node.description = channel.description;
node.tagline = channel.tagline;
return node;
}
if (!node) return null;

// The `channel` comes with additional data that is
// not returned from the ContentNodeResource.
// Namely thumbnail, description and tagline (so far)
node.thumbnail = channel.thumbnail;
node.description = channel.description;
node.tagline = channel.tagline;
return node;
})
.filter(Boolean);
store.commit('topicsRoot/SET_STATE', { rootNodes });
Expand Down Expand Up @@ -63,32 +63,30 @@ export function showFilteredChannels(store) {
const node = _collectionState(channelCollection).find(
n => n.channel_id === channel.id
);
if (node) {
// The `channel` comes with additional data that is
// not returned from the ContentNodeResource.
// Namely thumbnail, description and tagline (so far)
node.thumbnail = channel.thumbnail;
node.description = channel.description;
node.tagline = channel.tagline;
const getParams = {
search: CUSTOM_PRESENTATION_TITLE,
kind: ContentNodeKinds.HTML5,
channel_id: channel.id,
};
return ContentNodeSearchResource.getCollection(getParams)
.fetch()
.then(({ results }) => {
if (results.length) {
const thumb = results[0].files.find(file =>
file.preset.endsWith('thumbnail')
);
if (thumb) {
node.html5Thumbnail = thumb.storage_url;
}
return node;
}
});
}
if (!node) return null;

// The `channel` comes with additional data that is
// not returned from the ContentNodeResource.
// Namely thumbnail, description and tagline (so far)
node.thumbnail = channel.thumbnail;
node.description = channel.description;
node.tagline = channel.tagline;
const getParams = {
search: CUSTOM_PRESENTATION_TITLE,
kind: ContentNodeKinds.HTML5,
channel_id: channel.id,
};
return ContentNodeSearchResource.getCollection(getParams)
.fetch()
.then(({ results }) => {
if (!results.length) return null;

const thumb = results[0].files.find(file => file.preset.endsWith('thumbnail'));
if (thumb) {
node.html5Thumbnail = thumb.storage_url;
}
return node;
});
})
);
})
Expand Down
Loading

0 comments on commit c6a0aaf

Please sign in to comment.