Skip to content

Commit

Permalink
Merge pull request #22 from classroom-interaction-environment/fix-lint
Browse files Browse the repository at this point in the history
ci: Implement testsuite, linter and make code compliant
  • Loading branch information
jankapunkt committed Dec 5, 2022
2 parents dab2e8d + f270c2c commit 1e144f7
Show file tree
Hide file tree
Showing 287 changed files with 10,722 additions and 10,309 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/create-comments-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Add immediate comment on new issues

on:
issues:
types: [ opened ]

jobs:
createComment:
runs-on: ubuntu-latest
steps:
- name: Create Comment
uses: peter-evans/create-or-update-comment@v1.4.2
with:
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for submitting this issue!
We, the developers of CLAIRE take every issue seriously.
Our goal is to provide a long-term maintainable system that is entirely for free.
However, we can't guarantee you issues to be solved within certain time.
If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.
Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know.
160 changes: 67 additions & 93 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,105 @@ on:
pull_request:

jobs:
lintcode:
lintCode:
name: Javascript lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3

- name: setup node
uses: actions/setup-node@v3
with:
node-version: 14

- name: setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-14-
- name: cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-14-
- run: |
cd src
npm ci
npm run lint:code
- run: |
cd src
npm ci --no-optional
npm run lint:code
lintstyle:
lintStyle:
name: SCSS lint
runs-on: ubuntu-latest
needs: [lintcode]
needs: [ lintCode ]
steps:
- name: checkout
uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3

- name: setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 14

- name: cache dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-14-
- run: |
cd src
npm ci
npm run lint:style
- name: cache dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-14-
- run: |
cd src
npm ci --no-optional
npm run lint:style
lintdocs:
lintDocs:
name: documentation lint
runs-on: ubuntu-latest
needs: [lintcode,lintstyle]
needs: [ lintCode,lintStyle ]
steps:
- name: checkout
uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3

- name: setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 14

- name: cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-14-
- run: |
cd src
npm ci
npm run lint:markdown
- name: cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-14-
- run: |
cd src
npm ci --no-optional
npm run lint:markdown
tests:
name: Meteor ${{ matrix.meteor }} tests
runs-on: ubuntu-latest
steps:
# CACHING
- name: checkout
uses: actions/checkout@v3

- name: Install Meteor
id: cache-meteor-install
uses: actions/cache@v3
with:
path: ~/.meteor
key: v1-meteor-${{ hashFiles('.meteor/versions') }}
restore-keys: |
v1-meteor-
v1-meteor-
- name: Cache NPM dependencies
id: cache-meteor-npm
uses: actions/cache@v3
with:
path: ~/.npm
key: v1-npm-${{ hashFiles('package-lock.json') }}
key: ${{ runner.os }}-node-14-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
v1-npm-
${{ runner.os }}-node-14-
- name: Cache Meteor build
id: cache-meteor-build
uses: actions/cache@v3
Expand All @@ -114,45 +117,16 @@ jobs:
.meteor/local/isopacks
.meteor/local/bundler-cache/scanner
key: v1-meteor_build_cache-${{ github.ref }}-${{ github.sha }}
restore-key: |
restore-keys: |
v1-meteor_build_cache-
- name: Setup meteor
uses: meteorengineer/setup-meteor@v1
with:
meteor-release: '2.7.3'

- name: Install NPM Dependencies
run: meteor npm ci

# uses -o for running once -c for coverage
- name: Run Tests
run: |
cd src
sh ./scripts/test.sh -c -o
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
name: coverage-folder
path: src/.coverage/

coverage:
name: Coverage report
runs-on: ubuntu-latest
needs: [tests]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download coverage
uses: actions/download-artifact@v2
with:
name: coverage-folder
path: src/.coverage/


- name: Coverage Report
uses: VeryGoodOpenSource/very_good_coverage@v1.1.1
with:
path: ".coverage/lcov.info"
min_coverage: 65 # TODO increase to 95!
meteor npm ci --no-optional
sh ./scripts/test.sh -c -o -p
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CLAIRE - The Classroom Interaction Runtime Environment

