Skip to content

Commit

Permalink
build: Update to latest profile template
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Oct 23, 2024
1 parent 987f40e commit a1c73ce
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 69 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
env:
PAT: ${{ secrets.PAT }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT || github.token }}
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: pip
cache-dependency-path: '**/requirements*.txt'
- id: changed-files
uses: tj-actions/changed-files@v45
- uses: pre-commit/[email protected]
continue-on-error: true
with:
extra_args: pip-compile --files ${{ steps.changed-files.outputs.all_changed_files }}
- if: ${{ env.PAT }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: '[github-actions] pre-commit autoupdate'
- shell: bash
run: curl -s -S --retry 3 $BASEDIR/tests/install.sh | bash -
- shell: bash
Expand Down
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ci:
autoupdate_schedule: quarterly
skip: [pip-compile]
default_language_version:
python: python3.10
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.18
hooks:
- id: pip-compile
name: pip-compile common-requirements.in
args: [common-requirements.in, -o, common-requirements.txt]
files: ^common-requirements\.(in|txt)$
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
3 changes: 1 addition & 2 deletions common-requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linkify-it-py
myst-parser
ocds-babel
Sphinx
-e git+https://github.com/open-contracting/standard_theme.git@open_contracting#egg=standard_theme
git+https://github.com/open-contracting/standard_theme.git@open_contracting#egg=standard_theme

# Profile
ocdsextensionregistry
Expand All @@ -19,5 +19,4 @@ selenium

# Development
click
pip-tools
sphinx-autobuild
87 changes: 40 additions & 47 deletions common-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile common-requirements.in
#
-e git+https://github.com/open-contracting/standard_theme.git@open_contracting#egg=standard_theme
# via -r common-requirements.in
# This file was autogenerated by uv via the following command:
# uv pip compile common-requirements.in -o common-requirements.txt
alabaster==0.7.12
# via sphinx
anyio==4.4.0
# via
# starlette
# watchfiles
async-generator==1.10
# via
# trio
Expand All @@ -23,11 +21,9 @@ babel==2.9.1
# via
# sphinx
# sphinx-intl
build==0.10.0
# via pip-tools
cattrs==23.1.2
# via requests-cache
certifi==2023.7.22
certifi==2024.7.4
# via
# elastic-transport
# requests
Expand All @@ -38,26 +34,30 @@ click==8.1.3
# via
# -r common-requirements.in
# ocdsindex
# pip-tools
# sphinx-intl
colorama==0.4.4
# uvicorn
colorama==0.4.6
# via sphinx-autobuild
docutils==0.18
# via
# myst-parser
# sphinx
elastic-transport==8.4.0
# via elasticsearch
elasticsearch[requests]==8.6.2
elasticsearch==8.6.2
# via ocdsindex
exceptiongroup==1.0.0
exceptiongroup==1.2.2
# via
# anyio
# cattrs
# pytest
h11==0.13.0
# via wsproto
# via
# uvicorn
# wsproto
idna==3.7
# via
# anyio
# requests
# trio
imagesize==1.4.1
Expand All @@ -74,8 +74,6 @@ jsonref==1.0.0.post1
# via ocdsextensionregistry
linkify-it-py==1.0.1
# via -r common-requirements.in
livereload==2.6.3
# via sphinx-autobuild
lxml==4.9.1
# via ocdsindex
markdown-it-py==2.2.0
Expand All @@ -90,31 +88,24 @@ mdurl==0.1.2
# via markdown-it-py
myst-parser==0.18.1
# via -r common-requirements.in
ocds-babel==0.3.1
ocds-babel==0.3.6
# via -r common-requirements.in
ocdsextensionregistry==0.3.8
ocdsextensionregistry==0.5.0
# via -r common-requirements.in
ocdsindex==0.2.0
# via -r common-requirements.in
outcome==1.1.0
# via trio
packaging==21.3
packaging==24.1
# via
# build
# pytest
# sphinx
pip-tools==7.3.0
# via -r common-requirements.in
platformdirs==3.9.1
# via requests-cache
pluggy==0.13.1
# via pytest
pygments==2.15.1
# via sphinx
pyparsing==2.4.7
# via packaging
pyproject-hooks==1.0.0
# via build
pysocks==1.7.1
# via urllib3
pytest==7.2.0
Expand All @@ -133,12 +124,14 @@ requests-cache==1.1.0
# via ocdsextensionregistry
selenium==4.11.2
# via -r common-requirements.in
setuptools==75.2.0
# via sphinx-intl
six==1.16.0
# via
# livereload
# url-normalize
# via url-normalize
sniffio==1.2.0
# via trio
# via
# anyio
# trio
snowballstemmer==2.1.0
# via sphinx
sortedcontainers==2.4.0
Expand All @@ -149,7 +142,7 @@ sphinx==5.3.0
# myst-parser
# sphinx-autobuild
# sphinx-intl
sphinx-autobuild==2021.3.14
sphinx-autobuild==2024.9.3
# via -r common-requirements.in
sphinx-intl==2.2.0
# via -r common-requirements.in
Expand All @@ -165,14 +158,12 @@ sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.5
# via sphinx
standard-theme @ git+https://github.com/open-contracting/standard_theme.git@07ca0e39979a244656dd6df0658f2ead428184b9#egg=standard_theme
# via -r common-requirements.in
starlette==0.40.0
# via sphinx-autobuild
tomli==2.0.1
# via
# build
# pip-tools
# pyproject-hooks
# pytest
tornado==6.4.1
# via livereload
# via pytest
trio==0.20.0
# via
# selenium
Expand All @@ -181,23 +172,25 @@ trio-websocket==0.9.2
# via selenium
typing-extensions==4.4.0
# via
# anyio
# cattrs
# myst-parser
# uvicorn
uc-micro-py==1.0.1
# via linkify-it-py
url-normalize==1.4.3
# via requests-cache
urllib3[socks]==1.26.18
urllib3==1.26.19
# via
# elastic-transport
# requests
# requests-cache
# selenium
wheel==0.38.4
# via pip-tools
uvicorn==0.30.6
# via sphinx-autobuild
watchfiles==0.24.0
# via sphinx-autobuild
websockets==13.0.1
# via sphinx-autobuild
wsproto==1.1.0
# via trio-websocket

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
2 changes: 1 addition & 1 deletion script/update
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu
main() {
mkdir -p script include tests

for f in Makefile common-requirements.in common-requirements.txt .github/dependabot.yml .github/workflows/lint.yml .github/workflows/shell.yml docs/_static/favicon-16x16.ico include/common.mk include/prologue.mk include/header.html script/diff script/update tests/conftest.py tests/test_common.py; do
for f in .pre-commit-config.yaml .python-version Makefile common-requirements.in common-requirements.txt pyproject.toml .github/dependabot.yml .github/workflows/lint.yml .github/workflows/shell.yml docs/_static/favicon-16x16.ico include/common.mk include/prologue.mk include/header.html script/diff script/update tests/conftest.py tests/test_common.py; do
curl -sS -o $f https://raw.githubusercontent.com/open-contracting/standard_profile_template/latest/$f
done

Expand Down
14 changes: 7 additions & 7 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from selenium.webdriver.chrome.options import Options


@pytest.fixture(scope='module')
@pytest.fixture(scope="module")
def browser(request):
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument("--headless")
options.add_argument("--no-sandbox")

browser = webdriver.Chrome(options=options)
browser.implicitly_wait(3)
Expand All @@ -21,17 +21,17 @@ def browser(request):
browser.quit()


@pytest.fixture(scope='module')
@pytest.fixture(scope="module")
def server(request):
host = 'localhost'
host = "localhost"
port_number = 8331

server = HTTPServer((host, port_number), partial(SimpleHTTPRequestHandler, directory='build'))
server = HTTPServer((host, port_number), partial(SimpleHTTPRequestHandler, directory="build"))

thread = threading.Thread(target=server.serve_forever)
thread.start()

yield f'http://{host}:{port_number}/'
yield f"http://{host}:{port_number}/"

server.shutdown()
thread.join()
24 changes: 12 additions & 12 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@
from tests import languages, test_basic_params, test_search_params


@pytest.mark.parametrize(('lang', 'text'), test_basic_params.items())
@pytest.mark.parametrize(("lang", "text"), test_basic_params.items())
def test_basic(browser, server, lang, text):
browser.get(f'{server}{lang}')
assert text in browser.find_element(By.TAG_NAME, 'body').text
browser.get(f"{server}{lang}")
assert text in browser.find_element(By.TAG_NAME, "body").text


@pytest.mark.parametrize(('lang', 'regex'), test_search_params)
@pytest.mark.parametrize(("lang", "regex"), test_search_params)
def test_search(browser, server, lang, regex):
browser.get(f'{server}{lang}')
search_box = browser.find_element(By.ID, 'rtd-search-form').find_element(By.TAG_NAME, 'input')
search_box.send_keys('tender\n')
browser.get(f"{server}{lang}")
search_box = browser.find_element(By.ID, "rtd-search-form").find_element(By.TAG_NAME, "input")
search_box.send_keys("tender\n")
time.sleep(3)
assert re.search(regex, browser.find_element(By.TAG_NAME, 'body').text)
assert re.search(regex, browser.find_element(By.TAG_NAME, "body").text)


# This seems to be an issue in Selenium and/or ChromeDriver.
@pytest.mark.filterwarnings("ignore:unclosed <socket.socket fd=:ResourceWarning")
def test_language_switcher(browser, server):
if 'localhost' in server:
if "localhost" in server:
pytest.skip()

browser.get(f'{server}en/')
browser.get(f"{server}en/")

for lang, lang_name in languages.items():
select = Select(browser.find_element(By.XPATH, "//select[@name='lang']"))
select.select_by_visible_text(lang_name)
assert browser.current_url == f'{server}{lang}/'
assert test_basic_params[lang] in browser.find_element(By.TAG_NAME, 'body').text
assert browser.current_url == f"{server}{lang}/"
assert test_basic_params[lang] in browser.find_element(By.TAG_NAME, "body").text

0 comments on commit a1c73ce

Please sign in to comment.