Skip to content

Commit a2795d1

Browse files
authored
Merge pull request #1 from aaltat/ci_and_build
ci: Initial CI setup
2 parents 5524ff5 + b64a611 commit a2795d1

File tree

6 files changed

+299
-0
lines changed

6 files changed

+299
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/on-push.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
schedule:
7+
- cron: '15 10 * * *'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.8, 3.12.2]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python ${{ matrix.python-version }} with Robot Framework ${{ matrix.rf-version }}
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
pip install uv
24+
uv pip install -r requirements-dev.txt --python ${{ matrix.python-version }} --system
25+
uv pip install robotframework-seleniumlibrary --python ${{ matrix.python-version }} --system
26+
- name: Lint files
27+
run: |
28+
inv lint
29+
- name: Run unit tests
30+
run: inv utest
31+
- name: Run acceptance tests
32+
run: |
33+
inv atest
34+
- uses: actions/upload-artifact@v4
35+
if: ${{ always() }}
36+
with:
37+
name: Test_results_${{ matrix.python-version }}
38+
path: atest/output

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: SemanticRelease
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
concurrency: release
12+
permissions:
13+
id-token: write
14+
contents: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- name: Set up Python 3.12 with Robot Framework 7
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: 3.12
24+
- name: Install dependencies
25+
run: |
26+
pip install uv
27+
uv pip install -r requirements-dev.txt --python 3.23 --system
28+
uv pip install robotframework-seleniumlibrary --python 3.23 --system
29+
- name: Lint files
30+
run: inv lint
31+
- name: Run unit tests
32+
run: |
33+
inv utest
34+
- name: Run acceptance tests
35+
run: |
36+
inv atest
37+
- name: Python Semantic Release
38+
id: release
39+
uses: python-semantic-release/[email protected]
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Build package
43+
run: python -m build
44+
if: steps.release.outputs.released == 'true'
45+
- name: Publish package to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
if: steps.release.outputs.released == 'true'
48+
- name: Publish package to GitHub Release
49+
uses: python-semantic-release/upload-to-gh-release@main
50+
if: steps.release.outputs.released == 'true'
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
tag: ${{ steps.release.outputs.tag }}

pyproject.toml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "robotframework-seleniumlibrary-translation-fi"
7+
version = "0.0.1"
8+
authors = [
9+
{ name="Tatu Aalto", email="[email protected]" },
10+
]
11+
license = {file = "LICENSE"}
12+
description = "Robot Framework SeleniumLibrary translation to Finnish languege"
13+
readme = "README.md"
14+
requires-python = ">=3.8"
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Framework :: Robot Framework :: Library",
18+
"Topic :: Software Development :: Testing :: Acceptance",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.8",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"License :: OSI Approved :: Apache Software License",
26+
"Operating System :: OS Independent",
27+
]
28+
keywords = ["Robot Framework", "SeleniumLibrary"]
29+
30+
dependencies = ["robotframework-seleniumlibrary >= 6.4.0"]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/MarketSquare/robotframework-seleniumlibrary-translation-fi"
34+
Issues = "https://github.com/MarketSquare/robotframework-seleniumlibrary-translation-fi/issues"
35+
Changelog = "https://github.com/MarketSquare/robotframework-seleniumlibrary-translation-fi/blob/main/CHANGELOG.md"
36+
37+
[tool.setuptools]
38+
packages = ["robotframework_seleniumlibrary_translation_fi"]
39+
40+
[tool.setuptools.package-data]
41+
robotframework_seleniumlibrary_translation_fi = ["*.json"]
42+
43+
[tool.semantic_release]
44+
version_toml = [
45+
"pyproject.toml:project.version",
46+
]
47+
version_variables = [
48+
"robotframework_seleniumlibrary_translation_fi/__init__.py:__version__",
49+
]
50+
51+
[tool.black]
52+
target-version = ['py38']
53+
exclude = '''
54+
/(
55+
\.eggs
56+
| \.git
57+
| \.mypy_cache
58+
| \.venv
59+
| _build
60+
| buck-out
61+
| build
62+
| dist
63+
| generated
64+
| wrapper
65+
| browser\.pyi
66+
)/
67+
'''
68+
69+
[tool.ruff]
70+
lint.unfixable = []
71+
exclude = [
72+
"__pycache__",
73+
]
74+
target-version = "py38"
75+
lint.select = [
76+
"E",
77+
"F",
78+
"W",
79+
"C90",
80+
"I",
81+
"N",
82+
"B",
83+
"PYI",
84+
"PL",
85+
"PTH",
86+
"UP",
87+
"A",
88+
"C4",
89+
"DTZ",
90+
"ISC",
91+
"ICN",
92+
"INP",
93+
"PIE",
94+
"T20",
95+
"PYI",
96+
"PT",
97+
"RSE",
98+
"RET",
99+
"SIM",
100+
"RUF"
101+
]
102+
103+
[tool.ruff.lint.per-file-ignores]
104+
"tasks.py" = ["T201"]
105+
"utest/*" = ["INP001"]
106+
"atest/*" = ["INP001"]
107+
108+
[tool.pytest.ini_options]
109+
testpaths = ["utest"]
110+
log_format = "%(asctime)s %(levelname)s %(message)s"
111+
log_date_format = "%Y-%m-%d %H:%M:%S"
112+
113+
[tool.robotidy]
114+
lineseparator = "unix"
115+
configure = [
116+
"NormalizeAssignments:equal_sign_type=space_and_equal_sign",
117+
"NormalizeAssignments:equal_sign_type_variables=space_and_equal_sign",
118+
"NormalizeNewLines:section_lines=1",
119+
"RenameTestCases:enabled=True:capitalize_each_word=True",
120+
"RenameKeywords:enabled=True",
121+
]
122+
123+
[tool.mypy]
124+
exclude = [
125+
"utest/*",
126+
]

