From 68d49cf783eb9f1b4ce53b83aab7a8fed603d136 Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Wed, 30 Oct 2024 14:54:06 +0100 Subject: [PATCH] debug CI --- .github/workflows/python-ci.yaml | 76 --------------- .github/workflows/test-and-package.yaml | 121 ++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 76 deletions(-) delete mode 100644 .github/workflows/python-ci.yaml create mode 100644 .github/workflows/test-and-package.yaml diff --git a/.github/workflows/python-ci.yaml b/.github/workflows/python-ci.yaml deleted file mode 100644 index 1923636..0000000 --- a/.github/workflows/python-ci.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: CI using pip - -on: [push, pull_request] - -jobs: - - # Job 1 - Code_Consistency: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 - - name: Suggestion to fix issues - if: ${{ failure() }} - run: | - echo "::notice::In project root run 'python -m ruff check . --fix' and commit changes to fix issues." - : # exit 1 - - # Job 2 - Code_Testing: - strategy: - fail-fast: false - matrix: - python-version: ['3.9', '3.10', '3.11'] - os: [ubuntu-latest, macos-latest, windows-latest] - - runs-on: ${{ matrix.os }} - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: pip install -e '.[dev]' - - - name: Test with tox - run: | - pip install tox tox-gh-actions coverage - tox - - - name: Upload coverage - uses: codecov/codecov-action@v4.0.1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - name: Pytest coverage - env_vars: OS,PYTHON,GITHUB_ACTIONS,GITHUB_ACTION,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_HEAD_REF,GITHUB_RUN_ID,GITHUB_SHA,COVERAGE_FILE - env: - OS: ${{ matrix.os }} - PYTHON: ${{ matrix.python-version }} - - # Job 3 - Package_Testing: - - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Install dependencies and build - run: | - pip install -e '.[dev]' - python -m build - - - name: Check Build - run: | - cd ./dist - pytest ../ diff --git a/.github/workflows/test-and-package.yaml b/.github/workflows/test-and-package.yaml new file mode 100644 index 0000000..b9dce0a --- /dev/null +++ b/.github/workflows/test-and-package.yaml @@ -0,0 +1,121 @@ +# This workflow will for a variety of Python versions +# - install the code base +# - lint the code base +# - test the code base +# - upload the test coverage to codecov +# +# It will also +# - build the package +# - check the package +# +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Test code and package + +on: [push, pull_request] + +jobs: + + # Job 1 + code-consistency: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Ensure repository stays clean + uses: astral-sh/ruff-action@v1 + + - name: Suggestion to fix issues + if: ${{ failure() }} + run: | + echo "::notice::In project root run 'python -m ruff check . --fix' and commit changes to fix issues." + exit 1 + + # Job 2 + code-testing: + needs: code-consistency # previous job 'code-consistency' need to be finished first + + # current job matrix. if modified, remember to UPDATE the strategy in the next job + strategy: + fail-fast: false + matrix: + python-version: ['3.11'] # ['3.9', '3.10', '3.11', '3.12'] + os: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + run: pip install '.[dev]' + + #- name: Test with tox + # run: | + # pip install tox tox-gh-actions coverage + # tox --colored yes + + #- name: Upload coverage + # uses: codecov/codecov-action@v4.0.1 + # with: + # token: ${{ secrets.CODECOV_TOKEN }} + # name: Pytest coverage + # env_vars: OS,PYTHON,GITHUB_ACTIONS,GITHUB_ACTION,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_HEAD_REF,GITHUB_RUN_ID,GITHUB_SHA,COVERAGE_FILE + # env: + # OS: ${{ matrix.os }} + # PYTHON: ${{ matrix.python-version }} + + - name: Create Python package # dist/*.whl + run: python -m build + + - name: Upload zipped Python package for next job + uses: actions/upload-artifact@v4 + with: + name: EasyCrystallography - Python ${{ matrix.python-version }} + path: | + dist/*.whl + tests/ + if-no-files-found: "error" + compression-level: 0 + + # Job 3 + package-testing: + needs: code-testing # previous job 'code-testing' need to be finished first + + strategy: + fail-fast: false + matrix: + python-version: ['3.11'] # ['3.9', '3.10', '3.11', '3.12'] + os: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Download zipped Python package from previous job + uses: actions/download-artifact@v4 + with: # name or path are taken from the upload step of the previous job + name: EasyCrystallography - Python ${{ matrix.python-version }} # name (without .zip) of the zipped artifact uploaded on the previous jobs + path: . # directory to extract downloaded zipped artifacts + + - name: Install Python package from previous job + run: pip install easycrystallography --no-index --find-links=dist/ + + - name: Run tests + run: pytest tests/ --color=yes