Skip to content
Merged
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
29 changes: 17 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Python CI

on:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI should also run on merges to master to make sure we did have a bad merge.

workflow_call:
push:
branches:
- master
Expand All @@ -10,24 +11,28 @@ on:

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

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.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.

74 changes: 74 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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:
- 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:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "github-actions@github.com"
changelog: "false"
vcs_release: "false"
- name: Create GitHub Release with Assets
if: steps.release.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ steps.release.outputs.release_notes }}
TAG: ${{ steps.release.outputs.tag }}
run: |
printf '%s' "$RELEASE_NOTES" > "$RUNNER_TEMP/release_notes.md"
gh release create "$TAG" \
--verify-tag \
--title "$TAG" \
--notes-file "$RUNNER_TEMP/release_notes.md" \
dist/*
- 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 }}
release_notes: ${{ steps.release.outputs.release_notes }}

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
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
include crowdsourcehinter_correct.png crowdsourcehinter_hint.png crowdsourcehinter_setup.png
include requirements/constraints.txt

prune .github
prune htmlcov
exclude .coverage coverage.xml
37 changes: 9 additions & 28 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,17 @@ 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://github.com/ghraw/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
uv sync --group dev

quality: quality-python ## Run linters
quality: ## run linting checks
uv run --group quality flake8 src/crowdsourcehinter/

test-python: clean ## run tests and generate coverage report
-pytest
uv run --group test python -Wd -m pytest; code=$$?; [ $$code -eq 5 ] && exit 0 || exit $$code

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

This file was deleted.

104 changes: 104 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[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.package-data]
"crowdsourcehinter" = [
"static/**",
"public/**",
]

[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
default-groups = []
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.edx_lint]
uv_constraints = []

[tool.coverage.run]
branch = true
source_pkgs = ["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"
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.

Loading