Skip to content

Commit

Permalink
Merge pull request #1 from ICTLearningSciences/initial-release
Browse files Browse the repository at this point in the history
initial release
  • Loading branch information
beatthat authored Nov 21, 2019
2 parents 59a18c0 + 8e8157d commit e4dee97
Show file tree
Hide file tree
Showing 57 changed files with 46,964 additions and 1 deletion.
166 changes: 166 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
version: 2.1
aliases:
- &only-tagged-releases
tags:
only: /^\d+\.\d+\.\d+(-[a-z\d\-.]+)?$/
branches:
ignore: /.*/
- &only-untagged
tags:
ignore: /.*/
orbs:
docker: circleci/[email protected]
executors:
node:
docker:
- image: circleci/node:12.4
python:
docker:
- image: circleci/python:3.6.9
jobs:
client-format:
executor: node
steps:
- checkout
- run:
name: Install client
command: cd client && npm install
- run:
name: Client test format
command: cd client && npm run test:format
client-audit:
executor: node
steps:
- checkout
- run:
name: Audit js
command: cd client && npm run test:audit
client-lint:
executor: node
steps:
- checkout
- run:
name: Install client
command: cd client && npm install
- run:
name: Client test lint
command:
cd client && npm run test:lint
client-types:
executor: node
steps:
- checkout
- run:
name: Install client
command: cd client && npm install
- run:
name: Client test types
command:
cd client && npm run test:types
client-test:
executor: node
steps:
- checkout
- run:
name: Install client
command: cd client && npm install
- run:
name: Client test
command:
cd client && npm run test
build-and-push:
parameters:
is-release-tag:
type: boolean
default: false
executor: docker/docker
steps:
- unless:
condition: <<parameters.is-release-tag>>
steps:
- run:
name: "set image tag to commit sha"
command: |
echo 'export IMAGE_TAG="$CIRCLE_SHA1"' >> $BASH_ENV
- when:
condition: <<parameters.is-release-tag>>
steps:
- run:
name: "override image tag to release tag"
command: |
echo 'export IMAGE_TAG="$CIRCLE_TAG"' >> $BASH_ENV
- run:
name: report tag
command: echo "building tag uscictdocker/mentor-client:${IMAGE_TAG}..."
- setup_remote_docker
- checkout
- docker/check
- run:
name: Build setup
command: |
sudo apt-get update \
&& sudo apt-get install -y rsync \
&& cd node \
&& make clean build
- docker/build:
path: node
image: uscictdocker/mentor-client
tag: ${IMAGE_TAG}
- docker/push:
digest-path: /tmp/digest.txt
image: uscictdocker/mentor-client
tag: ${IMAGE_TAG}
- run:
command: |
echo "Digest is: $(</tmp/digest.txt)"
workflows:
test-build-deploy:
jobs:
- client-format:
filters: *only-untagged
- client-audit:
filters: *only-untagged
- client-lint:
filters: *only-untagged
- client-types:
filters: *only-untagged
- client-test:
filters: *only-untagged
- approve-build-and-push:
filters: *only-untagged
type: approval
requires:
- client-format
- client-audit
- client-lint
- client-types
- client-test
- build-and-push:
is-release-tag: false
filters: *only-untagged
requires:
- approve-build-and-push
test-build-deploy-release:
jobs:
- client-format:
filters: *only-tagged-releases
- client-audit:
filters: *only-tagged-releases
- client-lint:
filters: *only-tagged-releases
- client-types:
filters: *only-tagged-releases
- client-test:
filters: *only-tagged-releases
- build-and-push:
is-release-tag: true
filters: *only-tagged-releases
requires:
- client-format
- client-audit
- client-lint
- client-types
- client-test



2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bower_components
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
build

# Dependency directories
node_modules/
Expand Down
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PHONY: audit-fix
audit-fix:
cd client && $(MAKE) audit-fix

PHONY: format
format:
cd client && $(MAKE) format

