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
17 changes: 0 additions & 17 deletions .coveragerc

This file was deleted.

19 changes: 9 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: Python CI

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

With workflow_call from release.yml, the push: trigger makes CI run twice on every merge. Same fix as openedx/forum#293:

.github/workflows/ci.yml:3

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

and point the badge at release.yml:

README.rst:4

.. image:: https://github.com/openedx/cc2olx/actions/workflows/release.yml/badge.svg?branch=master
    :target: https://github.com/openedx/cc2olx/actions/workflows/release.yml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 5bcce58: dropped push: and pointed the badge at release.yml. The live sample-plugin ci.yml also has only pull_request and workflow_call now.


jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
matrix:
os:
Expand All @@ -20,20 +20,19 @@ jobs:
toxenv: [ formatting,quality,django52 ]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: setup python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
- name: Setup uv
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

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

- name: Run Tests
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
run: uv run --locked tox

- name: Run Coverage
if: matrix.toxenv=='django52'
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/pypi-publish.yml

This file was deleted.

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

on:
push:
branches: [master]
# Run manually on an older branch to cut a patch release for that line.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adding it seems fine to me.
But have we decided to add it in the PR's. As per current understanding it's only a timely needed feature.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've kept it. It mirrors the current release.yml on openedx/sample-plugin, which added the workflow_dispatch force input, the "fail a manual run that released nothing" check, and the release/* maintenance branch group together. With all three in place, a manual run can cut a patch release from a release branch, and a manual run that releases nothing fails instead of showing green. Happy to drop all three together if we decide it shouldn't be in these PRs yet.

workflow_dispatch:
inputs:
force:
description: 'Force a version bump (auto = derive from commits)'
type: choice
options: [auto, patch, minor, major]
default: auto

jobs:
# The same aggregate a pull request has to pass, so the release runs exactly
# the checks that were required to merge -- and picks up any package added to
# ci.yml later without needing a change here.
run_ci:
uses: ./.github/workflows/ci.yml

release:
# The package this workflow publishes has to build before we tag
# anything. The GitHub release and the PyPI upload cannot be taken back,
# so a package that only fails to build in its publish job would leave the
# release half-finished.
needs: [run_ci]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false

permissions:
contents: write

steps:
# Note: We checkout the repository at the branch that triggered the workflow.
# Python Semantic Release will automatically convert shallow clones to full clones
# if needed to ensure proper history evaluation. However, we forcefully reset the
# branch to the workflow sha because it is possible that the branch was updated
# while the workflow was running, which prevents accidentally releasing un-evaluated
# changes.
- name: Setup | Checkout Repository on Release Branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.ref_name }}

- name: Setup | Force release branch to be at workflow sha
run: |
git reset --hard ${{ github.sha }}

- name: Action | Semantic Version Release
id: release
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@b700dbeb1f431a0fcc30a79f3f0869407fe07278 # v10.7.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "[email protected]"
changelog: "false"
# Commit, tag, push and build, but don't create the GitHub release.
# We create it ourselves in the next step so that the distributions
# are attached before the release is published. See that step for why.
vcs_release: "false"
force: ${{ inputs.force != 'auto' && inputs.force || '' }}

# python-semantic-release exits successfully without releasing when the
# branch is not in a release group or there is nothing to release. A
# manual run is always meant to release, so fail it rather than show it
# as green.
- name: Check | Fail a manual run that released nothing
if: github.event_name == 'workflow_dispatch' && steps.release.outputs.released != 'true'
run: |
echo "::error::No release was made. Run this on master or release/<name>, with releasable commits."
exit 1

# python-semantic-release also skips the release, and exits successfully,
# when the next version is already tagged on another branch, eg. main's
# next minor taken by a release branch. Fail so the skip doesn't look green.
- name: Check | Fail when the next version is tagged on another branch
if: steps.release.outputs.released != 'true'
env:
TAG: ${{ steps.release.outputs.tag }}
run: |
git fetch --tags --quiet
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null \
&& ! git merge-base --is-ancestor "$TAG" HEAD; then
echo "::error::$TAG is already tagged on another branch, so this release was skipped."
exit 1
fi

