Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JJMC89 committed Oct 13, 2024
0 parents commit 98b96a8
Show file tree
Hide file tree
Showing 34 changed files with 524 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
groups:
dependencies:
patterns:
- "*"
labels:
- "ci"
schedule:
interval: "monthly"
23 changes: 23 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Update
on:
workflow_dispatch:
jobs:
update:
name: Update
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: update submodules
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git submodule sync --recursive
git submodule update --init --no-single-branch --remote --recursive
git commit -am "update submodules" || echo no updates
git push
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[submodule "bsiconsbot"]
path = bsiconsbot
url = https://github.com/jjmc89-bot/bsiconsbot
branch = main
[submodule "jjmc89-bot-scripts"]
path = jjmc89-bot-scripts
url = https://github.com/jjmc89-bot/jjmc89-bot-scripts
branch = main
[submodule "pywikibot"]
path = pywikibot
url = https://gerrit.wikimedia.org/r/pywikibot/core
branch = stable
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-vcs-permalinks
- id: check-yaml
- id: destroyed-symlinks
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: script-must-not-have-extension
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
- id: beautysh
additional_dependencies:
- setuptools # depends on pkg_resources
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
1 change: 1 addition & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
disable=SC1091
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-2022 JJMC89

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/jjmc89-bot/jjmc89-bot-toolforge/main.svg)](https://results.pre-commit.ci/latest/github/jjmc89-bot/jjmc89-bot-toolforge/main)

[JJMC89 bot](https://meta.wikimedia.org/wiki/User:JJMC89_bot), [JJMC89 bot II](https://meta.wikimedia.org/wiki/User:JJMC89_bot_II), [JJMC89 bot III](https://meta.wikimedia.org/wiki/User:JJMC89_bot_III), and [Magic links bot](https://meta.wikimedia.org/wiki/User:Magic_links_bot) run on [Wikimedia](https://www.wikimedia.org/) projects and are hosted on [Wikimedia Toolforge](https://toolforge.org/).

Toolforge setup and job management

## Clone and setup virtual environments
```shell
rm -fdr $HOME/repos && git clone --depth 1 --single-branch --recurse-submodules --shallow-submodules https://github.com/jjmc89-bot/jjmc89-bot-toolforge $HOME/repos && toolforge-jobs run setup-venvs --command $HOME/repos/bin/setup-venvs --image python3.11 --wait
```

## Load jobs
```shell
toolforge-jobs load $HOME/repos/cronjobs.yaml
```
24 changes: 24 additions & 0 deletions bin/setup-venvs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# shellcheck disable=SC1090
set -euo pipefail

VENVPYZ=$HOME/virtualenv.pyz

mkdir -p "$HOME/repos/.venvs"

curl --silent --location --output "$VENVPYZ" https://bootstrap.pypa.io/virtualenv/3.11/virtualenv.pyz

function setup-venv {
echo "Setting up $1"
rm -fdr "$HOME/repos/.venvs/$1"
python3 "$VENVPYZ" "$HOME/repos/.venvs/$1"
. "$HOME/repos/.venvs/$1/bin/activate"
python3 -m pip install -U pip setuptools wheel
# shellcheck disable=SC2086
python3 -m pip install $2
deactivate
}

setup-venv jjmc89-bot-scripts "-U -r $HOME/repos/jjmc89-bot-scripts/requirements.txt"
setup-venv bsiconsbot "-e $HOME/repos/bsiconsbot"
setup-venv pwb "-e $HOME/repos/pywikibot[mwoauth,mysql]"
1 change: 1 addition & 0 deletions bsiconsbot
Submodule bsiconsbot added at 644b0d
101 changes: 101 additions & 0 deletions cronjobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
- &defaults
name: dummy-defaults-job
command: echo this is a dummy job to set defaults
emails: onfailure
image: python3.11
no-filelog: true
retry: 5
- name: admin-activity-early
command: $HOME/repos/jobs/admin-activity
schedule: '7 0 1-28 * *'
<<: *defaults
- name: admin-activity-late
command: $HOME/repos/jobs/admin-activity
schedule: '53 23 28-31 * *'
retry: 1
<<: *defaults
- name: bsicons-replacer
command: $HOME/repos/jobs/bsicons-replacer
mem: 1Gi
schedule: '7 7 * * *'
<<: *defaults
- name: bsicons-reporter
command: $HOME/repos/jobs/bsicons-reporter
schedule: '12 12 * * *'
<<: *defaults
- name: cat-dbl-redir-fixer
command: $HOME/repos/jobs/cat-dbl-redir-fixer
schedule: '6 6 * * *'
<<: *defaults
- name: cfdw
command: $HOME/repos/jobs/cfdw
schedule: '17,47 * * * *'
<<: *defaults
- name: cfdwl
command: $HOME/repos/jobs/cfdwl
schedule: '37 */3 * * *'
<<: *defaults
- name: commons-potd-importer
command: $HOME/repos/jobs/commons-potd-importer
schedule: '7 0 * * *'
<<: *defaults
- name: dfy-daily
command: $HOME/repos/jobs/dfy-daily
schedule: '17 1 * * *'
<<: *defaults
- name: dfy-monthly
command: $HOME/repos/jobs/dfy-monthly
schedule: '37 1 1 * *'
<<: *defaults
- name: dfy-tagger
command: $HOME/repos/jobs/dfy-tagger
schedule: '*/5 * * * *'
<<: *defaults
- name: dfy-untagger
command: $HOME/repos/jobs/dfy-untagger
schedule: '57 23 * * *'
<<: *defaults
- name: dfy-weekly
command: $HOME/repos/jobs/dfy-weekly
schedule: '27 1 * * 0'
<<: *defaults
- name: inactive-interface-admins
command: $HOME/repos/jobs/inactive-interface-admins
schedule: '18 23 28 * *'
<<: *defaults
- name: infotalk-editnotice
command: $HOME/repos/jobs/infotalk-editnotice
schedule: '7 19 * * *'
<<: *defaults
- name: massmessage-list-updater
command: $HOME/repos/jobs/massmessage-list-updater
schedule: '13 0 * * *'
<<: *defaults
- name: mlr-daily
command: $HOME/repos/jobs/mlr-daily
schedule: '16 16 * * *'
<<: *defaults
- name: purge-daily
command: $HOME/repos/jobs/purge-daily
schedule: '0 1 * * *'
<<: *defaults
- name: purge-dup-args
command: $HOME/repos/jobs/purge-dup-args
schedule: '33 * * * *'
<<: *defaults
- name: purge-script-errors-ns0
command: $HOME/repos/jobs/purge-script-errors-ns0
schedule: '4 * * * *'
<<: *defaults
- name: purge-weekly
command: $HOME/repos/jobs/purge-weekly
schedule: '27 1 * * 1'
<<: *defaults
- name: svg-validator-daily
command: $HOME/repos/jobs/svg-validator-daily
schedule: '2 2 * * *'
<<: *defaults
- name: svg-validator-monthly
command: $HOME/repos/jobs/svg-validator-monthly
schedule: '3 3 28 * *'
<<: *defaults
1 change: 1 addition & 0 deletions jjmc89-bot-scripts
Submodule jjmc89-bot-scripts added at af57b6
16 changes: 16 additions & 0 deletions jobs/admin-activity
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

day=$(date -u +"%d")

if [ "$day" = "01" ]; then
args=(--notify c1n1 --notify c2 --notify c2r)
elif [ "$day" = "23" ]; then
args=(--update-recent --notify c1n2)
else
args=(--update-recent)
fi

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/admin_activity.py -dir:.pywikibot-admin-activity "${args[@]}"
19 changes: 19 additions & 0 deletions jobs/bsicons-replacer
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/bsiconsbot/bin/activate

if [ "$(date +"%u")" -eq 6 ]; then
tpl='--transcluded'
else
tpl=''
fi

# shellcheck disable=SC2086
bsicons-replacer \
-lang:commons -family:commons \
-ns:not:2,3 \
User:JJMC89_bot/config/BSiconsReplacer/global \
--local-config User:JJMC89_bot/config/BSiconsReplacer \
--always \
$tpl
12 changes: 12 additions & 0 deletions jobs/bsicons-reporter
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/bsiconsbot/bin/activate

bsicons-reporter \
-lang:commons -family:commons \
User:JJMC89_bot/config/BSicons \
User:JJMC89_bot/report/BSicons/changes \
User:JJMC89_bot/report/BSicons/large \
User:JJMC89_bot/report/BSicons/logs \
User:JJMC89_bot/report/BSicons/redirects
12 changes: 12 additions & 0 deletions jobs/cat-dbl-redir-fixer
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

args=(--always -ns:14 "-subcats:'Double-redirected categories'")

if [ "$(date +"%u")" -eq 6 ]; then
args+=("-transcludes:'Category redirect'")
fi

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/category_double_redirect_fixer.py "${args[@]}"
8 changes: 8 additions & 0 deletions jobs/cfdw
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/cfdw.py \
-dir:"$HOME"/.pywikibot-cfdw \
-page:WP:Categories_for_discussion/Working
8 changes: 8 additions & 0 deletions jobs/cfdwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/cfdw.py \
-dir:"$HOME"/.pywikibot-cfdwl \
-page:WP:Categories_for_discussion/Working/Large
9 changes: 9 additions & 0 deletions jobs/commons-potd-importer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# shellcheck disable=SC2086
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/multi/commons_potd_importer.py --always \
-page:'User:JJMC89 bot/Commons picture of the day' \
-page:'eu:User:JJMC89 bot/Commons eguneko irudia'
7 changes: 7 additions & 0 deletions jobs/dfy-daily
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/draftification_report.py \
'User:JJMC89 bot/report/Draftifications/daily'
9 changes: 9 additions & 0 deletions jobs/dfy-monthly
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/draftification_report.py \
'User:JJMC89 bot/report/Draftifications/monthly' \
--start "$(date -ud "-1 month" +"%Y-%m-%dT00:00:00Z")" \
--end "$(date -u +"%Y-%m-%dT00:00:00Z")"
9 changes: 9 additions & 0 deletions jobs/dfy-tagger
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/draftification_tagger.py \
-dir:"$HOME"/.pywikibot-dfy-tagger \
--always \
--start "$(date -ud '-15 min' +"%Y-%m-%dT%H:%M:%SZ")"
13 changes: 13 additions & 0 deletions jobs/dfy-untagger
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/pwb/bin/activate

python3 "$HOME"/repos/pywikibot/pwb.py \
template \
-dir:"$HOME"/.pywikibot-dfy-tagger \
-ns:0 \
'drafts moved from mainspace' \
-remove \
-summary:'Remove {{drafts moved from mainspace}}' \
-always
9 changes: 9 additions & 0 deletions jobs/dfy-weekly
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

. "$HOME"/repos/.venvs/jjmc89-bot-scripts/bin/activate

python3 "$HOME"/repos/jjmc89-bot-scripts/enwiki/draftification_report.py \
'User:JJMC89 bot/report/Draftifications/weekly' \
--start "$(date -ud "-1 week" +"%Y-%m-%dT00:00:00Z")" \
--end "$(date -u +"%Y-%m-%dT00:00:00Z")"
Loading

0 comments on commit 98b96a8

Please sign in to comment.