PHONY: test
test:
cd client && $(MAKE) test

PHONY: test-all
test-all:
$(MAKE) test-audit
$(MAKE) test-format
$(MAKE) test-lint
$(MAKE) test-types
$(MAKE) test

PHONY: test-audit
test-audit:
cd client && $(MAKE) test-audit
cd node && $(MAKE) test-audit

PHONY: test-format
test-format:
cd client && $(MAKE) test-format
cd node && $(MAKE) test-format

PHONY: test-lint
test-lint:
cd client && $(MAKE) test-lint
cd node && $(MAKE) test-lint

PHONY: test-types
test-types:
cd client && $(MAKE) test-types
cd node && $(MAKE) test-types
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
mentor-client
==================

Usage
-----

A docker image that serves a web client for question/answer sessions using prerecorded mentor videos and an AI classifier provided by [mentor-api](https://github.com/ICTLearningSciences/mentor-api)


Variables
---------

In order to function properly the client generally requires these environment variables defined:

- **MENTOR_API_URL**: The base url for the the [mentor-api](https://github.com/ICTLearningSciences/mentor-api), e.g. https://mentorpal.org/mentor-api

- **MENTOR_VIDEO_URL**: The base url for the mentor videos, e.g. https://video.mentorpal.org/videos


Development
-----------

Any changes made to this repo should be covered by tests. To run the existing tests:

```
make test
```

All pushed commits must also pass format and lint checks. To check all required tests before a commit:

```
make test-all
```

To fix formatting issues:

```
make format
```

Releases
--------

Currently, this image is semantically versioned. When making changes that you want to test in another project, create a branch and PR and then you can release a test tag one of two ways:

To build/push a work-in-progress tag of `mentor-client` for the current commit in your branch

- find the `docker_tag_commit` workflow for your commit in [circleci](https://circleci.com/gh/ICTLearningSciences/workflows/mentor-client)
- approve the workflow
- this will create a tag like `https://hub.docker.com/mentor-client:${COMMIT_SHA}`

To build/push a pre-release semver tag of `mentor-client` for the current commit in your branch

- create a [github release](https://github.com/ICTLearningSciences/mentor-client/releases/new) **from your development branch** with tag format `/^\d+\.\d+\.\d+(-[a-z\d\-.]+)?$/` (e.g. `1.0.0-alpha.1`)
- find the `docker_tag_release` workflow for your git tag in [circleci](https://circleci.com/gh/ICTLearningSciences/workflows/mentor-client)
- approve the workflow
- this will create a tag like `uscictdocker/mentor-client:1.0.0-alpha.1`



Once your changes are approved and merged to master, you should create a release tag in semver format as follows:

- create a [github release](https://github.com/ICTLearningSciences/mentor-client/releases/new) **from master** with tag format `/^\d+\.\d+\.\d$/` (e.g. `1.0.0`)
- find the `docker_tag_release` workflow for your git tag in [circleci](https://circleci.com/gh/ICTLearningSciences/workflows/mentor-client)
- approve the workflow
- this will create a tag like `uscictdocker/mentor-client:1.0.0`
5 changes: 5 additions & 0 deletions client/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
static
public
.cache
.gitignore
60 changes: 60 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
extends: [
"eslint:recommended",
"plugin:jest/recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
settings: {
react: {
version: "detect",
},
},
env: {
browser: true,
es6: true,
node: true,
"jest/globals": true,
},
plugins: ["@typescript-eslint", "jest", "react"],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
},
rules: {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"no-prototype-builtins": "off",
"react/display-name": "off",
"react/prop-types": "off", // Disable prop-types as we use TypeScript for type checking
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
},
settings: {
react: {
version: "detect", // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
overrides: [
// Override some TypeScript rules just for .js files
{
files: ["*.js"],
rules: {
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/no-var-requires": "off",
},
},
],
};
Loading

0 comments on commit e4dee97

Please sign in to comment.