[![built with Meteor](https://img.shields.io/badge/Meteor-2.7.3-green?logo=meteor&logoColor=white)](https://meteor.com)
[![Test suite](https://github.com/classroom-interaction-environment/claire/actions/workflows/tests.yml/badge.svg)](https://github.com/classroom-interaction-environment/claire/actions/workflows/tests.yml)
[![CodeQL](https://github.com/classroom-interaction-environment/claire/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/classroom-interaction-environment/claire/actions/workflows/codeql-analysis.yml)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
![GitHub](https://img.shields.io/github/license/classroom-interaction-environment/claire)
Expand Down Expand Up @@ -95,7 +97,8 @@ the provided run script:

```bash
$ cd src
$ meteor npm install
$ meteor npm run install:core
$ meteor npm run install:peers
$ ./scripts/run.sh
```

Expand Down
1 change: 1 addition & 0 deletions src/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ claire:item-range
# TESTING
#========================================
meteortesting:mocha@2.0.2
meteortesting:browser-tests@1.5.1
lmieulet:meteor-coverage@3.2.0
hwillson:stub-collections

4 changes: 2 additions & 2 deletions src/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ logging@1.3.1
mdg:validated-method@1.2.0
meteor@1.10.0
meteor-base@1.5.1
meteortesting:browser-tests@1.3.5
meteortesting:browser-tests@1.5.1
meteortesting:mocha@2.0.3
meteortesting:mocha-core@8.1.2
minifier-css@1.6.1
Expand All @@ -90,7 +90,7 @@ mongo@1.15.0
mongo-decimal@0.1.3
mongo-dev-server@1.1.0
mongo-id@1.0.8
muqube:autoform-nouislider@0.6.0
muqube:autoform-nouislider@0.5.2
npm-mongo@4.3.1
observe-sequence@1.0.20
ordered-dict@1.1.0
Expand Down
11 changes: 8 additions & 3 deletions src/.settings-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const optionalBoolean = {

const monitorSchema = schema({
constructView: optionalBoolean,
onCreated:optionalBoolean,
onCreated: optionalBoolean,
onRendered: optionalBoolean,
onDestroyed: optionalBoolean,
registerHelper: optionalBoolean,
Expand Down Expand Up @@ -90,12 +90,17 @@ module.exports = schema({
'fixtures.teacher': optionalArray,
'fixtures.teacher.$': accountsFixtureSchema,
'fixtures.schoolAdmin': optionalArray,
'fixtures.schoolAdmin.$': accountsFixtureSchema,
'fixtures.schoolAdmin.$': accountsFixtureSchema
}),
patch: patchSchema,
public: schema({
logLevel: {
type: Number,
optional: true,
allowedValues: [0, 1, 2, 3, 4]
},
features: schema({
groups:Boolean
groups: Boolean
}),
defaultLocale: String,
templateMonitor: monitorSchema,
Expand Down
12 changes: 11 additions & 1 deletion src/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"extends": "stylelint-config-sass-guidelines"
"extends": "stylelint-config-sass-guidelines",
"rules": {
"selector-no-qualifying-type": [
true,
{
"ignore": [
"attribute"
]
}
]
}
}
3 changes: 1 addition & 2 deletions src/imports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Could also be named "system". Most general layer.
Contains fundamental parts to build the system, which
then can be used to provide an API.


## API

Contains shared functions, classes and interfaces.
Expand All @@ -23,7 +22,7 @@ More concrete and application-specific implementations.
## Contexts

Similar to "domain".
Contains the static and descriptive definitions of contextual objects
Contains the static and descriptive definitions of contextual objects
(think domain objects).

## Startup
Expand Down
18 changes: 7 additions & 11 deletions src/imports/api/accounts/admin/createAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ import { getCollection } from '../../utils/getCollection'
import { matchNonEmptyString } from '../../utils/check/matchNonEmptyString'
import { Admin } from '../../../contexts/system/accounts/admin/Admin'

let AdminCollection

/**
* Adds a user by user id to the Admins collection.
* @param userId
* @param newAdminId {string} the user _id of the user who will be new admin
* @return {String} the doc id of the the user's entry in the admin collection
*/

export const createAdmin = function (userId) {
check(userId, matchNonEmptyString)
export const createAdmin = function (newAdminId) {
check(newAdminId, matchNonEmptyString)

if (!AdminCollection) {
AdminCollection = getCollection(Admin.name)
}
const AdminCollection = getCollection(Admin.name)

if (AdminCollection.find({ userId }).count() > 0) {
throw new Meteor.Error('createAdmin.failed', 'createAdmin.alreadyAdmin', userId)
if (AdminCollection.find({ userId: newAdminId }).count() > 0) {
throw new Meteor.Error('createAdmin.failed', 'createAdmin.alreadyAdmin', { adminId: newAdminId })
}

return AdminCollection.insert({ userId })
return AdminCollection.insert({ userId: newAdminId })
}
Loading

0 comments on commit 1e144f7

Please sign in to comment.