# This repo has immutable releases enabled, which freezes a release's
# assets the moment it is published, so assets cannot be attached
# afterwards. Everything we want on the release has to be built by now
# and passed to this one command, which creates the release as a draft,
# uploads the assets, and only then publishes it:
# https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases
- name: Publish | Create GitHub Release with Assets
if: steps.release.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Reuse the release notes python-semantic-release generated for us.
RELEASE_NOTES: ${{ steps.release.outputs.release_notes }}
TAG: ${{ steps.release.outputs.tag }}
run: |
# Output the release notes to a file
printf '%s' "$RELEASE_NOTES" > "$RUNNER_TEMP/release_notes.md"
# Creates the release as a draft, uploads the assets, and then
# publishes it -- all within this one command.
gh release create "$TAG" \
--verify-tag \
--latest=${{ github.ref_name == 'master' }} \
--title "$TAG" \
--notes-file "$RUNNER_TEMP/release_notes.md" \
dist/*

- name: Upload | Distribution Artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: steps.release.outputs.released == 'true'
with:
name: distribution-artifacts
path: dist
if-no-files-found: error

outputs:
released: ${{ steps.release.outputs.released || 'false' }}
version: ${{ steps.release.outputs.version }}

publish_to_pypi:
# 1. Separate out the publish step from the github release step to run each step at
# the least amount of token privilege
# 2. Also, publishing can fail, and its better to have a separate job if you need to retry
# and it won't require reversing the release.
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.released == 'true'

permissions:
contents: read
id-token: write

steps:
- name: Setup | Download Build Artifacts
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
id: artifact-download
with:
name: distribution-artifacts
path: dist

- name: Publish to PyPi
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.. DEPRECATED: This file is no longer updated. Release notes are published on
GitHub Releases: https://github.com/openedx/cc2olx/releases

Change Log
==========

Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM python:3.12-alpine3.20
ARG VERSION=0.0.0
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CC2OLX=$VERSION

WORKDIR /app

Expand Down
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ include LICENSE
include README.rst

recursive-include src/cc2olx/templates *
recursive-include requirements *
recursive-include tests *
prune test_data

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The sdist now picks up every tracked file (uv.lock, .github/, Dockerfile, etc.; 309 KB → 366 KB). Exclude them?

MANIFEST.in:6

Suggested change
prune test_data
prune test_data
prune .github
exclude uv.lock Dockerfile .dockerignore .editorconfig .gitignore codecov.yml

Also, openedx.yaml is legacy, can we delete it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 5bcce58, using your excludes as written. The sdist is back to 310 KB. Compared with master's sdist, the only files that dropped out are setup.py and requirements/, both deleted on purpose. I've left openedx.yaml alone here because it isn't part of the tooling migration, so it fits better in its own PR.

prune .github
exclude uv.lock Dockerfile .dockerignore .editorconfig .gitignore codecov.yml
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

Expand Down
43 changes: 8 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test-all: ## run tests on every Python version with tox
tox

reformat: ## reformats all code files
black --line-length 120 src tests setup.py
black --line-length 120 src tests

fixture_olx: ## creates ready for import course using tests fixture data
tar -czvf olx_fixture.tar.gz tests/fixtures_data/studio_course_xml/*
Expand All @@ -72,43 +72,16 @@ coverage: ## check code coverage quickly with the default Python
coverage html
$(BROWSER) htmlcov/index.html

release: dist ## package and upload a release
twine upload dist/*

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
python -m build
ls -l dist

install: clean ## install the package to the active Python's site-packages
python setup.py install

# Define PIP_COMPILE_OPTS=-v to get more information during make upgrade.
PIP_COMPILE = pip-compile --rebuild --upgrade $(PIP_COMPILE_OPTS)

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 -qr requirements/pip-tools.txt
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/quality.txt requirements/quality.in
$(PIP_COMPILE) -o requirements/ci.txt requirements/ci.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
# Let tox control the Django version for tests
sed '/^[dD]jango==/d' requirements/test.txt > requirements/test.tmp
mv requirements/test.tmp requirements/test.txt
uv pip install .

upgrade: ## update uv.lock with the latest packages satisfying pyproject.toml
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

requirements: ## install development environment requirements
pip install -qr requirements/pip-tools.txt
pip-sync requirements/dev.txt requirements/private.*
uv sync --locked --group dev
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cc2olx
######

.. image:: https://github.com/openedx/cc2olx/workflows/Python%20CI/badge.svg?branch=master
:target: https://github.com/openedx/cc2olx/actions?query=workflow%3A%22Python+CI%22
.. image:: https://github.com/openedx/cc2olx/actions/workflows/release.yml/badge.svg?branch=master
:target: https://github.com/openedx/cc2olx/actions/workflows/release.yml

*cc2olx* is a converter of `Common Cartridge <https://www.imsglobal.org/activity/common-cartridge>`_ `.imscc` files into `.tar.gz` files that can be imported into Studio.

Expand All @@ -28,9 +28,9 @@ Not converted:
Install
-------

Clone repository and install via setup.py::
Clone repository and install it with pip::

python setup.py install
pip install .

Use
---
Expand Down Expand Up @@ -90,7 +90,7 @@ application using Docker you need:

1. Build the image::

docker build -t cc2olx .
docker build --build-arg VERSION=<VERSION> -t cc2olx .

2. Run the conversion command in a container by mounting passed argument path
directories/files and passing the corresponding arguments to the script::
Expand Down Expand Up @@ -125,4 +125,4 @@ Work that needs to be done:
Video Upload Tool
#################

- The *cc2olx* repository also has a video upload tool that can be used to upload videos to directly to edX's video encoding pipeline. See the tool's README :ref:`video_upload_tool`. for a further details.
- The *cc2olx* repository also has a video upload tool that can be used to upload videos to directly to edX's video encoding pipeline. See the `tool's README <https://github.com/openedx/cc2olx/blob/master/src/cc2olx/tools/README.rst>`_ for further details.
Loading
Loading