added lichess bot
This commit is contained in:
32
lichess_bot/.github/workflows/mypy.yml
vendored
Normal file
32
lichess_bot/.github/workflows/mypy.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# This workflow will install Python dependencies and run mypy
|
||||
|
||||
name: Mypy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
mypy:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest]
|
||||
python: [3.9, "3.11"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install -r test_bot/test-requirements.txt
|
||||
- name: Run mypy
|
||||
run: |
|
||||
mypy --strict .
|
||||
44
lichess_bot/.github/workflows/python-build.yml
vendored
Normal file
44
lichess_bot/.github/workflows/python-build.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# This workflow will install Python dependencies and lint
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
||||
|
||||
name: Python Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
python: [3.9, "3.10", "3.11"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install -r test_bot/test-requirements.txt
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide.
|
||||
# W503 and W504 are mutually exclusive. W504 is considered the best practice now.
|
||||
flake8 . --count --max-complexity=10 --max-line-length=127 --statistics --ignore=D,W503
|
||||
- name: Lint with flake8-markdown
|
||||
run: |
|
||||
flake8-markdown "*.md"
|
||||
flake8-markdown "wiki/*.md"
|
||||
- name: Lint with flake8-docstrings
|
||||
run: |
|
||||
flake8 . --count --max-line-length=127 --statistics --select=D
|
||||
48
lichess_bot/.github/workflows/python-test.yml
vendored
Normal file
48
lichess_bot/.github/workflows/python-test.yml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# This workflow will install Python dependencies and run tests
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
||||
|
||||
name: Python Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
python: [3.9, "3.11"]
|
||||
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install -r test_bot/test-requirements.txt
|
||||
- name: Restore engines
|
||||
id: cache-temp-restore
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
TEMP
|
||||
key: ${{ matrix.os }}-engines
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
pytest --log-cli-level=10
|
||||
- name: Save engines
|
||||
id: cache-temp-save
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: |
|
||||
TEMP
|
||||
key: ${{ steps.cache-temp-restore.outputs.cache-primary-key }}
|
||||
65
lichess_bot/.github/workflows/sync-wiki.yml
vendored
Normal file
65
lichess_bot/.github/workflows/sync-wiki.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
name: Sync wiki
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'wiki/**'
|
||||
- 'README.md'
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
if: github.repository == 'lichess_bot-devs/lichess_bot'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout wiki
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: "${{ github.repository }}.wiki"
|
||||
path: "lichess_bot.wiki"
|
||||
- name: Set path
|
||||
uses: dorny/paths-filter@v2
|
||||
id: changes
|
||||
with:
|
||||
filters: |
|
||||
wiki:
|
||||
- 'wiki/**'
|
||||
home:
|
||||
- 'wiki/Home.md'
|
||||
readme:
|
||||
- 'README.md'
|
||||
- name: Prevent Conflicts
|
||||
if: |
|
||||
steps.changes.outputs.home == 'true' &&
|
||||
steps.changes.outputs.readme == 'true'
|
||||
run: |
|
||||
echo "Error: Conflicting changes. Edit either the README.md file or the wiki/Home.md file, not both."
|
||||
exit 1
|
||||
- name: Set github bot global config
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "actions-user"
|
||||
- name: Sync README.md to wiki/Home.md
|
||||
if: steps.changes.outputs.readme == 'true'
|
||||
run: |
|
||||
cp -r $GITHUB_WORKSPACE/README.md $GITHUB_WORKSPACE/wiki/Home.md
|
||||
git add wiki/Home.md
|
||||
git commit -m "Auto update wiki/Home.md"
|
||||
git push
|
||||
- name: Sync wiki/Home.md to README.md
|
||||
if: steps.changes.outputs.home == 'true'
|
||||
run: |
|
||||
cp -r $GITHUB_WORKSPACE/wiki/Home.md $GITHUB_WORKSPACE/README.md
|
||||
git add README.md
|
||||
git commit -m "Auto update README.md"
|
||||
git push
|
||||
- name: Sync all files to wiki
|
||||
run: |
|
||||
cp -r $GITHUB_WORKSPACE/wiki/* $GITHUB_WORKSPACE/lichess-bot.wiki
|
||||
cd $GITHUB_WORKSPACE/lichess-bot.wiki
|
||||
git add .
|
||||
git commit -m "Auto update wiki"
|
||||
git push
|
||||
26
lichess_bot/.github/workflows/update_version.py
vendored
Normal file
26
lichess_bot/.github/workflows/update_version.py
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Automatically updates the lichess_bot version."""
|
||||
import yaml
|
||||
import datetime
|
||||
import os
|
||||
|
||||
with open("lib/versioning.yml") as version_file:
|
||||
versioning_info = yaml.safe_load(version_file)
|
||||
|
||||
current_version = versioning_info["lichess_bot_version"]
|
||||
|
||||
utc_datetime = datetime.datetime.utcnow()
|
||||
new_version = f"{utc_datetime.year}.{utc_datetime.month}.{utc_datetime.day}."
|
||||
if current_version.startswith(new_version):
|
||||
current_version_list = current_version.split(".")
|
||||
current_version_list[-1] = str(int(current_version_list[-1]) + 1)
|
||||
new_version = ".".join(current_version_list)
|
||||
else:
|
||||
new_version += "1"
|
||||
|
||||
versioning_info["lichess_bot_version"] = new_version
|
||||
|
||||
with open("lib/versioning.yml", "w") as version_file:
|
||||
yaml.dump(versioning_info, version_file, sort_keys=False)
|
||||
|
||||
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
|
||||
print(f"new_version={new_version}", file=fh)
|
||||
30
lichess_bot/.github/workflows/versioning.yml
vendored
Normal file
30
lichess_bot/.github/workflows/versioning.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: Versioning
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
versioning:
|
||||
if: github.repository == 'lichess_bot-devs/lichess_bot'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python 3.11
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.11"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install PyYAML
|
||||
- name: Update version
|
||||
id: new-version
|
||||
run: python .github/workflows/update_version.py
|
||||
- name: Auto update version
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "actions-user"
|
||||
git add lib/versioning.yml
|
||||
git commit -m "Auto update version to ${{ steps.new-version.outputs.new_version }}"
|
||||
git push origin HEAD:master
|
||||
Reference in New Issue
Block a user