Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into remove-data-env-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
okaycj committed Oct 29, 2024
2 parents 6c60ded + 7230f51 commit 205972e
Show file tree
Hide file tree
Showing 35 changed files with 290 additions and 94 deletions.
5 changes: 0 additions & 5 deletions .changeset/cold-chairs-confess.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/early-seahorses-brush.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/large-rabbits-matter.md

This file was deleted.

7 changes: 7 additions & 0 deletions .changeset/mean-llamas-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lookit/templates": patch
"@lookit/record": patch
"@lookit/data": patch
---

Generate environment file before production build
7 changes: 0 additions & 7 deletions .changeset/moody-points-cheat.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/nice-hats-sing.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/shaggy-toes-swim.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/silver-pigs-develop.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/smart-books-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@lookit/record": patch
---

Add missing default value for video consent "additional_segments" parameter,
which was causing an error when this optional parameter was omitted (#84).
6 changes: 0 additions & 6 deletions .changeset/strange-bottles-invent.md

This file was deleted.

8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
node: ["18.x", "20.x"]

steps:
- uses: actions/checkout@v4
Expand All @@ -25,6 +25,12 @@ jobs:
- name: Install NPM dependencies
run: npm ci

- name: Create environment file
run: printenv > .env
env:
DEBUG: "false"
LOCAL_DOWNLOAD: "false"

- name: Build packages
run: npm run build

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
node-version: "20.x"
cache: npm

- name: Install pango for NPM package "canvas"
Expand Down
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,37 @@ npm i @jspsych/config -w @lookit/<name of new package>

## Build all packages

We can use npm workspaces to build all packages.
First, create a `.env` file at the root of the monorepo. It can contain the
following for a successful local development build.

First, install dependencies:
```
DEBUG=true
LOCAL_DOWNLOAD=true
```

Next, we can use npm to install dependencies.

```
npm ci
```

Build all packages:
Then, build all packages.

```
npm run build
```

## Linting/formating

Lint and formating is done at the monorepo level.
Lint and formatting is done at the monorepo level.

To auto fix linting/formating issues:
To auto fix linting/formatting issues:

```
npm run fix
```

Unfixable issues will be diplayed as errors.
Unfixable issues will be displayed as errors.

## Change log

Expand All @@ -129,7 +135,38 @@ Adding a change log through `changeset` is done with the following command:
npm run changeset
```

Make sure to add the change log found in the `.changeset` directory to the PR.
Try to only bump packages that have actual changes and be sure to add the change
log found in the `.changeset` directory to the PR.

## Package Release

Package release is automated using github actions. You can find the release
script in this repo in the `.github/workflows/` directory.

The NPM token required to release packages should never expire. If, for some
reason, a new token is required. You will have to first generate one through
NPM.

1. Login to https://www.npmjs.com.
2. Select "Access Tokens" from your user dropdown.
3. In the "Generate New Token" dropdown, select "Classic Token".
4. Give the token a meaningful name, select "Automation" radio button, and
click "Generate Token".
5. Copy token or leave the website open. If you close this page without
copying, you will have to generate a new token. There will be no way to get
it back.

Next we have to move the NPM token to github actions.

1. Login to Github and goto
https://github.com/lookit/lookit-jspsych/settings/secrets/actions.
2. Click the "Pencil" icon next to `NPM_TOKEN`.
3. Paste NPM token from above. There won't be a token in the value box. This is
to keep the current token secret.
4. Click "Update secret".

This should allow the release script to be able to publish our packages without
authentication.

## Run dev server

Expand Down
7 changes: 7 additions & 0 deletions packages/data/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @lookit/data

## 0.0.4

### Patch Changes

- b111054: Update rollup config to hide known circular warnings
- 888be3d: Update to unpkg config

## 0.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lookit/data",
"version": "0.0.3",
"version": "0.0.4",
"description": "This is a JS implementation of lookit's RESTful API.",
"homepage": "https://github.com/lookit/lookit-jspsych#readme",
"bugs": {
Expand Down
9 changes: 9 additions & 0 deletions packages/lookit-initjspsych/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @lookit/lookit-initjspsych

## 0.0.4

### Patch Changes

- b111054: Update rollup config to hide known circular warnings
- Updated dependencies [b111054]
- Updated dependencies [888be3d]
- @lookit/data@0.0.4

## 0.0.3

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/lookit-initjspsych/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lookit/lookit-initjspsych",
"version": "0.0.3",
"version": "0.0.4",
"description": "This package overloads jsPsych's init function.",
"homepage": "https://github.com/lookit/lookit-jspsych#readme",
"bugs": {
Expand All @@ -26,7 +26,7 @@
"test": "jest --coverage"
},
"dependencies": {
"@lookit/data": "0.0.3"
"@lookit/data": "0.0.4"
},
"devDependencies": {
"@jspsych/config": "^2.0.0"
Expand Down
23 changes: 23 additions & 0 deletions packages/record/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# @lookit/record

## 0.0.4

### Patch Changes

- bb6754c: Move translations and video consent templates to new templates
package.
- c879e6a: Add ability to select specific video consent template.
- 4e72f2b: Adds `chs_type: "consent"` to consentVideo trial data and updates the
lookit-api response object with `completed_consent_frame: true` at the end of
the consentVideo trial.
- b111054: Update rollup config to hide known circular warnings
- 2a3ce6d: Change video file names to match existing format, and to pass
necessary info to AWS Lambda for saving video files to database.
- 496b62d: Unmute playback of recorded consent video.
- 9385555: Add Garden's consent template
- Updated dependencies [bb6754c]
- Updated dependencies [c879e6a]
- Updated dependencies [b111054]
- Updated dependencies [888be3d]
- Updated dependencies [9385555]
- @lookit/templates@0.0.1
- @lookit/data@0.0.4

## 0.0.3

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/record/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lookit/record",
"version": "0.0.3",
"version": "0.0.4",
"description": "Recording extensions and plugins for CHS studies.",
"homepage": "https://github.com/lookit/lookit-jspsych#readme",
"bugs": {
Expand Down Expand Up @@ -46,8 +46,8 @@
"typescript": "^5.6.2"
},
"peerDependencies": {
"@lookit/data": "^0.0.3",
"@lookit/templates": "^0.0.0",
"@lookit/data": "^0.0.4",
"@lookit/templates": "^0.0.1",
"jspsych": "^8.0.2"
}
}
2 changes: 1 addition & 1 deletion packages/record/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default makeRollupConfig("chsRecord").map((config) => {
plugins: [
...config.plugins,
// Add support for .env files
dotenv(),
dotenv({ cwd: "../../" }),
// Add support to import yaml and handlebars files as strings
importAsString({
include: ["**/*.yaml", "**/*.hbs"],
Expand Down
2 changes: 1 addition & 1 deletion packages/record/src/consentVideo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ test("recordButton", async () => {

// Start recorder
expect(Recorder.prototype.start).toHaveBeenCalledTimes(1);
expect(Recorder.prototype.start).toHaveBeenCalledWith("consent");
expect(Recorder.prototype.start).toHaveBeenCalledWith(true, "consent-video");
});

test("playButton", () => {
Expand Down
11 changes: 6 additions & 5 deletions packages/record/src/consentVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ const info = <const>{
additional_segments: {
type: ParameterType.COMPLEX,
array: true,
default: [],
nested: {
title: {
type: ParameterType.STRING,
default: "",
},
},
text: {
type: ParameterType.STRING,
default: "",
text: {
type: ParameterType.STRING,
default: "",
},
},
},
prompt_all_adults: { type: ParameterType.BOOL, default: false },
Expand Down Expand Up @@ -212,7 +213,7 @@ export class VideoConsentPlugin implements JsPsychPlugin<Info> {
play.disabled = true;
next.disabled = true;
this.getImg(display, "record-icon").style.visibility = "visible";
await this.recorder.start("consent");
await this.recorder.start(true, VideoConsentPlugin.info.name);
});
}

Expand Down
12 changes: 9 additions & 3 deletions packages/record/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ jest.mock("./recorder");
jest.mock("@lookit/data");
jest.mock("jspsych", () => ({
...jest.requireActual("jspsych"),
initJsPsych: jest
.fn()
.mockReturnValue({ finishTrial: jest.fn().mockImplementation() }),
initJsPsych: jest.fn().mockReturnValue({
finishTrial: jest.fn().mockImplementation(),
getCurrentTrial: jest
.fn()
.mockReturnValue({ type: { info: { name: "test-type" } } }),
}),
}));

/**
Expand Down Expand Up @@ -41,14 +44,17 @@ test("Trial recording", () => {
const mockRecStop = jest.spyOn(Recorder.prototype, "stop");
const jsPsych = initJsPsych();
const trialRec = new Rec.TrialRecordExtension(jsPsych);
const getCurrentPluginNameSpy = jest.spyOn(trialRec, "getCurrentPluginName");

trialRec.on_start();
trialRec.on_load();
trialRec.on_finish();

expect(Recorder).toHaveBeenCalledTimes(1);
expect(mockRecStart).toHaveBeenCalledTimes(1);
expect(mockRecStart).toHaveBeenCalledWith(false, "test-type");
expect(mockRecStop).toHaveBeenCalledTimes(1);
expect(getCurrentPluginNameSpy).toHaveBeenCalledTimes(1);
});

test("Trial recording's initialize does nothing", async () => {
Expand Down
Loading

0 comments on commit 205972e

Please sign in to comment.