Skip to content

Commit

Permalink
Validate reporter configuration (OpenTermsArchive#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndpnt authored Oct 18, 2023
2 parents 6512e06 + 04e2a76 commit 10f1e0f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## Unreleased [patch]

_Full changeset and discussions: [#1026](https://github.com/OpenTermsArchive/engine/pull/1026)._

### Added

- Ensure `Reporter` configuration is defined before instantiating it
- Ensure to add links to `versions` and `snapshots` in issues only if repositories are defined in configuration

### Removed

- No longer define default configuration for `Reporter` module

## 0.32.0 - 2023-10-18

Expand All @@ -16,6 +27,8 @@ _Full changeset and discussions: [#1025](https://github.com/OpenTermsArchive/eng
### Changed

- **Breaking:** Revise the formatting of reported issues, with notable adjustments to the title, transitioning from `Fix <service_id> - <terms_type>` to `<service_id> ‧ <terms_type> ‧ not tracked anymore`
- **Breaking:** Rename `tracker` module into `reporter`; update your configuration file by renaming `tracker` into `reporter`
- **Breaking:** Change configuration for `reporter` module; update your `reporter` [configuration accordingly](https://docs.opentermsarchive.org/#configuring)

### Removed

Expand Down
9 changes: 0 additions & 9 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@
"updateTemplateId": 7
}
},
"reporter": {
"githubIssues": {
"repositories": {
"declarations": "OpenTermsArchive/sandbox-declarations",
"versions": "OpenTermsArchive/sandbox-versions",
"snapshots": "OpenTermsArchive/sandbox-snapshots"
}
}
},
"dataset": {
"title": "sandbox",
"versionsRepositoryURL": "https://github.com/OpenTermsArchive/sandbox"
Expand Down
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export default async function track({ services, types, extractOnly, schedule })
}

if (process.env.GITHUB_TOKEN) {
const reporter = new Reporter(config.get('reporter'));

await reporter.initialize();
archivist.attach(reporter);
if (config.has('reporter.githubIssues.repositories.declarations')) {
const reporter = new Reporter(config.get('reporter'));

await reporter.initialize();
archivist.attach(reporter);
} else {
logger.warn('Configuration key "reporter.githubIssues.repositories.declarations" was not found; the Reporter module will be ignored\n');
}
}

if (!schedule) {
Expand Down
4 changes: 2 additions & 2 deletions src/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ If the source documents are accessible in a browser but fetching them always fai
### References
- ${latestDeclarationLink}
- ${latestVersionLink}
- ${latestSnapshotsLink}
${this.repositories.versions ? `- ${latestVersionLink}` : ''}
${this.repositories.snapshots ? `- ${latestSnapshotsLink}` : ''}
`;
/* eslint-enable no-irregular-whitespace */
}
Expand Down

0 comments on commit 10f1e0f

Please sign in to comment.