Skip to content

Commit 5c6f9be

Browse files
authored
Removed discourse-gatekeeper/discourse-ahead-ok (#235)
* feat(ISD-1567): removed obsolete code and corresponding documentation * feat(ISD-1498): removed check in test_check for the removed tag * feat(ISD-1498): updated test parameters to account for removal of discourse ahead tag removal * feat(ISD-1498): removed tagged argument from tests * feat(ISD-1498): ensured all parameters return only 2 values in tuple * feat(ISD-1498): removed ahead tag from constants file, removed mention in integration tests * feat(ISD-1498): removed ahead tag from check.py * feat(ISD-1498): rectified erroneous deletion of expected problem in test check * feat(ISD-1498): adhered to linting requirements by removing unused src.constants imports * feat(ISD-1498): fixed all linting issues and fixed method signatures. * feat(ISD-1498): removed test case 7 from test conflicts * feat(ISD-1498): removed test 7 * feat(ISD-1498): fixed linting issues * feat(ISD-1498): updated change log with new version details * feat(ISD-1498): added src-docs * feat(ISD-1498): fixed comments in run_conflict integration test * feat(ISD-1498): removed assert associated with removed act
1 parent 794d1d4 commit 5c6f9be

10 files changed

+28
-123
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
- Added a formatted representation of the UpdatePageAction dataclass for more
66
human-readable output.
77

8+
## [v0.8.2] - 2024-02-16
9+
10+
### Fixed
11+
12+
- Removed soft-conflict ignore button. `discourse-ahead-ok` tag, which was used
13+
to indicate changes between discourse and git should no longer be used. Has been
14+
removed, with tests updated to reflect this.
15+
816
## [v0.8.1] - 2024-01-18
917

1018
### Fixed

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ that have not been merged into `main` and a PR proposes changes to
210210
`docs/architecture.md` could make changes to the documentation that mean that
211211
the changes to `docs/getting-started.md` are no longer accurate.
212212

213-
If, after checking the community contributions on discourse, you determine that
214-
there are no logical conflicts, the `discourse-gatekeeper/discourse-ahead-ok` tag
215-
can be applied to the latest commit in the PR which will allow the action to
216-
proceed assuming there are no page-by-page conflicts.
217-
218213
## Contents Index
219214

220215
The `docs/index.md` file may contain a `# contents` section which is used to

src-docs/__init__.py.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Upload the documentation to charmhub.
5151

5252
---
5353

54-
<a href="../src/__init__.py#L195"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
54+
<a href="../src/__init__.py#L191"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
5555

5656
## <kbd>function</kbd> `run_migrate`
5757

@@ -76,7 +76,7 @@ Migrate existing docs from charmhub to local repository.
7676

7777
---
7878

79-
<a href="../src/__init__.py#L259"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
79+
<a href="../src/__init__.py#L255"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
8080

8181
## <kbd>function</kbd> `pre_flight_checks`
8282

src-docs/check.py.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Module for running checks.
1111

1212
---
1313

14-
<a href="../src/check.py#L55"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
14+
<a href="../src/check.py#L53"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
1515

1616
## <kbd>function</kbd> `get_path_with_diffs`
1717

@@ -37,15 +37,13 @@ Generate the paths that have either local or server content changes.
3737

3838
---
3939

40-
<a href="../src/check.py#L161"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
40+
<a href="../src/check.py#L159"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
4141

4242
## <kbd>function</kbd> `conflicts`
4343

4444
```python
4545
conflicts(
46-
actions: Iterable[CreateGroupAction | CreatePageAction | CreateExternalRefAction | NoopGroupAction | NoopPageAction | NoopExternalRefAction | UpdateGroupAction | UpdatePageAction | UpdateExternalRefAction | DeleteGroupAction | DeletePageAction | DeleteExternalRefAction],
47-
repository: Client,
48-
user_inputs: UserInputs
46+
actions: Iterable[CreateGroupAction | CreatePageAction | CreateExternalRefAction | NoopGroupAction | NoopPageAction | NoopExternalRefAction | UpdateGroupAction | UpdatePageAction | UpdateExternalRefAction | DeleteGroupAction | DeletePageAction | DeleteExternalRefAction]
4947
) → Iterator[Problem]
5048
```
5149

@@ -60,8 +58,6 @@ The second type of conflict is a logical conflict which arises out of that there
6058
**Args:**
6159

6260
- <b>`actions`</b>: The actions to check.
63-
- <b>`repository`</b>: Client for repository interactions.
64-
- <b>`user_inputs`</b>: Configuration from the user.
6561

6662

6763

@@ -71,7 +67,7 @@ The second type of conflict is a logical conflict which arises out of that there
7167

7268
---
7369

74-
<a href="../src/check.py#L273"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
70+
<a href="../src/check.py#L259"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
7571

7672
## <kbd>function</kbd> `external_refs`
7773

src-docs/constants.py.md

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ The use of this module should be limited to cases where the constant is not bett
1111
---------------
1212
- **DEFAULT_BRANCH**
1313
- **DOCUMENTATION_TAG**
14-
- **DISCOURSE_AHEAD_TAG**
1514
- **DOCUMENTATION_FOLDER_NAME**
1615
- **DOC_FILE_EXTENSION**
1716
- **DOCUMENTATION_INDEX_FILENAME**

src/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ def run_reconcile(clients: Clients, user_inputs: UserInputs) -> ReconcileOutputs
147147
)
148148

