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
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: Python CI

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

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
name: ${{ matrix.toxenv }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- 3.12
- "3.12"
toxenv:
- quality

steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
- name: Setup uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
python-version: "${{ matrix.python-version }}"

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

- name: Run Tests
run: make quality
- name: Run tox
run: uv run tox -e ${{ matrix.toxenv }}
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

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

on:
push:
branches: [master]

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

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:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- 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"
git_committer_email: "github-actions@github.com"
changelog: "false"
- name: Upload dist
if: steps.release.outputs.released == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
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:
- uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
39 changes: 9 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean upgrade test quality quality-python test-python
.PHONY: clean upgrade requirements quality test help
# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
help: ## display this help message
@echo "Please use \`make <target>\` where <target> is one of"
Expand All @@ -11,36 +11,15 @@ clean: ## delete generated byte code and coverage reports
rm -rf assets
rm -rf pii_report

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/ci.txt requirements/ci.in
pip-compile --upgrade -o requirements/test.txt requirements/test.in
upgrade: ## update uv.lock and regenerate uv constraints
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

requirements: ## install development environment requirements
pip install -r requirements/pip.txt
pip install -q -r requirements/pip_tools.txt
pip install -qr requirements/base.txt --exists-action w
pip-sync requirements/base.txt requirements/constraints.txt requirements/test.txt requirements/ci.txt

quality-python: ## Run python linters
flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

quality: quality-python ## Run linters
uv sync --group dev

test-python: clean ## run tests and generate coverage report
-pytest
quality: ## run linting checks
tox -e quality

test: test-python ## run tests
test: ## run tests
tox -e test
3 changes: 0 additions & 3 deletions crowdsourcehinter/__init__.py

This file was deleted.

96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["setuptools", "setuptools-scm>8.1"]
build-backend = "setuptools.build_meta"

[project]
name = "crowdsourcehinter-xblock"
dynamic = ["version"]
description = "crowdsourcehinter XBlock"
readme = "README.md"
license = "AGPL-3.0"
license-files = ["LICENSE"]
requires-python = ">=3.12"
dependencies = [
"six>=1.16.0",
"xblock>=6.2.0",
]
keywords = ["crowdsourcehinter", "xblock"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
]

[project.entry-points."xblock.v1"]
crowdsourcehinter = "crowdsourcehinter:CrowdsourceHinter"

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

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

[tool.setuptools.packages.find]
where = ["src"]
include = ["crowdsourcehinter*"]

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

[dependency-groups]
# Base test packages, no Django version pinned
test-base = ["pytest-cov"]
# Default test group: current supported Django version
test = [{include-group = "test-base"}, "Django>=5.2,<6.0"]
# Legacy Django 4.2 support
django42 = [{include-group = "test-base"}, "Django>=4.2,<5.0"]
quality = [{include-group = "test"}, "flake8"]
ci = ["tox", "tox-uv>=1"]
dev = [{include-group = "quality"}, {include-group = "ci"}]

[tool.uv]
package = true
conflicts = [
[
{group = "test"},
{group = "django42"},
],
]

# DO NOT EDIT constraint-dependencies DIRECTLY.
# This list is managed by `edx_lint write_uv_constraints`
# and will be overwritten the next time `make upgrade` is run.
# - GLOBAL constraints: edit edx_lint/files/common_constraints.txt
# - REPO-SPECIFIC constraints: edit [tool.edx_lint].uv_constraints in this file
constraint-dependencies = [
"Django<6.0",
"elasticsearch<7.14.0",
]
[tool.coverage.run]
branch = true
source = ["crowdsourcehinter"]
omit = ["*/tests/*", "*/migrations/*", "*/__pycache__/*"]

[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"

[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
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
addopts = --cov . --cov-report term-missing --cov-report xml
addopts = --cov=crowdsourcehinter --cov-report term-missing --cov-report xml
5 changes: 0 additions & 5 deletions requirements/base.in

This file was deleted.

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

This file was deleted.

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

This file was deleted.

14 changes: 0 additions & 14 deletions requirements/ci.txt

This file was deleted.

20 changes: 0 additions & 20 deletions requirements/common_constraints.txt

This file was deleted.

Loading