generated from actions/container-action
-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (74 loc) · 2.71 KB
/
format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: black-command
on:
repository_dispatch:
types: [black-command]
jobs:
black:
runs-on: ubuntu-latest
steps:
# Checkout the pull request branch
- uses: actions/checkout@v3
with:
token: ${{ secrets.PR_MAINTAIN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
# Setup Python environment
- uses: actions/setup-python@v3
with:
python-version: 3.8
# Set cache id
- name: Cache weekly timestamp
id: pip-cache
run: echo "::set-output name=datew::$(date '+%Y-%V')"
shell: bash
# Set cache (linux only)
- 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 isort black autopep8
run: |
sudo apt-get -y install dos2unix libtinfo5
pip install isort black autopep8 torch numpy pycodestyle!=2.11.0
# Execute autopep8 and black
- name: Autopep8 isort Black
id: black
run: |
dos2unix --version
autopep8 --version
isort --version
black --version
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 .
black --skip-magic-trailing-comma .
repo_name=${{ github.event.client_payload.pull_request.head.repo.full_name }}
repo_name=${repo_name: -5}
echo $repo_name
script_file=runtests.sh
if [[ -f $script_file && "$repo_name" == "MONAI" ]]; then
./runtests.sh --clangformat
fi
changes=
if [ -n "$(git status --porcelain)" ]; then
changes="true"
fi
echo ::set-output name=format::$changes
shell: bash
# Commit the change to the PR branch
- name: Commit to the PR branch
if: steps.black.outputs.format == 'true'
run: |
git config --global user.name 'monai-bot'
git config --global user.email 'monai.miccai2019@gmail.com'
git commit -sam "[MONAI] code formatting"
git push
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.PR_MAINTAIN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray