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