-
Notifications
You must be signed in to change notification settings - Fork 35
162 lines (134 loc) · 5.27 KB
/
merge_pr.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: "PR merge workflow"
on:
push:
branches:
- main
jobs:
apply-autopep8-isort:
name: Autopep8 and isort auto-format by a bot
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
- name: Apply isort
id: isort-step
# default configuration use --check-only and --diff instead of --in-place options.
uses: isort/isort-action@master
with:
configuration: --only-modified
- name: autopep8 check and fix
id: autopep8
uses: peter-evans/autopep8@v2
with:
args: --exit-code --recursive --in-place --aggressive --aggressive .
- name: Detect changes by isort
uses: tj-actions/verify-changed-files@v18
id: verify-isort-update
with:
files: |
tests/
sinergym/
examples/
*.py
- name: Commit format changes
if: steps.autopep8.outputs.exit-code == 2 || steps.verify-isort-update.outputs.files_changed == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Automatic format fixes (autopep8 + isort)
apply-documentation:
needs: [apply-autopep8-isort]
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ vars.PYTHON_VERSION }}
- name: Verify documentation update
uses: dorny/paths-filter@v3
id: verify-documentation-update
with:
filters: |
doc:
- 'docs/source/**'
- name: Install dependencies
if: steps.verify-documentation-update.outputs.doc == 'true'
run: |
sudo apt install python3-enchant
sudo apt install pandoc
poetry install --no-interaction --with doc
- name: Build multiversion docs
if: steps.verify-documentation-update.outputs.doc == 'true'
run: poetry run sphinx-multiversion docs/source docs/compilation
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/compilation
publish_branch: github-pages
destination_dir: docs/compilation
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
keep_files: false
enable_jekyll: true
tests:
needs: [apply-autopep8-isort]
name: tests execution and CodeCov upload
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build the latest Docker image
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=test --tag pushmain/sinergym:latest
- name: Create a shared folder for coverage output
run: mkdir shared
- name: Execute tests from container
run: docker run -v ${GITHUB_WORKSPACE}/shared:/shared -t pushmain/sinergym:latest /bin/bash -c 'pytest -vv --cov sinergym --cov-report=xml tests/ && mv coverage.xml /shared'
- name: Upload to CodeCov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: /home/runner/work/sinergym/sinergym/shared/coverage.xml
fail_ci_if_error: true
verbose: true
update-dockerhub:
needs: [apply-autopep8-isort]
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# If you don't have secrets configured with docker credential, this job will be skipped
name: Container build and upload in Docker Hub
runs-on: ubuntu-24.04
steps:
- name: Checkout code
if: "${{ env.DOCKER_USER != '' && env.DOCKER_PASSWORD != '' }}"
uses: actions/checkout@v4
- name: Build the latest Docker image
if: "${{ env.DOCKER_USER != '' && env.DOCKER_PASSWORD != '' }}"
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=format,test,doc,DRL,gcloud --tag $DOCKER_USER/sinergym:latest
- name: Build the latest lite Docker image
if: "${{ env.DOCKER_USER != '' && env.DOCKER_PASSWORD != '' }}"
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=test --tag $DOCKER_USER/sinergym:latest-lite
- name: Login in Docker Hub account
if: "${{ env.DOCKER_USER != '' && env.DOCKER_PASSWORD != '' }}"
run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Push container with all extras
if: "${{ env.DOCKER_USER != '' && env.DOCKER_PASSWORD != '' }}"
run: docker push $DOCKER_USER/sinergym:latest
- name: Push container used with test
if: "${{ env.DOCKER_USER != '' && env.DOCKER_PASSWORD != '' }}"
run: docker push $DOCKER_USER/sinergym:latest-lite