Skip to content

Commit f384b97

Browse files
authored
Feature/74 activate the projects title filter (#78)
* New logic for writing the configuration without specifying query-labes and project-title-filter.
1 parent 8b8da09 commit f384b97

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ See the default action step definition:
5151
```yaml
5252
- name: Generate Living Documentation
5353
id: generate_living_doc
54-
uses: AbsaOSS/living-doc-generator@v0.3.0
54+
uses: AbsaOSS/living-doc-generator@v0.4.0
5555
env:
5656
GITHUB-TOKEN: ${{ secrets.REPOSITORIES_ACCESS_TOKEN }}
5757
with:
@@ -70,7 +70,7 @@ See the full example of action step definition (in example are used non-default
7070
```yaml
7171
- name: Generate Living Documentation
7272
id: generate_living_doc
73-
uses: AbsaOSS/living-doc-generator@v0.3.0
73+
uses: AbsaOSS/living-doc-generator@v0.4.0
7474
env:
7575
GITHUB-TOKEN: ${{ secrets.REPOSITORIES_ACCESS_TOKEN }}
7676
with:
@@ -89,14 +89,12 @@ See the full example of action step definition (in example are used non-default
8989
{
9090
"organization-name": "health-analytics",
9191
"repository-name": "patient-data-analysis",
92-
"query-labels": ["functionality"],
9392
"projects-title-filter": ["Health Data Analysis Project"]
9493
},
9594
{
9695
"organization-name": "open-source-initiative",
9796
"repository-name": "community-driven-project",
98-
"query-labels": ["improvement"],
99-
"projects-title-filter": ["Community Outreach Initiatives", "CDD Project"]
97+
"query-labels": ["improvement"]
10098
}
10199
]
102100
liv-doc-project-state-mining: true # project state mining feature de/activation

living_documentation_regime/README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ See the default minimal Living Documentation regime action step definition:
3838
```yaml
3939
- name: Generate Living Documentation
4040
id: generate_living_doc
41-
uses: AbsaOSS/living-doc-generator@v0.3.0
41+
uses: AbsaOSS/living-doc-generator@v0.4.0
4242
env:
4343
GITHUB-TOKEN: ${{ secrets.REPOSITORIES_ACCESS_TOKEN }}
4444
with:
@@ -47,15 +47,7 @@ See the default minimal Living Documentation regime action step definition:
4747
[
4848
{
4949
"organization-name": "fin-services",
50-
"repository-name": "investment-app",
51-
"query-labels": ["feature", "enhancement"],
52-
"projects-title-filter": []
53-
},
54-
{
55-
"organization-name": "health-analytics",
56-
"repository-name": "patient-data-analysis",
57-
"query-labels": ["functionality"],
58-
"projects-title-filter": ["Health Data Analysis Project"]
50+
"repository-name": "investment-app"
5951
}
6052
]
6153
```
@@ -65,7 +57,7 @@ See the full example of Living Documentation regime step definition (in example
6557
```yaml
6658
- name: Generate Living Documentation
6759
id: generate_living_doc
68-
uses: AbsaOSS/living-doc-generator@v0.3.0
60+
uses: AbsaOSS/living-doc-generator@v0.4.0
6961
env:
7062
GITHUB-TOKEN: ${{ secrets.REPOSITORIES_ACCESS_TOKEN }}
7163
with:
@@ -100,7 +92,7 @@ Configure the Living Documentation regime by customizing the following parameter
10092
### Regime Inputs
10193
- **liv-doc-repositories** (optional, `default: '[]'`)
10294
- **Description**: A JSON string defining the repositories to be included in the documentation generation.
103-
- **Usage**: List each repository with its organization name, repository name, query labels and attached projects you want to filter if any. Only projects with these titles will be considered. For no filtering projects, leave the list empty.
95+
- **Usage**: Provide a list of repositories including the organization name, repository name, query labels, and any attached projects you wish to filter. The query-labels and projects-title-filter parameters are optional. Only issues with the specified labels and projects will be fetched. To fetch all issues (all labels), either omit these parameters or leave the lists empty.
10496
- **Example**:
10597
```yaml
10698
with:
@@ -109,13 +101,11 @@ Configure the Living Documentation regime by customizing the following parameter
109101
{
110102
"organization-name": "fin-services",
111103
"repository-name": "investment-app",
112-
"query-labels": ["feature", "enhancement"],
113-
"projects-title-filter": []
104+
"query-labels": ["feature", "enhancement"]
114105
},
115106
{
116107
"organization-name": "open-source-initiative",
117108
"repository-name": "community-driven-project",
118-
"query-labels": ["improvement"],
119109
"projects-title-filter": ["Community Outreach Initiatives", "CDD Project"]
120110
}
121111
]

living_documentation_regime/model/config_repository.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def load_from_json(self, repository_json: dict) -> bool:
6666
try:
6767
self.__organization_name = repository_json["organization-name"]
6868
self.__repository_name = repository_json["repository-name"]
69-
self.__query_labels = repository_json["query-labels"]
70-
self.__projects_title_filter = repository_json["projects-title-filter"]
69+
self.__query_labels = repository_json.get("query-labels", [])
70+
self.__projects_title_filter = repository_json.get("projects-title-filter", [])
7171
return True
7272
except KeyError as e:
7373
logger.error("The key is not found in the repository JSON input: %s.", e, exc_info=True)

tests/living_documentation_regime/model/test_config_repository.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
def test_load_from_json_with_valid_input_loads_correctly():
21+
# Arrange
2122
config_repository = ConfigRepository()
2223
organization_name = "organizationABC"
2324
repository_name = "repositoryABC"
@@ -32,35 +33,64 @@ def test_load_from_json_with_valid_input_loads_correctly():
3233
"other-field": other_value,
3334
}
3435

