Skip to content

update codebase

update codebase #177

Workflow file for this run

name: update codebase
on:
# push:
# branches:
# - master
schedule:
- cron: "0 6 * * 1" # 06:00 of every Monday
workflow_dispatch:
jobs:
dev_updates:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.PR_MAINTAIN }}
repository: Project-MONAI/MONAI
ref: dev
path: src_dir
- uses: actions/checkout@v3
with:
path: scripts
- uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Cache weekly timestamp
id: pip-cache
run: echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache for pip
uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }}
- name: Install tools
run: |
sudo apt-get -y install dos2unix libtinfo5
python -m pip install --upgrade pip wheel
python -m pip install -r src_dir/requirements-dev.txt
python -m pip install autopep8 yapf
python scripts/remove_type_ignore.py src_dir/setup.cfg src_dir/
- name: Make changes
id: black
run: |
dos2unix --version
autopep8 --version
isort --version
black --version
cd src_dir/
find . -type f -not -path "./.git/*" -print0 | xargs -0 -n 1 -P 2 dos2unix # remove return
autopep8 --recursive --in-place --aggressive --aggressive --ignore E721 --max-line-length 200 .
isort .
yapf --in-place --recursive --parallel --exclude "monai/_version.py" --exclude "versioneer.py" --style="{COLUMN_LIMIT: 150}" .
black --skip-magic-trailing-comma .
git config --global user.name 'monai-bot'
git config --global user.email '[email protected]'
git add .
git diff --cached | cat
script_file=runtests.sh
if [[ -f $script_file ]]; then
./runtests.sh --precommit --autofix --mypy --flake8 --clangformat
fi
changes=
if [ -n "$(git status --porcelain)" ]; then
changes="true"
fi
echo "format=$changes" >> $GITHUB_OUTPUT
shell: bash
- name: Git commit
if: steps.black.outputs.format == 'true'
run: |
cd src_dir/
git commit -sam "[MONAI] code formatting"
git diff @~1
git checkout -b auto-update
git push -f --set-upstream origin auto-update
sleep 10
shell: bash
- name: Submit PR
if: steps.black.outputs.format == 'true'
run: |
cd src_dir/
gh pr create --fill --title "auto updates" --base dev --head "auto-update"
env:
token: ${{ secrets.PR_MAINTAIN }}
GITHUB_TOKEN: ${{ secrets.PR_MAINTAIN }}