|
| 1 | +name: GH Actions CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "**" # main -- replaced main to allow CI to run in example cookie repo |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - "**" # main -- replaced main to allow CI to run in example cookie repo |
| 9 | + schedule: |
| 10 | + # Weekly tests at midnight on Sundays run on main by default: |
| 11 | + # Scheduled workflows run on the latest commit on the default or base branch. |
| 12 | + # (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule) |
| 13 | + - cron: "0 0 * * 0" |
| 14 | + |
| 15 | +concurrency: |
| 16 | + # Specific group naming so CI is only cancelled |
| 17 | + # within same PR or on merge to main |
| 18 | + group: ${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +defaults: |
| 22 | + run: |
| 23 | + shell: bash |
| 24 | + |
| 25 | +jobs: |
| 26 | + main-tests: |
| 27 | + if: "github.repository == 'other/mdakit-Cookie'" |
| 28 | + runs-on: ${{ matrix.os }} |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + os: [ubuntu-latest, macOS-latest, windows-latest] |
| 33 | + mdanalysis-version: ["latest", "develop"] |
| 34 | + python-version: ["3.11", "3.12", "3.13", "3.14"] |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Build information |
| 40 | + run: | |
| 41 | + uname -a |
| 42 | + df -h |
| 43 | + ulimit -a |
| 44 | +
|
| 45 | +
|
| 46 | + - name: Set up Python ${{ matrix.python-version }} |
| 47 | + uses: actions/setup-python@v5 |
| 48 | + with: |
| 49 | + python-version: ${{ matrix.python-version }} |
| 50 | + |
| 51 | + - name: Install testing dependencies |
| 52 | + run: | |
| 53 | + python -m pip install -U pytest pytest-xdist pytest-cov codecov |
| 54 | +
|
| 55 | +
|
| 56 | + - name: Install MDAnalysis version |
| 57 | + uses: MDAnalysis/install-mdanalysis@main |
| 58 | + with: |
| 59 | + version: ${{ matrix.mdanalysis-version }} |
| 60 | + install-tests: false |
| 61 | + installer: pip |
| 62 | + shell: bash |
| 63 | + |
| 64 | + - name: Install package |
| 65 | + run: | |
| 66 | + python --version |
| 67 | + python -m pip install . |
| 68 | +
|
| 69 | + - name: Python information |
| 70 | + run: | |
| 71 | + which python |
| 72 | + which pip |
| 73 | + pip list |
| 74 | +
|
| 75 | +
|
| 76 | + - name: Run tests |
| 77 | + run: | |
| 78 | + pytest -n 2 -v --cov=cookieKit --cov-report=xml --color=yes cookieKit/tests/ |
| 79 | +
|
| 80 | + - name: codecov |
| 81 | + if: github.repository == 'other/mdakit-Cookie' && github.event_name != 'schedule' |
| 82 | + uses: codecov/codecov-action@v5 |
| 83 | + with: |
| 84 | + file: coverage.xml |
| 85 | + name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} |
| 86 | + verbose: True |
| 87 | + # to upload coverage reports, set a secret called CODECOV_TOKEN |
| 88 | + # in the repository settings |
| 89 | + # (Obtain this from the Codecov website after setting up the repository there) |
| 90 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 91 | + # To fail the CI if there's an error, keep this set to true |
| 92 | + # If repository forks need to run CI, you may need to set this to false |
| 93 | + # Forks can't access the CODECOV_TOKEN secret, |
| 94 | + # and a failed upload registers as an error |
| 95 | + fail_ci_if_error: true |
| 96 | + |
| 97 | + |
| 98 | + pylint_check: |
| 99 | + if: "github.repository == 'other/mdakit-Cookie'" |
| 100 | + runs-on: ubuntu-latest |
| 101 | + |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + |
| 105 | + - name: Set up Python |
| 106 | + uses: actions/setup-python@v5 |
| 107 | + with: |
| 108 | + python-version: "3.12" |
| 109 | + |
| 110 | + - name: Install Pylint |
| 111 | + run: | |
| 112 | + which pip |
| 113 | + which python |
| 114 | + pip install pylint mdanalysis |
| 115 | +
|
| 116 | + - name: Run Pylint |
| 117 | + env: |
| 118 | + PYLINTRC: .pylintrc |
| 119 | + run: | |
| 120 | + pylint . |
| 121 | +
|
| 122 | +
|
| 123 | + pypi_check: |
| 124 | + if: "github.repository == 'other/mdakit-Cookie'" |
| 125 | + runs-on: ubuntu-latest |
| 126 | + |
| 127 | + steps: |
| 128 | + - uses: actions/checkout@v4 |
| 129 | + |
| 130 | + - name: Set up Python |
| 131 | + uses: actions/setup-python@v5 |
| 132 | + with: |
| 133 | + python-version: "3.12" |
| 134 | + |
| 135 | + - name: Install dependencies |
| 136 | + run: | |
| 137 | + pip install pipx twine |
| 138 | +
|
| 139 | + - name: Build package |
| 140 | + run: | |
| 141 | + python -m pipx run build --sdist |
| 142 | +
|
| 143 | + - name: Check package build |
| 144 | + run: | |
| 145 | + DISTRIBUTION=$(ls -t1 dist/mdakit_cookie-*.tar.gz | head -n 1) |
| 146 | + test -n "${DISTRIBUTION}" || { echo "no distribution dist/mdakit-Cookie-*.tar.gz found"; exit 1; } |
| 147 | + echo "twine check $DISTRIBUTION" |
| 148 | + twine check $DISTRIBUTION |
0 commit comments