(v3.3.3) - Sinergym extra variables logging (#412) #171
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "PR merge workflow" | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
apply-autopep8: | |
name: Autopep8 auto-format by a bot | |
runs-on: ubuntu-latest | |
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: Automated format fixes (autopep8 + isort) | |
apply-documentation: | |
name: Documentation compilation update by bot | |
needs: [apply-autopep8] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- 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: Build the latest Docker image | |
if: steps.verify-documentation-update.outputs.doc == 'true' | |
run: docker build . --file Dockerfile --build-arg SINERGYM_EXTRAS=[extras] --tag pushmain/sinergym:latest | |
- name: Give permissions to container for see the repository | |
if: steps.verify-documentation-update.outputs.doc == 'true' | |
run: git config --global --add safe.directory /sinergym | |
- name: Compile documentation | |
if: steps.verify-documentation-update.outputs.doc == 'true' | |
run: docker run -v ${GITHUB_WORKSPACE}/docs/compilation:/workspaces/sinergym/docs/compilation -t pushmain/sinergym:latest /bin/bash -c 'sphinx-multiversion docs/source docs/compilation' | |
- name: Check sphinx spelling | |
if: steps.verify-documentation-update.outputs.doc == 'true' | |
run: docker run -t pushmain/sinergym:latest /bin/bash -c 'sphinx-build -M spelling docs/source docs/compilation' | |
- name: Pull local repository (needed if format commit has been done before) | |
if: steps.verify-documentation-update.outputs.doc == 'true' | |
run: git pull origin main | |
- name: Commit and push changes if exists | |
if: steps.verify-documentation-update.outputs.doc == 'true' | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
file_pattern: docs/compilation/* | |
commit_message: Documentation source update detected and pushed compilation build directory for Github Pages | |
tests: | |
needs: [apply-autopep8] | |
name: tests execution and CodeCov upload | |
runs-on: ubuntu-latest | |
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] | |
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-latest | |
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=[extras] --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 |