Joint-Teapot/README.md

164 lines
5.7 KiB
Markdown

# Joint Teapot
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/352635b2c8534b0086b5a153db7c82e9)](https://app.codacy.com/gh/BoYanZh/Joint-Teapot?utm_source=github.com&utm_medium=referral&utm_content=BoYanZh/Joint-Teapot&utm_campaign=Badge_Grade_Settings)
A handy tool for TAs in JI to handle works through [Gitea](https://focs.ji.sjtu.edu.cn/git/), [Canvas](https://umjicanvas.com/), [JOJ](https://joj.sjtu.edu.cn/) and [Mattermost](https://focs.ji.sjtu.edu.cn/mm/). Joint is related to JI and also this tool which join websites together. Teapot means to hold Gitea, inspired by [@nichujie](https://github.com/nichujie).
This tool is still under heavy development. The docs may not be updated on time, and all the features are provided with the probability to change.
## Getting Started
### Setup venv (Optional)
```bash
python3 -m venv env # you only need to do that once
# each time when you need this venv, if on Linux / macOS use
source env/bin/activate
# or this if on Windows
source env/Scripts/activate
```
### Install
```bash
pip3 install -e .
cp .env.example .env && vi .env # configure environment
joint-teapot --help
```
### For developers
```bash
pip3 install -r requirements-dev.txt
pre-commit install
pytest -svv
```
## Commands & Features
### `archive-repos`
archive repos in gitea organization according to regex (dry-run enabled by default)
### `unwatch-all-repos`
unwatch all repos in gitea organization
### `check-issues`
check the existence of issue by title on gitea
### `checkout-releases`
checkout git repo to git tag fetched from gitea by release name, with due date
### `clone-all-repos`
clone all gitea repos to local
### `close-all-issues`
close all issues and pull requests in gitea organization
### `create-group-channels-on-mm`
create Mattermost channels for student groups based on team information on Gitea
**Options**:
- `--prefix TEXT`: Only process repositories starting with this prefix
- `--suffix TEXT`: Add suffix to created channels
- `--invite-teaching-team/--no-invite-teaching-team`: Whether to invite teaching team (default: invite)
Example: `joint-teapot create-group-channels-on-mm --prefix "hteam" --suffix "-gitea"` will Create channels for webhook integration. Members of "hteam*" repo will be added to the corresponding channel. And teaching team (adjust in `.env`) will be invited to the channels.
### `create-personal-channels-on-mm`
create personal Mattermost channels for every student
**Options**:
- `--invite-teaching-team/--no-invite-teaching-team`: Whether to invite teaching team (default: invite)
### `create-comment`
create a comment for an issue on gitea.
### `create-issues`
create issues on gitea. Specify a list of repos (use `--regex` to match against list of patterns), a title, and a body (use `--file` to read from file), in this order.
Examples (run both with `python3 -m joint_teapot create-issues`):
- `pgroup-08 pgroup-17 "Hurry up" "You are running out of time"` will create an issue in these two pgroups.
- `--regex "^pgroup" "Final submission" --file "./issues/final-submission.md"` will create an issue in all pgroups, with body content read from said file.
### `create-personal-repos`
create personal repos on gitea for all canvas students. You may specify an optional suffix.
Example: `python3 -m joint_teapot create-personal-repos --suffix "-p1"` will create repos named `StudentNameStudentID-p1`.
### `create-teams`
create teams on gitea by canvas groups. To integrate with webhooks, it's recommended to set suffix to `-gitea`.
### `create-webhooks-for-mm`
Create a pair of webhooks on gitea and mm for all student groups on gitea, and configure them so that updates on gitea will be pushed to the mm channel. Optionally specify a prefix to ignore all repos whose names do not start with it.
Example: `python3 -m joint_teapot create-webhooks-for-mm p1 -git-suffix` will fetch all repos whose names start with `"p1"` and create two-way webhooks for these repos and channels of the same name but with a "-git" suffix. All repos should already have mm channels following the requirement. If not, use `create-channels-on-mm` to create them.
### `get-no-collaborator-repos`
list all repos with no collaborators
### `get-public-keys`
list all public keys on gitea
### `get-repos-status`
list status of all repos with conditions
### `invite-to-teams`
invite all canvas students to gitea teams by team name
### `prepare-assignment-dir`
prepare assignment dir from extracted canvas "Download Submissions" zip
### `unsubscribe-from-repos`
Unsubscribe from all repos in the organization specified in the config file where the repo name matches a given regex expression.
Example: `python3 -m joint_teapot unsubscribe-from-repos '\d{12}$'` will remove all repos whose names end with a student ID number from your gitea subscription list. Refer to the Python `re` module docs for more info about regex.
### `upload-assignment-grades`
upload assignment grades to canvas from grade file (GRADE.txt by default), read the first line as grade, the rest as comments
### `label-issues`
add a label to specific issues in a repository, create labels if not exist, with dry-run disabled by default. You may adjust the color of the label with `--color "#******"` if the label doesn't exist.
### `delete-labels`
remove a label from specific issues or delete the repository labels, with dry-run disabled by default.
### `close-issues`
close one or more specific issues in a repository, with dry-run disabled by default.
### `update-group-channels-on-mm`
update Mattermost channels for student groups based on team information on Gitea. It will only add missing users, never delete anyone.
### `update-personal-channels-on-mm`
update personal Mattermost channels for every student. It will only add missing users, never delete anyone.
## License
MIT