blob: 621b90e9abe160643836a399084f371c0f58fba1 [file] [log] [blame]
Marc Kupietz01f41602020-06-19 20:06:31 +02001name: PythonKorAPClient CI unit test
2
3on: [push, pull_request]
4
5jobs:
6 build:
7
8 runs-on: ${{ matrix.os }}
9 strategy:
Marc Kupietz6f2bdae2022-01-20 12:19:23 +010010 max-parallel: 6
Marc Kupietz602833a2020-07-31 12:41:32 +020011 fail-fast: false
Marc Kupietz01f41602020-06-19 20:06:31 +020012 matrix:
Marc Kupietzc6d99102025-01-21 11:46:30 +010013 python-version: ['3.11', '3.12', '3.13']
Marc Kupietzf573f8f2021-10-02 21:46:22 +020014 r-version: [release]
Marc Kupietzda7d6a12024-01-27 19:01:02 +010015 os: [macOS-latest, ubuntu-latest]
Marc Kupietz01f41602020-06-19 20:06:31 +020016 steps:
Marc Kupietzf84baac2024-01-26 09:20:00 +010017 - uses: actions/checkout@v4
Marc Kupietz01f41602020-06-19 20:06:31 +020018 - name: Set up Python ${{ matrix.python-version }}
Marc Kupietzf84baac2024-01-26 09:20:00 +010019 uses: actions/setup-python@v5
Marc Kupietz01f41602020-06-19 20:06:31 +020020 with:
21 python-version: ${{ matrix.python-version }}
Marc Kupietzf84baac2024-01-26 09:20:00 +010022 cache: 'pip' # caching pip dependencies
Marc Kupietz01f41602020-06-19 20:06:31 +020023 - name: Set up R ${{ matrix.r-version }}
Marc Kupietzfaa9f652022-12-22 11:00:55 +010024 uses: r-lib/actions/setup-r@v2
Marc Kupietz01f41602020-06-19 20:06:31 +020025 with:
26 r-version: ${{ matrix.r-version }}
Marc Kupietz1e23bf52024-01-26 11:16:30 +010027 use-public-rspm: true
28 cache-version: 2
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020029 - name: Set up package maintainers R on Linux
30 run: |
31 sudo apt-get update -y
Marc Kupietz1e23bf52024-01-26 11:16:30 +010032 sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietzc6d99102025-01-21 11:46:30 +010033 mkdir -p /usr/local/lib/R/site-library
Marc Kupietz1e23bf52024-01-26 11:16:30 +010034 sudo chown $(whoami) /usr/local/lib/R/site-library
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020035 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020036 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020037 - name: Install R dependencies
38 run: Rscript -e "install.packages('RKorAPClient')"
39 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010040 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020041 with:
42 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020043 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020044 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020045 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010046 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020047 with:
48 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020049 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020050 if: runner.os != 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020051 - name: Install dependencies
52 run: |
53 python -m pip install --upgrade pip
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020054 pip install wheel
Marc Kupietzf84baac2024-01-26 09:20:00 +010055 - name: Install package on Mac and Linux
56 if: runner.os != 'Windows'
Marc Kupietz01f41602020-06-19 20:06:31 +020057 run: |
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020058 pip install .
Marc Kupietzf84baac2024-01-26 09:20:00 +010059 - name: Install package on Windows
60 if: runner.os == 'Windows'
61 run: |
62 pip install rpy2
63 pip install .
64 env:
65 R_HOME: "c:/R"
66 R_USER: "c:/R"
Marc Kupietzccd05aa2024-01-27 12:33:40 +010067 PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +020068 - name: Test with pytest on POSIX
69 if: runner.os != 'Windows'
70 run: |
71 export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020072 pip install pytest
73 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +020074 - name: Test with pytest on Windows
75 if: runner.os == 'Windows'
76 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +020077 pip install pytest
78 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
79 env:
80 R_HOME: "c:/R"
81 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +020082 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +020083 - name: Build documentation un Linux
84 if: runner.os == 'Linux'
85 run: |
86 pip install pdoc3
87 pdoc KorAPClient --force --html -o build/doc
88 - name: Deploy documentation on Linux
89 if: runner.os == 'Linux'
90 uses: JamesIves/github-pages-deploy-action@releases/v3
91 with:
92 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93 BRANCH: gh-pages # The branch the action should deploy to.
94 FOLDER: build/doc # The folder the action should deploy.
95 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020096 - name: Upload check results
97 if: failure()
Marc Kupietzfaa9f652022-12-22 11:00:55 +010098 uses: actions/upload-artifact@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020099 with:
100 name: pytest-results-${{ matrix.python-version }}
101 path: junit/test-results-${{ matrix.python-version }}.xml
102