149149
actions, check_actions = tee(actions, 2)
150-
problems = tuple(
151-
check.conflicts(
152-
actions=check_actions, repository=clients.repository, user_inputs=user_inputs
153-
)
154-
)
150+
problems = tuple(check.conflicts(actions=check_actions))
155151
if problems:
156152
raise InputError(
157153
"One or more of the required actions could not be executed, see the log for details"

src/check.py

+3-17
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010

1111
import requests
1212

13-
from src import constants, content
13+
from src import content
1414
from src.constants import DOCUMENTATION_TAG
15-
from src.repository import Client
1615
from src.types_ import (
1716
AnyAction,
1817
IndexContentsListItem,
1918
UpdateAction,
2019
UpdateExternalRefAction,
2120
UpdateGroupAction,
2221
UpdatePageAction,
23-
UserInputs,
2422
)
2523

2624

@@ -158,9 +156,7 @@ def _update_action_problem(action: UpdateAction) -> Problem | None:
158156
return problem
159157

160158

161-
def conflicts(
162-
actions: Iterable[AnyAction], repository: Client, user_inputs: UserInputs
163-
) -> Iterator[Problem]:
159+
def conflicts(actions: Iterable[AnyAction]) -> Iterator[Problem]:
164160
"""Check whether actions have any content conflicts.
165161
166162
There are two types of conflicts. The first is where the local content is different to what is
@@ -176,8 +172,6 @@ def conflicts(
176172
177173
Args:
178174
actions: The actions to check.
179-
repository: Client for repository interactions.
180-
user_inputs: Configuration from the user.
181175
182176
Yields:
183177
A problem for each action with a conflict
@@ -196,12 +190,6 @@ def conflicts(
196190
if any_page_conflicts:
197191
return
198192

199-
commit_discourse_ahead_ok_tagged = repository.is_same_commit(
200-
tag=constants.DISCOURSE_AHEAD_TAG, commit=user_inputs.commit_sha
201-
)
202-
if commit_discourse_ahead_ok_tagged:
203-
return
204-
205193
paths_with_diff = get_path_with_diffs(actions_logical_conflicts)
206194
if not paths_with_diff.base_local_diffs or not paths_with_diff.base_server_diffs:
207195
return
@@ -210,9 +198,7 @@ def conflicts(
210198
path=paths_with_diff.base_local_diffs[0],
211199
description=(
212200
"detected unmerged community contributions, these need to be resolved "
213-
"before proceeding. If the differences are not conflicting, please apply the "
214-
f"{constants.DISCOURSE_AHEAD_TAG} tag to commit {user_inputs.commit_sha} to "
215-
"proceed. Paths with potentially unmerged community contributions: "
201+
"before proceeding. Paths with potentially unmerged community contributions: "
216202
f"{set(chain(paths_with_diff.base_local_diffs, paths_with_diff.base_server_diffs))}."
217203
),
218204
)

src/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"""
99
DEFAULT_BRANCH = "main"
1010
DOCUMENTATION_TAG = "discourse-gatekeeper/base-content"
11-
DISCOURSE_AHEAD_TAG = "discourse-gatekeeper/discourse-ahead-ok"
1211

1312
DOCUMENTATION_FOLDER_NAME = "docs"
1413
DOC_FILE_EXTENSION = ".md"

tests/integration/test___init__run_conflict.py

+2-36
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from github.ContentFile import ContentFile
2121

2222
from src import Clients, constants, exceptions, metadata, repository, run_reconcile
23-
from src.constants import DEFAULT_BRANCH, DISCOURSE_AHEAD_TAG, DOCUMENTATION_TAG
23+
from src.constants import DEFAULT_BRANCH, DOCUMENTATION_TAG
2424
from src.discourse import Discourse
2525

2626
from .. import factories
@@ -49,16 +49,13 @@ async def test_run_conflict(
4949
5. docs with an index and documentation and alternate documentation file
5050
6. docs with an index and changed documentation and alternate documentation with server
5151
changes
52-
7. docs with an index and changed documentation and alternate documentation with server
53-
changes with discourse-gatekeeper/discourse-ahead-ok applied
5452
assert: then:
5553
1. the documentation page is created
5654
2. the documentation page is not updated
5755
3. the documentation page is not updated
5856
4. the documentation page is updated
5957
5. the alternate documentation page is created
6058
6. the documentation page is not updated
61-
6. the documentation page is updated
6259
"""
6360
document_name = "name 1"
6461
caplog.set_level(logging.INFO)
@@ -260,7 +257,7 @@ async def test_run_conflict(
260257
# 6. docs with an index and changed documentation and alternate documentation with server
261258
# changes
262259
caplog.clear()
263-
doc_file.write_text(doc_content_6 := f"# {doc_title}\ncontent 6", encoding="utf-8")
260+
doc_file.write_text(f"# {doc_title}\ncontent 6", encoding="utf-8")
264261

265262
repository_client.switch(DEFAULT_BRANCH).update_branch(
266263
"# 6. docs with an index and changed documentation and alternate documentation with "
@@ -300,34 +297,3 @@ async def test_run_conflict(
300297
assert doc_topic == doc_content_5
301298
alt_doc_topic = discourse_api.retrieve_topic(url=alt_doc_url)
302299
assert alt_doc_topic == alt_doc_topic_content_6
303-
304-
# 7. docs with an index and changed documentation and alternate documentation with server
305-
# changes with discourse-gatekeeper/discourse-ahead-ok applied
306-
caplog.clear()
307-
repository_client.tag_commit(DISCOURSE_AHEAD_TAG, repository_client.current_commit)
308-
mock_github_repo.get_contents.side_effect = [mock_alt_content_file, mock_content_file]
309-
310-
reconcile_output = run_reconcile(
311-
clients=Clients(discourse=discourse_api, repository=repository_client),
312-
user_inputs=factories.UserInputsFactory(
313-
dry_run=False, delete_pages=True, commit_sha=repository_client.current_commit
314-
),
315-
)
316-
317-
assert reconcile_output is not None
318-
urls_with_actions = reconcile_output.topics
319-
320-
assert len(urls_with_actions) == 3
321-
(alt_doc_url, _, _) = urls_with_actions.keys()
322-
assert (urls := tuple(urls_with_actions)) == (alt_doc_url, doc_url, index_url)
323-
assert_substrings_in_string(
324-
chain(urls, (doc_table_line_1, alt_doc_table_line_5, "Update", "'success'")),
325-
caplog.text,
326-
)
327-
index_topic = discourse_api.retrieve_topic(url=index_url)
328-
assert doc_table_line_1 in index_topic
329-
assert alt_doc_table_line_5 in index_topic
330-
doc_topic = discourse_api.retrieve_topic(url=doc_url)
331-
assert doc_topic == doc_content_6
332-
alt_doc_topic = discourse_api.retrieve_topic(url=alt_doc_url)
333-
assert alt_doc_topic == alt_doc_topic_content_6

0 commit comments

Comments
 (0)