From b5fb84cb2a5ca21b95157ebac38b48c183008588 Mon Sep 17 00:00:00 2001 From: JoschD <26184899+JoschD@users.noreply.github.com> Date: Tue, 7 Nov 2023 16:12:47 +0100 Subject: [PATCH] Update to common workflows (#35) * common workflows * updated python versions in setup.py * Readme - it's available on windows --- .github/workflows/README.md | 57 +++++++++---------- .github/workflows/coverage.yml | 88 ++++++----------------------- .github/workflows/cron.yml | 56 +++++------------- .github/workflows/documentation.yml | 65 +++++---------------- .github/workflows/publish.yml | 61 ++++---------------- .github/workflows/tests.yml | 62 ++++++-------------- README.md | 6 +- setup.py | 2 +- 8 files changed, 104 insertions(+), 293 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 28bbb63..ce6d514 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -1,29 +1,28 @@ -# Continous Integration Workflows - -This package implements different workflows for CI. -They are organised as follows. - -### Documentation - -The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful). -It runs on `ubuntu-latest` and our lowest supported Python version, `Python 3.7`. - -### Testing Suite - -Tests are ensured in the `tests` workflow, which triggers on all pushes. -It runs on a matrix of all supported operating systems (ubuntu-18.04, ubuntu-20.04, windows-latest and macos-latest) for all supported Python versions (currently `3.7`, `3.8`, `3.9` and `3.10`). - -### Test Coverage - -Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`. -It runs on `ubuntu-latest` & the lowest supported Python version (`Python 3.7`), and reports the coverage results of the test suite to `CodeClimate`. - -### Regular Testing - -A `cron` workflow triggers every Monday at 3am (UTC time) and runs the full testing suite, on all supported operating systems and supported Python versions. -It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included. - -### Publishing - -Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the Github repository. -It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful. +# Continous Integration Workflows + +This package implements different workflows for CI, based on our organisation's common workflows. +They are organised as follows. + +### Documentation + +The `documentation` workflow triggers on any push to master, builds the documentation and pushes it to the `gh-pages` branch (if the build is successful). + +### Testing Suite + +Tests are ensured in the `tests` workflow, which triggers on all pushes. +It runs on a matrix of all supported operating systems for all supported Python versions. + +### Test Coverage + +Test coverage is calculated in the `coverage` wokflow, which triggers on pushes to `master` and any push to a `pull request`. +It reports the coverage results of the test suite to `CodeClimate`. + +### Regular Testing + +A `cron` workflow triggers every Monday at 3am (UTC time) and runs the full testing suite, on all available operating systems and supported Python versions. +It also runs on `Python 3.x` so that newly released Python versions that would break tests are automatically included. + +### Publishing + +Publishing to `PyPI` is done through the `publish` workflow, which triggers anytime a `release` is made of the GitHub repository. +It builds a `wheel`, checks it, and pushes to `PyPI` if checks are successful. diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4bb4a4c..0cf7fcb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,72 +1,16 @@ -# Runs all tests and pushes coverage report to codeclimate -name: Coverage - -defaults: - run: - shell: bash - -on: # Runs on all push events to master branch and any push related to a pull request - push: - branches: - - master - pull_request: # so that codeclimate gets coverage and reports on the diff - -jobs: - coverage: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: # only lowest supported Python on latest ubuntu - os: [ubuntu-latest] - python-version: [3.7] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[test]' - - - name: Set up env for CodeClimate (push) - run: | - echo "GIT_BRANCH=${GITHUB_REF/refs\/heads\//}" >> $GITHUB_ENV - echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV - if: github.event_name == 'push' - - - name: Set up env for CodeClimate (pull_request) - env: - PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} - run: | - echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV - echo "GIT_COMMIT_SHA=$PR_HEAD_SHA" >> $GITHUB_ENV - if: github.event_name == 'pull_request' - - - name: Prepare CodeClimate binary - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - run: | - curl -LSs 'https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64' >./cc-test-reporter; - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build - - - name: Run tests - run: python -m pytest -m "not cern_network" --cov-report xml --cov=pylhc_submitter - - - name: Push Coverage to CodeClimate - if: ${{ success() }} # only if tests were successful - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - run: ./cc-test-reporter after-build +# Runs all tests and pushes coverage report to codeclimate +name: Coverage + +on: # Runs on all push events to master branch and any push related to a pull request + push: + branches: + - master + pull_request: # so that codeclimate gets coverage and reports on the diff + +jobs: + coverage: + uses: pylhc/.github/.github/workflows/coverage.yml@master + with: + src-dir: pylhc_submitter + pytest-options: -m "not cern_network" + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index d18df8e..c67d827 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -1,43 +1,13 @@ -# Runs all tests on master every week at 3 am (UTC time) -name: Cron Testing - -defaults: - run: - shell: bash - -on: # Runs on master branch on Mondays at 3am UTC time - schedule: - - cron: '* 3 * * mon' - -jobs: - tests: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04, ubuntu-20.04, ubuntu-latest, macos-latest, windows-latest] - # Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser - python-version: [3.7, 3.8, 3.9, "3.10", 3.x] # crons should always run latest python hence 3.x - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[test]' - - - name: Run tests - run: python -m pytest -m "not cern_network" +# Runs all tests on master on Mondays at 3 am (UTC time) +name: Cron Testing + + +on: + schedule: + - cron: '* 3 * * mon' + +jobs: + tests: + uses: pylhc/.github/.github/workflows/cron.yml@master + with: + pytest-options: -m "not cern_network" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 3562495..ace3140 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,51 +1,14 @@ -# Build and publish documentation -name: Build and upload documentation - -defaults: - run: - shell: bash - -on: # Runs on any push event to master - push: - branches: - - 'master' - -jobs: - documentation: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: # only lowest supported Python on latest ubuntu - os: [ubuntu-latest] - python-version: [3.7] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[doc]' - - - name: Build documentation - run: python -m sphinx -b html doc ./doc_build -d ./doc_build - - - name: Upload documentation to gh-pages - if: ${{ success() }} - uses: JamesIves/github-pages-deploy-action@3.6.2 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: doc_build +# Build documentation +# The build is uploaded as artifact if the triggering event is a push for a pull request +# The build is published to github pages if the triggering event is a push to the master branch (PR merge) +name: Build and upload documentation + +on: # Runs on any push event in a PR or any push event to master + pull_request: + push: + branches: + - 'master' + +jobs: + documentation: + uses: pylhc/.github/.github/workflows/documentation.yml@master \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 79fce4c..bc21fe3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,50 +1,11 @@ -# Publishes to PyPI upon creation of a release -name: Upload Package to PyPI - -defaults: - run: - shell: bash - -on: # Runs everytime a release is added to the repository - release: - types: [created] - -jobs: - deploy: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: # only lowest supported Python on ubuntu-latest - os: [ubuntu-latest] - python-version: [3.7] - - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools, wheel, build and twine - run: python -m pip install --upgrade pip setuptools wheel build twine - - - name: Build and check build - run: | - python -m build - twine check dist/* - - - name: Publish - if: ${{ success() }} - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload dist/* +# Publishes to PyPI upon creation of a release +name: Upload Package to PyPI + +on: # Runs everytime a release is added to the repository + release: + types: [created] + +jobs: + deploy: + uses: pylhc/.github/.github/workflows/publish.yml@master + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 35d9620..084d017 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,44 +1,18 @@ -# Runs all tests not flagged as "cern_network" with a pytest marker -name: Tests - -defaults: - run: - shell: bash - -on: # Runs on all push events to any branch that isn't master - push: - branches-ignore: - - 'master' - -jobs: - tests: - name: ${{ matrix.os }} / ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04, ubuntu-20.04, macos-latest, windows-latest] - # Make sure to escape 3.10 with quotes so it doesn't get interpreted as float 3.1 by GA's parser - python-version: [3.7, 3.8, 3.9, "3.10"] - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' - cache-dependency-path: '**/setup.py' - - - name: Get full Python version - id: full-python-version - run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") - - - name: Upgrade pip, setuptools and wheel - run: python -m pip install --upgrade pip setuptools wheel - - - name: Install package - run: python -m pip install '.[test]' - - - name: Run basic tests - run: python -m pytest -m "not cern_network" +# Runs all tests +name: All Tests + +defaults: + run: + shell: bash + +on: # Runs on any push event to any branch except master (the coverage workflow takes care of that) + push: + branches-ignore: + - 'master' + +jobs: + tests: + uses: pylhc/.github/.github/workflows/tests.yml@master + with: + pytest-options: -m "not cern_network" + \ No newline at end of file diff --git a/README.md b/README.md index 9ca3155..e0926a8 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ See the [API documentation](https://pylhc.github.io/submitter/) for details. ## Installing -**Note**: This package is unavailable on `Windows`, and available on: -- `Linux` through `PyPI`. -- `Linux` and `macOS` through `conda-forge`. +**Note**: This package is available +- through `PyPI` on `Linux`, `Windows` and `macOS` +- through `conda-forge` on `Linux` and `macOS` Installation is easily done via `pip`: ```bash diff --git a/setup.py b/setup.py index d41e3d9..c40d86b 100644 --- a/setup.py +++ b/setup.py @@ -67,10 +67,10 @@ def about_package(init_posixpath: pathlib.Path) -> dict: "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], packages=setuptools.find_packages(exclude=["tests*", "doc"]), include_package_data=True,