Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More skip options, fixes #1103 #1104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/ota-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ program
.option('-s, --services [serviceId...]', 'service IDs of services to track')
.option('-t, --types [termsType...]', 'terms types to track')
.option('-e, --extract-only', 'extract versions from existing snapshots with latest declarations and engine, without recording new snapshots')
.option('--schedule', 'track automatically at a regular interval');
.option('--schedule', 'track automatically at a regular interval')
.option('--skipPreRun', 'skip the pre run')
.option('--skipReadBack', 'skip the read-back of snapshots')
.option('--skipSnapshots', 'skip both the writing and the read-back of the snapshots');

track(program.parse(process.argv).opts());
14 changes: 9 additions & 5 deletions src/archivist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Archivist extends events.EventEmitter {
});
}

async track({ services: servicesIds = this.servicesIds, types: termsTypes = [], extractOnly = false } = {}) {
async track({ services: servicesIds = this.servicesIds, types: termsTypes = [], extractOnly = false, skipSnapshots = false, skipReadBack = false } = {}) {
const numberOfTerms = Service.getNumberOfTerms(this.services, servicesIds, termsTypes);

this.emit('trackingStarted', servicesIds.length, numberOfTerms, extractOnly);
Expand All @@ -114,7 +114,7 @@ export default class Archivist extends events.EventEmitter {
return;
}

this.trackingQueue.push({ terms: this.services[serviceId].getTerms({ type: termsType }), extractOnly });
this.trackingQueue.push({ terms: this.services[serviceId].getTerms({ type: termsType }), extractOnly, skipSnapshots, skipReadBack });
});
});

Expand All @@ -127,13 +127,17 @@ export default class Archivist extends events.EventEmitter {
this.emit('trackingCompleted', servicesIds.length, numberOfTerms, extractOnly);
}

async trackTermsChanges({ terms, extractOnly = false }) {
async trackTermsChanges({ terms, extractOnly = false, skipReadBack = false, skipSnapshots = false }) {
if (!extractOnly) {
await this.fetchSourceDocuments(terms);
await this.recordSnapshots(terms);
if (!skipSnapshots) {
await this.recordSnapshots(terms);
}
}

await this.loadSourceDocumentsFromSnapshots(terms);
if (!skipSnapshots && !skipReadBack) {
await this.loadSourceDocumentsFromSnapshots(terms);
}

if (terms.sourceDocuments.filter(sourceDocument => !sourceDocument.content).length) {
// If some source documents do not have associated snapshots, it is not possible to generate a fully valid version
Expand Down
12 changes: 7 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

const require = createRequire(import.meta.url);

export default async function track({ services, types, extractOnly, schedule }) {
const archivist = new Archivist({
export default async function track({ services, types, extractOnly, skipPreRun, skipSnapshots, skipReadBack, schedule }) {
const archivist = new Archivist({

Check failure on line 15 in src/index.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-20.04)

Expected indentation of 2 spaces but found 4

Check failure on line 15 in src/index.js

View workflow job for this annotation

GitHub Actions / test (windows-latest)

Expected indentation of 2 spaces but found 4

Check failure on line 15 in src/index.js

View workflow job for this annotation

GitHub Actions / test (macos-latest)

Expected indentation of 2 spaces but found 4
recorderConfig: config.get('@opentermsarchive/engine.recorder'),
fetcherConfig: config.get('@opentermsarchive/engine.fetcher'),
});
Expand All @@ -39,9 +39,11 @@

// The result of the extraction step that generates the version from the snapshots may depend on changes to the engine or its dependencies.
// The process thus starts by only performing the extraction process so that any version following such changes can be labelled (to avoid sending notifications, for example)
await archivist.track({ services, types, extractOnly: true });
if (!skipPreRun) {
await archivist.track({ services, types, extractOnly: true, skipSnapshots });
}

if (extractOnly) {
if (extractOnly && !skipPreRun) {
return;
}

Expand Down Expand Up @@ -73,7 +75,7 @@
}

if (!schedule) {
await archivist.track({ services, types });
await archivist.track({ services, types, extractOnly, skipSnapshots, skipReadBack });

return;
}
Expand Down
Loading