36+
# Act
3537
actual = config_repository.load_from_json(repository_json)
3638

39+
# Assert
3740
assert actual
3841
assert organization_name == config_repository.organization_name
3942
assert repository_name == config_repository.repository_name
4043
assert query_labels == config_repository.query_labels
4144
assert projects_title_filter == config_repository.projects_title_filter
4245

4346

47+
def test_load_from_json_with_valid_input_check_default_values():
48+
# Arrange
49+
config_repository = ConfigRepository()
50+
organization_name = "organizationABC"
51+
repository_name = "repositoryABC"
52+
repository_json = {
53+
"organization-name": organization_name,
54+
"repository-name": repository_name
55+
}
56+
57+
# Act
58+
actual = config_repository.load_from_json(repository_json)
59+
60+
# Assert
61+
assert actual
62+
assert organization_name == config_repository.organization_name
63+
assert repository_name == config_repository.repository_name
64+
assert [] == config_repository.query_labels
65+
assert [] == config_repository.projects_title_filter
66+
67+
4468
def test_load_from_json_with_missing_key_logs_error(mocker):
69+
# Arrange
4570
config_repository = ConfigRepository()
46-
mock_log_error = mocker.patch("living_documentation_regime.model.config_repository.logger.error")
4771
repository_json = {"non-existent-key": "value"}
72+
mock_log_error = mocker.patch("living_documentation_regime.model.config_repository.logger.error")
4873

74+
# Act
4975
actual = config_repository.load_from_json(repository_json)
5076

77+
# Assert
5178
assert actual is False
5279
mock_log_error.assert_called_once_with(
5380
"The key is not found in the repository JSON input: %s.", mocker.ANY, exc_info=True
5481
)
5582

5683

5784
def test_load_from_json_with_wrong_structure_input_logs_error(mocker):
85+
# Arrange
5886
config_repository = ConfigRepository()
59-
mock_log_error = mocker.patch("living_documentation_regime.model.config_repository.logger.error")
6087
repository_json = "not a dictionary"
88+
mock_log_error = mocker.patch("living_documentation_regime.model.config_repository.logger.error")
6189

90+
# Act
6291
actual = config_repository.load_from_json(repository_json)
6392

93+
# Assert
6494
assert actual is False
6595
mock_log_error.assert_called_once_with(
6696
"The repository JSON input does not have a dictionary structure: %s.", mocker.ANY, exc_info=True

0 commit comments

Comments
 (0)