Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
name: Python CI

on:
push:
branches:
- master
pull_request:
branches:
- '**'
workflow_call:

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
name: quality
runs-on: ubuntu-latest
strategy:
matrix:
os:
- ubuntu-latest
python-version: ['3.12']
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: setup python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
architecture: x64
enable-cache: true
python-version: "${{ matrix.python-version }}"

- name: Install dependencies
run: pip install -r requirements/ci.txt
- name: Install quality dependencies
run: uv sync --group quality

- name: Run Tests
run: pycodestyle . --max-line-length=419 # TODO 419 --> 120
- name: Run quality checks
run: uv run pycodestyle . --max-line-length=419 --exclude=.venv
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Semantic Release

on:
push:
branches:
- master

jobs:
run_tests:
uses: ./.github/workflows/ci.yml
secrets: inherit
permissions:
contents: read

release:
needs: run_tests
if: github.ref_name == 'master'
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-release
cancel-in-progress: false

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.ref_name }}

- name: Reset to triggered commit
run: git reset --hard ${{ github.sha }}

- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@350c48fcb3ffcdfd2e0a235206bc2ecea6b69df0 # v10.5.3
with:
git_committer_name: "github-actions[bot]"
git_committer_email: "github-actions[bot]@users.noreply.github.com"
changelog: "false"

- name: Upload dist artifacts
if: steps.release.outputs.released == 'true'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

outputs:
released: ${{ steps.release.outputs.released }}
version: ${{ steps.release.outputs.version }}

publish_to_pypi:
needs: release
if: needs.release.outputs.released == 'true'
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- name: Download dist artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
21 changes: 4 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
WORKING_DIR := recommender
WORKING_DIR := src/recommender
JS_TARGET := $(WORKING_DIR)/public/js/translations

COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt
.PHONY: $(COMMON_CONSTRAINTS_TXT)
$(COMMON_CONSTRAINTS_TXT):
wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)"

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -r requirements/pip.txt
pip install -q -r requirements/pip_tools.txt
pip-compile --upgrade --allow-unsafe --rebuild -o requirements/pip.txt requirements/pip.in
pip-compile --upgrade -o requirements/pip_tools.txt requirements/pip_tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip_tools.txt
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/test.txt requirements/test.in
pip-compile --upgrade -o requirements/ci.txt requirements/ci.in
upgrade: ## update uv.lock with the latest packages
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

extract_translations: ## extract strings to be translated, outputting .po files
cd $(WORKING_DIR) && i18n_tool extract --no-segment --merge-po-files
Expand Down
97 changes: 97 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[build-system]
requires = ["setuptools>=64", "setuptools-scm>=8.0"]
build-backend = "setuptools.build_meta"

[project]
name = "recommender-xblock"
dynamic = ["version"]
description = "recommender XBlock"
readme = "README.rst"
license = "AGPL-3.0"
license-files = ["LICENSE"]
authors = [
{name = "edX", email = "oscm@edx.org"},
]
requires-python = ">=3.12"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.2",
]
dependencies = [
"bleach",
"edx-i18n-tools",
"fs",
"simplejson",
"web-fragments",
"webob",
]

[project.urls]
Homepage = "https://github.com/openedx/RecommenderXBlock"

[project.entry-points."xblock.v1"]
recommender = "recommender.recommender:RecommenderXBlock"

[tool.setuptools_scm]
version_scheme = "only-version"
local_scheme = "no-local-version"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
recommender = [
"static/**/*",
"templates/**/*",
"conf/locale/**",
"public/**/*",
]

[tool.setuptools.exclude-package-data]
"*" = ["tests*", "*.tests*", "spec*", "*.spec*"]

[tool.coverage.run]
branch = true
source = ["recommender"]
omit = [
"*/tests/*",
"*/migrations/*",
"*/__pycache__/*",
"*/settings.py",
]

[tool.coverage.report]
show_missing = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

[tool.coverage.html]
directory = "htmlcov"

[dependency-groups]
quality = [
"pycodestyle",
]

[tool.edx_lint]
uv_constraints = []

[tool.semantic_release]
build_command = "python -m pip install --upgrade build && SETUPTOOLS_SCM_PRETEND_VERSION=$NEW_VERSION python -m build"
allow_zero_version = true
major_on_zero = false

[tool.uv]
package = true
10 changes: 0 additions & 10 deletions requirements/base.in

This file was deleted.

47 changes: 0 additions & 47 deletions requirements/base.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements/ci.in

This file was deleted.

Loading