From f51c6a0e0b9605a7fc56a51c7cd28eeec7d0ab3f Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 14:50:45 -0600 Subject: [PATCH 1/9] Adding github action for linting and documentation --- .github/workflows/python-app.yml | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 000000000..165bd6c09 --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,59 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + + +permissions: + contents: read + +jobs: + PEP-Guidelines: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 flake8-docstrings pep8-naming + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 ./GEMstack --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=__init__.py || exit 1 + # to enable more advanced checks on the repo, uncomment the lines below (There are around 3000 violations) + # flake8 ./GEMstack --ignore=D,C901,E402,E231 --count --max-complexity=10 --max-line-length=127 --statistics --exclude=__init__.py || exit 1 + # if we want to enable documentation checks, uncomment the line below + # flake8 ./GEMstack --ignore=E128,E402,E501,F401 --docstring-convention pep257 --max-line-length=120 --exclude=__init__.py || exit 1 + continue-on-error: false + + Documentation: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install sphinx sphinx-rtd-theme + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Generate Documentation + run: | + # stop the build if there are Python syntax errors or undefined names + sphinx-build -b html docs docs/build + - name: Save Documentation as Artifact + uses: actions/upload-artifact@v2 + with: + name: documentation + path: documents/build From 86cd573b8cd17a7ba4c0bceeaf8b97de9dc136d0 Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 14:56:01 -0600 Subject: [PATCH 2/9] Adding github action trigger on all commits --- .github/workflows/python-app.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 165bd6c09..ab65f49b8 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -3,6 +3,12 @@ name: Python application +on: + push: + branches: + - '**' + pull_request: + permissions: contents: read From 0d4627c58e7bccd7e1cdf04d4da340fabce95037 Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 14:57:09 -0600 Subject: [PATCH 3/9] Upgrading version of upload artifact --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index ab65f49b8..5966ffbd7 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -59,7 +59,7 @@ jobs: # stop the build if there are Python syntax errors or undefined names sphinx-build -b html docs docs/build - name: Save Documentation as Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: documentation path: documents/build From daaaa1755fede7fb3be69334d8fc06e13d4c4bec Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 15:03:47 -0600 Subject: [PATCH 4/9] Optimizing the workflow yaml --- .github/workflows/python-app.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 5966ffbd7..19f573309 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -28,7 +28,6 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 flake8-docstrings pep8-naming - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names @@ -49,6 +48,13 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.10" + - name: Cache dependencies + - uses: actions/cache@v2 + - with: + path: ~/.cache/pip + keys: ${{ runner.os}}-python-${{hashFiles('**/requirements.txt')}} + restore-keys: | + ${{runner.os}}-python- - name: Install dependencies run: | python -m pip install --upgrade pip From 6100ea594917d2602f1033a8901391ce018e8447 Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 15:06:04 -0600 Subject: [PATCH 5/9] Optimizing the workflow yaml --- .github/workflows/python-app.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 19f573309..c95cb087c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -49,8 +49,8 @@ jobs: with: python-version: "3.10" - name: Cache dependencies - - uses: actions/cache@v2 - - with: + uses: actions/cache@v2 + with: path: ~/.cache/pip keys: ${{ runner.os}}-python-${{hashFiles('**/requirements.txt')}} restore-keys: | From 3a2f8e1a784e012ea32c587f5e28fe72b6ee0d10 Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 15:07:57 -0600 Subject: [PATCH 6/9] Correcting in the key names --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index c95cb087c..fa040db13 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -52,7 +52,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - keys: ${{ runner.os}}-python-${{hashFiles('**/requirements.txt')}} + key: ${{ runner.os}}-python-${{hashFiles('**/requirements.txt')}} restore-keys: | ${{runner.os}}-python- - name: Install dependencies From 79c3a683b8def9dbe0f9123061e7bb741afcaaaa Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 15:13:52 -0600 Subject: [PATCH 7/9] Removing requirements.txt installation in documentation --- .github/workflows/python-app.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index fa040db13..b452f3c51 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -48,18 +48,10 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.10" - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os}}-python-${{hashFiles('**/requirements.txt')}} - restore-keys: | - ${{runner.os}}-python- - name: Install dependencies run: | python -m pip install --upgrade pip pip install sphinx sphinx-rtd-theme - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Generate Documentation run: | # stop the build if there are Python syntax errors or undefined names From ad4af5bf8162b5a0a7512d208abcac6e3e19a779 Mon Sep 17 00:00:00 2001 From: animesh Date: Sun, 2 Feb 2025 15:15:07 -0600 Subject: [PATCH 8/9] Correcting name of build artifact for documentation folder --- .github/workflows/python-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index b452f3c51..541b071a7 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -60,4 +60,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: documentation - path: documents/build + path: docs/build From e1a0f8ef9a9f85c1c1f834ba7138bec397b3f56f Mon Sep 17 00:00:00 2001 From: Animesh Singh Date: Sun, 2 Feb 2025 15:18:35 -0600 Subject: [PATCH 9/9] Removing action trigger on PR --- .github/workflows/python-app.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 541b071a7..3de575d8e 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -7,8 +7,7 @@ on: push: branches: - '**' - pull_request: - + permissions: contents: read