From cf84765aa08934b3a8465b1e4178f4df60071ef8 Mon Sep 17 00:00:00 2001 From: "M. Zain Sohail" Date: Mon, 16 Oct 2023 14:04:52 +0200 Subject: [PATCH] update all workflows to use caches --- .github/workflows/linting.yml | 33 ++++++++++++++ .github/workflows/testing.yml | 30 +++++++++++++ .github/workflows/testing_multiversion.yml | 51 ++++++++++++++++++++++ .github/workflows/update_requirements.yml | 36 +++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 .github/workflows/linting.yml create mode 100644 .github/workflows/testing.yml create mode 100644 .github/workflows/testing_multiversion.yml create mode 100644 .github/workflows/update_requirements.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 00000000..c1ee31e3 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,33 @@ +name: linting + +# Triggers the workflow on push for all branches +on: [push] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + # Check out repo and set up Python + - uses: actions/checkout@v3 + with: + lfs: true + + # Use cached python and dependencies, install poetry + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main + with: + python-version: 3.8 + poetry-version: 1.2.2 + + # Linting steps, excute all linters even if one fails + - name: pycodestyle + run: + poetry run pycodestyle --ignore=E203,E501,W503 sed tests + - name: pylint + if: ${{ always() }} + run: + poetry run pylint --good-names=i,j,k,ex,x,y,t,k,v,ax,df,ec,mc,dc,ct --disable=fixme,too-many-branches,too-many-locals,too-many-statements,too-many-arguments,too-many-lines,too-many-public-methods,too-many-instance-attributes,too-few-public-methods sed tests + - name: mypy + if: ${{ always() }} + run: + poetry run mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional sed tests \ No newline at end of file diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 00000000..4509ea82 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,30 @@ +name: pytest + +on: + pull_request + +jobs: + pytest: + runs-on: ubuntu-latest + steps: + # Check out repo and set up Python + - name: Check out the repository + uses: actions/checkout@v4 + with: + lfs: true + + # Use cached python and dependencies, install poetry + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main + with: + python-version: 3.8 + poetry-version: 1.2.2 + + # Run pytest with coverage report and upload results to coveralls + - name: Run tests on python 3.8 + run: | + poetry run pytest --cov=sed -n auto tests/ + - name: Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/testing_multiversion.yml b/.github/workflows/testing_multiversion.yml new file mode 100644 index 00000000..d5c51337 --- /dev/null +++ b/.github/workflows/testing_multiversion.yml @@ -0,0 +1,51 @@ +name: pytest multiversion + +on: + push: + branches: [ main ] + +jobs: + pytest: + # Using matrix strategy + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + runs-on: ubuntu-latest + steps: + # Check out repo and set up Python + - name: Check out the repository + uses: actions/checkout@v4 + with: + lfs: true + + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main + with: + python-version: ${{matrix.python-version}} + poetry-version: 1.2.2 + + # Use cached python and dependencies, install poetry + - name: Run tests on python ${{matrix.python-version}} + run: | + poetry run pytest --cov=sed -n auto tests/ + + # run this job after each pytest job is finished + - name: Coveralls Parallel + uses: coverallsapp/github-action@v2 + with: + flag-name: run-${{ join(matrix.*, '-') }} + parallel: true + + # run this job after all the pytest jobs are finished + # coveralls will combine the coverage reports and upload to coveralls.io + finish: + needs: pytest + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true + carryforward: "run-3.8,run-3.9,run-3.10" \ No newline at end of file diff --git a/.github/workflows/update_requirements.yml b/.github/workflows/update_requirements.yml new file mode 100644 index 00000000..675054d8 --- /dev/null +++ b/.github/workflows/update_requirements.yml @@ -0,0 +1,36 @@ +name: update docs/requirements.txt for readthedocs + +on: + # Triggers the workflow on push but only for the main branch + # and only for changes to the poetry.lock file + push: + branches: [ main ] + paths: [poetry.lock] + +jobs: + pytest: + runs-on: ubuntu-latest + steps: + # Check out repo and set up Python + - name: Check out the repository + uses: actions/checkout@v4 + with: + lfs: true + + # Use cached python and dependencies, install poetry + - name: "Setup Python, Poetry and Dependencies" + uses: packetcoders/action-setup-cache-python-poetry@main + with: + python-version: 3.8 + poetry-version: 1.2.2 + + # Generates and commits a requirements.txt used by readthedocs + - name: Export requirements.txt + run: poetry export --without-hashes --format=requirements.txt -o docs/requirements.txt -E docs -E notebook + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + message: 'Updating requirements for docs' + add: 'docs/requirements.txt' \ No newline at end of file