Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 1 | name: PythonKorAPClient CI unit test |
| 2 | |
| 3 | on: [push, pull_request] |
| 4 | |
| 5 | jobs: |
| 6 | build: |
| 7 | |
| 8 | runs-on: ${{ matrix.os }} |
| 9 | strategy: |
Marc Kupietz | 6f2bdae | 2022-01-20 12:19:23 +0100 | [diff] [blame] | 10 | max-parallel: 6 |
Marc Kupietz | 602833a | 2020-07-31 12:41:32 +0200 | [diff] [blame] | 11 | fail-fast: false |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 12 | matrix: |
Marc Kupietz | f84baac | 2024-01-26 09:20:00 +0100 | [diff] [blame] | 13 | python-version: ['3.9', '3.11', '3.12'] |
Marc Kupietz | f573f8f | 2021-10-02 21:46:22 +0200 | [diff] [blame] | 14 | r-version: [release] |
Marc Kupietz | da7d6a1 | 2024-01-27 19:01:02 +0100 | [diff] [blame^] | 15 | os: [macOS-latest, ubuntu-latest] |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 16 | steps: |
Marc Kupietz | f84baac | 2024-01-26 09:20:00 +0100 | [diff] [blame] | 17 | - uses: actions/checkout@v4 |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 18 | - name: Set up Python ${{ matrix.python-version }} |
Marc Kupietz | f84baac | 2024-01-26 09:20:00 +0100 | [diff] [blame] | 19 | uses: actions/setup-python@v5 |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 20 | with: |
| 21 | python-version: ${{ matrix.python-version }} |
Marc Kupietz | f84baac | 2024-01-26 09:20:00 +0100 | [diff] [blame] | 22 | cache: 'pip' # caching pip dependencies |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 23 | - name: Set up R ${{ matrix.r-version }} |
Marc Kupietz | faa9f65 | 2022-12-22 11:00:55 +0100 | [diff] [blame] | 24 | uses: r-lib/actions/setup-r@v2 |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 25 | with: |
| 26 | r-version: ${{ matrix.r-version }} |
Marc Kupietz | 1e23bf5 | 2024-01-26 11:16:30 +0100 | [diff] [blame] | 27 | use-public-rspm: true |
| 28 | cache-version: 2 |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 29 | - name: Set up package maintainers R on Linux |
| 30 | run: | |
| 31 | sudo apt-get update -y |
Marc Kupietz | 1e23bf5 | 2024-01-26 11:16:30 +0100 | [diff] [blame] | 32 | sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev |
| 33 | sudo chown $(whoami) /usr/local/lib/R/site-library |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 34 | export R_LIBS_USER=/usr/local/lib/R/site-library |
Marc Kupietz | d95b947 | 2021-05-04 15:58:26 +0200 | [diff] [blame] | 35 | if: runner.os == 'Linux' |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 36 | - name: Install R dependencies |
| 37 | run: Rscript -e "install.packages('RKorAPClient')" |
| 38 | - name: Cache R packages on Linux |
Marc Kupietz | faa9f65 | 2022-12-22 11:00:55 +0100 | [diff] [blame] | 39 | uses: actions/cache@v3 |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 40 | with: |
| 41 | path: /usr/local/lib/R/site-library |
Marc Kupietz | 3cb8eba | 2020-06-20 15:36:47 +0200 | [diff] [blame] | 42 | key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }} |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 43 | if: runner.os == 'Linux' |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 44 | - name: Cache R packages |
Marc Kupietz | faa9f65 | 2022-12-22 11:00:55 +0100 | [diff] [blame] | 45 | uses: actions/cache@v3 |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 46 | with: |
| 47 | path: ${{ env.R_LIBS_USER }} |
Marc Kupietz | 3cb8eba | 2020-06-20 15:36:47 +0200 | [diff] [blame] | 48 | key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }} |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 49 | if: runner.os != 'Linux' |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 50 | - name: Install dependencies |
| 51 | run: | |
| 52 | python -m pip install --upgrade pip |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 53 | pip install wheel |
Marc Kupietz | f84baac | 2024-01-26 09:20:00 +0100 | [diff] [blame] | 54 | - name: Install package on Mac and Linux |
| 55 | if: runner.os != 'Windows' |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 56 | run: | |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 57 | pip install . |
Marc Kupietz | f84baac | 2024-01-26 09:20:00 +0100 | [diff] [blame] | 58 | - name: Install package on Windows |
| 59 | if: runner.os == 'Windows' |
| 60 | run: | |
| 61 | pip install rpy2 |
| 62 | pip install . |
| 63 | env: |
| 64 | R_HOME: "c:/R" |
| 65 | R_USER: "c:/R" |
Marc Kupietz | ccd05aa | 2024-01-27 12:33:40 +0100 | [diff] [blame] | 66 | PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}" |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 67 | - name: Test with pytest on POSIX |
| 68 | if: runner.os != 'Windows' |
| 69 | run: | |
| 70 | export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH} |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 71 | pip install pytest |
| 72 | pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml |
Marc Kupietz | 01f4160 | 2020-06-19 20:06:31 +0200 | [diff] [blame] | 73 | - name: Test with pytest on Windows |
| 74 | if: runner.os == 'Windows' |
| 75 | run: | |
Marc Kupietz | 6fc4b2a | 2020-06-20 17:31:24 +0200 | [diff] [blame] | 76 | pip install pytest |
| 77 | pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml |
| 78 | env: |
| 79 | R_HOME: "c:/R" |
| 80 | R_USER: "c:/R" |
Marc Kupietz | e8ca49f | 2020-06-24 14:45:10 +0200 | [diff] [blame] | 81 | PATH: "c:/R/bin/x64;${{ env.PATH }}" |
Marc Kupietz | cafdbb7 | 2020-06-27 18:54:46 +0200 | [diff] [blame] | 82 | - name: Build documentation un Linux |
| 83 | if: runner.os == 'Linux' |
| 84 | run: | |
| 85 | pip install pdoc3 |
| 86 | pdoc KorAPClient --force --html -o build/doc |
| 87 | - name: Deploy documentation on Linux |
| 88 | if: runner.os == 'Linux' |
| 89 | uses: JamesIves/github-pages-deploy-action@releases/v3 |
| 90 | with: |
| 91 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | BRANCH: gh-pages # The branch the action should deploy to. |
| 93 | FOLDER: build/doc # The folder the action should deploy. |
| 94 | TARGET_FOLDER: doc |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 95 | - name: Upload check results |
| 96 | if: failure() |
Marc Kupietz | faa9f65 | 2022-12-22 11:00:55 +0100 | [diff] [blame] | 97 | uses: actions/upload-artifact@v3 |
Marc Kupietz | 1e0d3cd | 2020-06-19 23:38:13 +0200 | [diff] [blame] | 98 | with: |
| 99 | name: pytest-results-${{ matrix.python-version }} |
| 100 | path: junit/test-results-${{ matrix.python-version }}.xml |
| 101 | |