blob: bd4776fa81e031d912e136cbb9edfa4a42bbde02 [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 Kupietzf84baac2024-01-26 09:20:00 +010013 python-version: ['3.9', '3.11', '3.12']
Marc Kupietzf573f8f2021-10-02 21:46:22 +020014 r-version: [release]
Marc Kupietzcdeea612021-05-04 13:33:27 +020015 os: [windows-latest, 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
33 sudo chown $(whoami) /usr/local/lib/R/site-library
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020034 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020035 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020036 - name: Install R dependencies
37 run: Rscript -e "install.packages('RKorAPClient')"
38 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010039 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020040 with:
41 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020042 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020043 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020044 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010045 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020046 with:
47 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020048 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020049 if: runner.os != 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020050 - name: Install dependencies
51 run: |
52 python -m pip install --upgrade pip
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020053 pip install wheel
Marc Kupietzf84baac2024-01-26 09:20:00 +010054 - name: Install package on Mac and Linux
55 if: runner.os != 'Windows'
Marc Kupietz01f41602020-06-19 20:06:31 +020056 run: |
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020057 pip install .
Marc Kupietzf84baac2024-01-26 09:20:00 +010058 - 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 Kupietzccd05aa2024-01-27 12:33:40 +010066 PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +020067 - 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 Kupietz1e0d3cd2020-06-19 23:38:13 +020071 pip install pytest
72 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +020073 - name: Test with pytest on Windows
74 if: runner.os == 'Windows'
75 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +020076 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 Kupietze8ca49f2020-06-24 14:45:10 +020081 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +020082 - 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 Kupietz1e0d3cd2020-06-19 23:38:13 +020095 - name: Upload check results
96 if: failure()
Marc Kupietzfaa9f652022-12-22 11:00:55 +010097 uses: actions/upload-artifact@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020098 with:
99 name: pytest-results-${{ matrix.python-version }}
100 path: junit/test-results-${{ matrix.python-version }}.xml
101