Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 784
Expand file tree
/
Copy pathtasks.py
More file actions
Latest commit
248 lines (199 loc) · 7.7 KB
/
Copy pathtasks.py
File metadata and controls
248 lines (199 loc) · 7.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
importsys
frompathlibimportPath
importbs4
fromdocutils.coreimportpublish_cmdline
frominvokeimporttask
fromrelluimportReleaseNotesGenerator, Version, initialize_labels
fromrellu.tasksimportclean# noqa
fromrobot.libdocimportlibdoc
assertPath.cwd() ==Path(__file__).parent
VERSION_PATTERN='__version__ = "(.*)"'
REPOSITORY="robotframework/SeleniumLibrary"
VERSION_PATH=Path("src/SeleniumLibrary/__init__.py")
RELEASE_NOTES_PATH=Path("docs/SeleniumLibrary-{version}.rst")
RELEASE_NOTES_TITLE="SeleniumLibrary {version}"
RELEASE_NOTES_INTRO="""
SeleniumLibrary_ is a web testing library for `Robot Framework`_ that utilizes
the Selenium_ tool internally. SeleniumLibrary {version} is a new release with
**UPDATE** enhancements and bug fixes. **ADD more intro stuff...**
**REMOVE this section with final releases or otherwise if release notes contain
all issues.**
All issues targeted for SeleniumLibrary {version.milestone} can be found
from the `issue tracker`_.
**REMOVE ``--pre`` from the next command with final releases.**
If you have pip_ installed, just run
::
pip install --pre --upgrade robotframework-seleniumlibrary
to install the latest available release or use
::
pip install robotframework-seleniumlibrary=={version}
to install exactly this version. Alternatively you can download the source
distribution from PyPI_ and install it manually.
SeleniumLibrary {version} was released on {date}. SeleniumLibrary supports
Python **ADD VERSIONS**, Selenium **ADD VERSIONS** and
Robot Framework **ADD VERSIONS**.
.. _Robot Framework: http://robotframework.org
.. _SeleniumLibrary: https://github.com/robotframework/SeleniumLibrary
.. _Selenium: http://seleniumhq.org
.. _pip: http://pip-installer.org
.. _PyPI: https://pypi.python.org/pypi/robotframework-seleniumlibrary
.. _issue tracker: https://github.com/robotframework/SeleniumLibrary/issues?q=milestone%3A{version.milestone}
"""
@task
defkw_docs(ctx, version=None):
"""Generates the library keyword documentation.
Args:
version: Appends version to the end of the filename.
Used for alpha and beta release.
Documentation is generated by using the Libdoc tool.
"""
ifversion:
out=Path(f"docs/SeleniumLibrary-{version}.html")
else:
out=Path("docs/SeleniumLibrary.html")
libdoc(str(Path("src/SeleniumLibrary")), str(out))
without.open("r") asfile:
data=file.read()
soup=bs4.BeautifulSoup(data, "html.parser")
script_async=soup.new_tag(
"script", src="https://www.googletagmanager.com/gtag/js?id=UA-106835747-4"
)
script_async.attrs["async"] =None
soup.head.append(script_async)
script_data=soup.new_tag("script")
script_data.string="""
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-106835747-4', {
'anonymize_ip': true,
'page_path': location.pathname+location.search+location.hash });
window.onhashchange = function() {
gtag('event', 'HashChange', {
'event_category': 'Subsection',
'event_label': window.location.hash
});
}
"""
soup.head.append(script_data)
without.open("w") asfile:
file.write(str(soup))
@task
defproject_docs(ctx):
"""Generate project documentation.
These docs are visible at http://robotframework.org/SeleniumLibrary/.
"""
args= [
"--stylesheet=style.css,extra.css",
"--link-stylesheet",
"README.rst",
"docs/index.html",
]
publish_cmdline(writer_name="html5", argv=args)
print(Path(args[-1]).absolute()) # noqa: T201
@task
defset_version(ctx, version):
"""Set project version in `src/SeleniumLibrary/__init__.py`` file.
Args:
version: Project version to set or ``dev`` to set development version.
Following PEP-440 compatible version numbers are supported:
- Final version like 3.0 or 3.1.2.
- Alpha, beta or release candidate with ``a``, ``b`` or ``rc`` postfix,
respectively, and an incremented number like 3.0a1 or 3.0.1rc1.
- Development version with ``.dev`` postfix and an incremented number like
3.0.dev1 or 3.1a1.dev2.
When the given version is ``dev``, the existing version number is updated
to the next suitable development version. For example, 3.0 -> 3.0.1.dev1,
3.1.1 -> 3.1.2.dev1, 3.2a1 -> 3.2a2.dev1, 3.2.dev1 -> 3.2.dev2.
"""
version=Version(version, VERSION_PATH, VERSION_PATTERN)
version.write()
print(version) # noqa: T201
@task
defprint_version(ctx):
"""Print the current project version."""
print(Version(path=VERSION_PATH)) # noqa: T201
@task
defrelease_notes(ctx, version=None, username=None, password=None, write=False):
"""Generates release notes based on issues in the issue tracker.
Args:
version: Generate release notes for this version. If not given,
generated them for the current version.
username: GitHub username.
password: GitHub password.
write: When set to True, write release notes to a file overwriting
possible existing file. Otherwise just print them to the
terminal.
Username and password can also be specified using ``GITHUB_USERNAME`` and
``GITHUB_PASSWORD`` environment variable, respectively. If they aren't
specified at all, communication with GitHub is anonymous and typically
pretty slow.
"""
version=Version(version, VERSION_PATH, VERSION_PATTERN)
file=RELEASE_NOTES_PATHifwriteelsesys.stdout
generator=ReleaseNotesGenerator(
REPOSITORY, RELEASE_NOTES_TITLE, RELEASE_NOTES_INTRO
)
generator.generate(version, username, password, file)
@task
definit_labels(ctx, username=None, password=None):
"""Initialize project by setting labels in the issue tracker.
Args:
username: GitHub username.
password: GitHub password.
Username and password can also be specified using ``GITHUB_USERNAME`` and
``GITHUB_PASSWORD`` environment variable, respectively.
Should only be executed once when taking ``rellu`` tooling to use or
when labels it uses have changed.
"""
initialize_labels(REPOSITORY, username, password)
@task
deflint(ctx, fix=False):
"""Run Ruff lint checks.
Args:
fix: Apply safe fixes when True. Defaults to False.
"""
cmd=f"{sys.executable} -m ruff check --config pyproject.toml tasks.py src/ utest/"# atest/"
iffix:
cmd=f"{cmd} --fix"
ctx.run(cmd)
@task
defformatter(ctx, check=False):
"""Run Ruff formatter.
Args:
check: When True, only check formatting and show diff.
When False, apply formatting changes.
"""
cmd=f"{sys.executable} -m ruff format --config pyproject.toml src/ utest/ atest/"
ifcheck:
cmd=f"{cmd} --check --diff"
ctx.run(cmd)
@task
defgen_stub(ctx):
"""Generate stub/.pyi file for SeleniumLibrary/__init__.py.
Stub files improves the IDE integration for Python usage.
"""
ctx.run("python gen_stub.py")
@task
defatest(ctx, suite=None):
"""Runs atest/run.py with headlesschrome.
Args:
suite: Select which suite to run.
Example:
inv utest --suite keywords/test_browsermanagement.py
inv utest --suite keywords/test_selenium_options_parser.py::test_create_chrome_with_options
"""
command=f"{sys.executable} atest/run.py headlesschrome"
ifsuite:
command=f"{command} --suite {suite}"
ctx.run(command)
@task
defutest(ctx, suite=None):
"""Runs utest/run.py
Args:
suite: Select which suite to run.
"""
command=f"{sys.executable} utest/run.py"
ifsuite:
command=f"{command} --suite {suite}"
ctx.run(command)