Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release-v1.4.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmer committed Jan 11, 2022
2 parents 254757c + 102231d commit 0da21c8
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 18 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Unreleased changes

[Full changelog](https://github.com/mozilla-rally/core-addon/compare/v1.3.8...master)
[Full changelog](https://github.com/mozilla-rally/core-addon/compare/v1.4.0...master)

# v1.4.0 (2022-01-10)
[Full changelog](https://github.com/mozilla-rally/core-addon/compare/v1.3.8...v1.4.0)

* [#771](https://github.com/mozilla-rally/rally-core-addon/pull/771): Switch to rally-studies-v2 remote-settings collection, and add `minimumCoreVersion` gate.
* [#769](https://github.com/mozilla-rally/rally-core-addon/pull/769): Sort studies using order property, if present.

# v1.3.8 (2022-01-10)

[Full changelog](https://github.com/mozilla-rally/core-addon/compare/v1.3.7...v1.3.8)
* [#765](https://github.com/mozilla-rally/rally-core-addon/pull/765): Updates to CITP consent/IRB notices.

# v1.3.7 (2022-01-05)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is the Core Add-on for the Rally platform. It is implemented as a cross-bro

Rally studies are implemented as Add-ons. A [study template](https://github.com/mozilla-rally/study-template) is provided to help study authors start writing their study. A [demo website landing page](https://mozilla-rally.github.io/core-addon) is also available for testing the Core Add-on.

The "source of truth" for Rally study metadata is on the [Firefox remote settings server](https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/rally-study-addons-v1/records).
The "source of truth" for Rally study metadata is on the [Firefox remote settings server](https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/rally-study-addons-v2/records).

## Get started

Expand Down Expand Up @@ -105,10 +105,10 @@ const { RemoteSettings } = ChromeUtils.import(
"resource://services-settings/remote-settings.js"
);
```
3. Then, disable signature checking and fetch the latest `rally-studies-v1` collection:
3. Then, disable signature checking and fetch the latest `rally-studies-v2` collection:
```js
RemoteSettings("rally-studies-v1").verifySignature = false;
await RemoteSettings("rally-studies-v1").get();
RemoteSettings("rally-studies-v2").verifySignature = false;
await RemoteSettings("rally-studies-v2").get();
```
4. The UI for the core add-on options page should respond immediately. After making changes to the RS server, you can either wait or explicitly poll for updates:
```js
Expand Down
33 changes: 33 additions & 0 deletions core-addon/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,39 @@ export default class Core {
return s;
}).filter(study => (!study.studyPaused || study.studyJoined));

// Only show study if it is compatible with this version of the core add-on.
const coreVersion = browser.runtime.getManifest().version;

// Match the version number used by the core add-on, such as "1.3.7buildid20220107.052711".
// this uses capture groups to isolate the part before the build ID, the semantic version number "1.3.7".
const versionRegex = /^([0-9]+)\.([0-9]+)\.([0-9])s*$/;
const [fullCore, majorCore, minorCore, patchCore] = coreVersion.match(versionRegex);

// Filter out any studies that are unsupported on this version of the core add-on.
availableStudies = availableStudies.filter(study => {
const [fullStudy, majorStudy, minorStudy, patchStudy] = study.minimumCoreVersion.match(versionRegex);
if (majorStudy > majorCore) {
console.error(`Study ${study.addonId} requires core version ${fullStudy}, not compatible with ${fullCore}`);
return false;
}
if (majorStudy === majorCore) {
if (minorStudy > minorCore) {
console.error(`Study ${study.addonId} requires core version ${fullStudy}, not compatible with ${fullCore}`);
return false;
}
if (minorStudy === minorCore) {
if (patchStudy > patchCore) {
console.error(`Study ${study.addonId} requires core version ${fullStudy}, not compatible with ${fullCore}`);
return false;
}
}
}
return study;
});

// Sort studies using order property, if set.
availableStudies.sort((a, b) => a.order - b.order);

const newState = {
enrolled,
firstRunCompleted,
Expand Down
2 changes: 1 addition & 1 deletion core-addon/FirefoxPrivilegedApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ XPCOMUtils.defineLazyServiceGetters(this, {
* NOTE - we cannot control which Remote Settings server that Firefox uses, so we assume that this
* is a global key that will be correct no matter which server is used (dev, staging, release, etc.)
*/
const STUDY_COLLECTION_KEY = "rally-studies-v1";
const STUDY_COLLECTION_KEY = "rally-studies-v2";

this.firefoxPrivilegedApi = class extends ExtensionAPI {
getAPI(context) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Mozilla",
"manifest_version": 2,
"name": "Mozilla Rally",
"version": "1.3.8",
"version": "1.4.0",
"homepage_url": "https://github.com/mozilla-rally/rally-core-addon",
"icons": {
"48": "public/img/rally-favicon.svg",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rally_core",
"version": "1.3.8",
"version": "1.4.0",
"type": "module",
"scripts": {
"prebuild": "node scripts/setupTaskcluster.js",
Expand Down
3 changes: 2 additions & 1 deletion public/locally-available-studies.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"studyDetailsLink": "https://addons.mozilla.org/en-US/firefox/addon/ion-basic-study/",
"dataCollectionDetails": ["The date and time"],
"tags": ["misinformation", "social media", "demo"],
"schemaNamespace": "rally-basic-study-template"
"schemaNamespace": "rally-basic-study-template",
"minimumCoreVersion": "1.3.8"
}
]
9 changes: 8 additions & 1 deletion public/studies-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"studyEnded",
"studyPaused",
"description",
"dataCollectionDetails"
"dataCollectionDetails",
"minimumCoreVersion"
],
"properties": {
"name": {
Expand Down Expand Up @@ -84,6 +85,12 @@
"items": {
"type": "string"
}
},
"order": {
"type": "number"
},
"minimumCoreVersion": {
"type": "string"
}
}
}
2 changes: 1 addition & 1 deletion rollup.config.addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default (cliArgs) => {
// the permissions in manifest.json.
__STUDIES_LIST__: cliArgs['config-studies-list-url'] ?
`'${cliArgs['config-studies-list-url']}'` :
"'https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/rally-studies-v1/records'",
"'https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/rally-studies-v2/records'",
__DISABLE_REMOTE_SETTINGS__: !!cliArgs["config-disable-remote-settings"],
__BASE_SITE__: "https://rally.mozilla.org",
// Data submission is disabled by default. Use this option via the CLI
Expand Down
51 changes: 51 additions & 0 deletions tests/core-addon/integration/core_addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,55 @@ describe("Core-Addon", function () {

await this.driver.quit();
});

it("Should filter out studies that are too old for core add-on", async function () {
this.driver = await utils.getFirefoxDriver(true, {});

// Switch to browser UI context, so we can inject script to set up Remote Settings.
await this.driver.setContext(firefox.Context.CHROME);
await this.driver.executeScript(utils.initRemoteSettings, utils.RALLY_TEST_STUDY_REGISTRY, 1234567);
// Switch back to web content context (options page).
await this.driver.setContext(firefox.Context.CONTENT);

await utils.installRally(this.driver);
await utils.joinRally(this.driver);

// Switch to browser UI context, so we can inject script to modify Remote Settings.
const modifiedTestStudy = Object.assign({}, utils.RALLY_TEST_STUDY_REGISTRY);
// Mark study as paused.
// Check that a far future version of the core add-on is incompatible.
modifiedTestStudy.minimumCoreVersion = "1000.0.1";
await this.driver.setContext(firefox.Context.CHROME);
await this.driver.executeScript(utils.updateRemoteSettings, modifiedTestStudy, 1234567);
// Switch back to web content context (options page).
await this.driver.setContext(firefox.Context.CONTENT);

// Check that no studies are displayed.
const noStudySelector = By.xpath(`//div[text()="No available studies"]`);
await this.driver.wait(until.elementLocated(noStudySelector), utils.WAIT_FOR_PROPERTY);

// Switch to browser UI context, so we can inject script to modify Remote Settings.
await this.driver.setContext(firefox.Context.CHROME);
// Check that a far past version of the core add-on is compatible.
modifiedTestStudy.minimumCoreVersion = "0.0.1";
await this.driver.executeScript(utils.updateRemoteSettings, modifiedTestStudy, (1234567 + 2));
// Switch back to web content context (options page).
await this.driver.setContext(firefox.Context.CONTENT);

// Ensure that the study card for the base study is displayed.
const baseStudySelector = By.xpath(`//span[text()="Rally Base Study"]`);
await this.driver.wait(until.elementLocated(baseStudySelector), utils.WAIT_FOR_PROPERTY);
await this.driver.findElement(baseStudySelector);

// Install study, so we can ensure that marking it paused does not hide the "leave" functionality.
await utils.findAndAct(this.driver, By.xpath(`//button[text()="Join Study"]`), e => e.click());
await utils.findAndAct(this.driver, By.xpath(`(//button[text()="Accept & Enroll"])`), e => e.click());

// Switch to browser UI context, to interact with Firefox add-on install prompts.
await this.driver.setContext(firefox.Context.CHROME);
await utils.findAndAct(this.driver, By.css(`[label="Add"]`), e => e.click());
await utils.findAndAct(this.driver, By.css(`[label="Okay"]`), e => e.click());

await this.driver.quit();
});
});
4 changes: 2 additions & 2 deletions tests/core-addon/integration/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async function installRally(driver) {
*/
async function initRemoteSettings(testStudy, timestamp) {
const { RemoteSettings } = ChromeUtils.import("resource://services-settings/remote-settings.js");
const remoteSettingsKey = "rally-studies-v1";
const remoteSettingsKey = "rally-studies-v2";

const db = await RemoteSettings(remoteSettingsKey).db;
await db.create(testStudy);
Expand All @@ -284,7 +284,7 @@ async function initRemoteSettings(testStudy, timestamp) {
*/
async function updateRemoteSettings(modifiedTestStudy, timestamp) {
const { RemoteSettings } = ChromeUtils.import("resource://services-settings/remote-settings.js");
const remoteSettingsKey = "rally-studies-v1";
const remoteSettingsKey = "rally-studies-v2";

await RemoteSettings(remoteSettingsKey).emit("sync", { data: { current: [modifiedTestStudy] } });
}
Expand Down
6 changes: 4 additions & 2 deletions tests/core-addon/unit/Core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const FAKE_STUDY_NOT_INSTALLED_NAMESPACE = "fake-study-not-installed-namespace"
const FAKE_STUDY_LIST = [
{
"addonId": FAKE_STUDY_ID,
"schemaNamespace": FAKE_STUDY_NAMESPACE
"schemaNamespace": FAKE_STUDY_NAMESPACE,
"minimumCoreVersion": "0.0.1"
},
{
"addonId": FAKE_STUDY_ID_NOT_INSTALLED,
"schemaNamespace": FAKE_STUDY_NOT_INSTALLED_NAMESPACE
"schemaNamespace": FAKE_STUDY_NOT_INSTALLED_NAMESPACE,
"minimumCoreVersion": "0.0.1"
}
];
const FAKE_UUID = "c0ffeec0-ffee-c0ff-eec0-ffeec0ffeec0";
Expand Down

1 comment on commit 0da21c8

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

Taskcluster-GitHub attempted to create a task for this event with the following scopes:

["assume:repo:github.com/mozilla-rally/rally-core-addon:tag:v1.4.0","queue:route:checks","queue:scheduler-id:taskcluster-github"]

The expansion of these scopes is not sufficient to create the task, leading to the following:

Client ID static/taskcluster/github does not have sufficient scopes and is missing the following scopes:

assume:repo:github.com/mozilla-rally/rally-core-addon:branch:v1.4.0

This request requires the client to satisfy the following scope expression:

{
  "AllOf": [
    "assume:repo:github.com/mozilla-rally/rally-core-addon:branch:v1.4.0",
    "queue:route:checks",
    "queue:route:index.xpi.v2.rally-core-addon.revision.0da21c8dccea11b5d27dcc37c72dfc36d35ed9ef.taskgraph.decision",
    "queue:create-task:project:none",
    "queue:scheduler-id:xpi-level-1",
    {
      "AnyOf": [
        "queue:create-task:highest:xpi-1/decision",
        "queue:create-task:very-high:xpi-1/decision",
        "queue:create-task:high:xpi-1/decision",
        "queue:create-task:medium:xpi-1/decision",
        "queue:create-task:low:xpi-1/decision",
        "queue:create-task:very-low:xpi-1/decision",
        "queue:create-task:lowest:xpi-1/decision"
      ]
    }
  ]
}

  • method: createTask
  • errorCode: InsufficientScopes
  • statusCode: 403
  • time: 2022-01-11T04:50:49.564Z

Please sign in to comment.