requirements-dev.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
black >= 24.1.1
2+
ruff >= 0.2.1
3+
invoke >= 2.2.0
4+
pytest >= 7.4.2
5+
approvaltests == 12.0.0
6+
robotframework-tidy >= 4.9.0
7+
python-semantic-release >= 9.3.1
8+
setuptools >= 61.0
9+
build >= 1.2.1
10+
mypy >= 1.9.0

tasks.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import os
2+
import shutil
3+
from pathlib import Path
4+
5+
from invoke import task
6+
7+
ROOT_FOLDER = Path(__file__).parent.absolute()
8+
ATEST_OUTPUT = ROOT_FOLDER / "atest" / "output"
9+
DIST_DIR = ROOT_FOLDER / "dist"
10+
RUFF_CACHE = ROOT_FOLDER / ".ruff_cache"
11+
PYTEST_CACHE = ROOT_FOLDER / ".pytest_cache"
12+
MYPY_CACHE = ROOT_FOLDER / ".mypy_cache"
13+
BUILD_DIR = ROOT_FOLDER / "build"
14+
15+
16+
@task
17+
def lint(ctx, fix=False):
18+
in_ci = os.getenv("GITHUB_WORKFLOW")
19+
print("Run mypy:")
20+
ctx.run("mypy --exclude .venv .")
21+
print("Run black:")
22+
black_cmd = ["black", "."]
23+
if in_ci:
24+
black_cmd.insert(1, "--check")
25+
ctx.run(" ".join(black_cmd))
26+
print("Run ruff:")
27+
ruff_cmd = "ruff check "
28+
if fix:
29+
ruff_cmd = f"{ruff_cmd} --fix"
30+
ctx.run(ruff_cmd)
31+
print(f"Lint Robot files {'in ci' if in_ci else ''}")
32+
cmd = ["robotidy", "atest"]
33+
if in_ci:
34+
cmd.insert(1, "--check")
35+
cmd.insert(1, "--diff")
36+
ctx.run(" ".join(cmd))
37+
38+
39+
@task
40+
def utest(ctx):
41+
ctx.run("python -m pytest .")
42+
43+
44+
@task
45+
def atest(ctx):
46+
ctx.run("python -m robot -L debug --outputdir atest/output atest")
47+
48+
49+
@task
50+
def clean(ctx):
51+
for target in [
52+
DIST_DIR,
53+
ATEST_OUTPUT,
54+
RUFF_CACHE,
55+
PYTEST_CACHE,
56+
MYPY_CACHE,
57+
BUILD_DIR,
58+
]:
59+
print(target)
60+
if target.exists():
61+
shutil.rmtree(target)

0 commit comments

Comments
 (0)