blob: 184e527838bec849ade5a9e5123cadd39b6bdc6f [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 Kupietzd95b9472021-05-04 15:58:26 +020027 if: runner.os != 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020028 - name: Set up package maintainers R on Linux
29 run: |
30 sudo apt-get update -y
Marc Kupietzd95b9472021-05-04 15:58:26 +020031 sudo apt-get install -y libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020032 sudo chown $USER /usr/local/lib/R/site-library
33 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020034 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020035 - name: Install R dependencies
36 run: Rscript -e "install.packages('RKorAPClient')"
37 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010038 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020039 with:
40 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020041 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020042 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020043 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010044 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020045 with:
46 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020047 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020048 if: runner.os != 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020049 - name: Install dependencies
50 run: |
51 python -m pip install --upgrade pip
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020052 pip install wheel
Marc Kupietzf84baac2024-01-26 09:20:00 +010053 - name: Install package on Mac and Linux
54 if: runner.os != 'Windows'
Marc Kupietz01f41602020-06-19 20:06:31 +020055 run: |
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020056 pip install .
Marc Kupietzf84baac2024-01-26 09:20:00 +010057 - name: Install package on Windows
58 if: runner.os == 'Windows'
59 run: |
60 pip install rpy2
61 pip install .
62 env:
63 R_HOME: "c:/R"
64 R_USER: "c:/R"
65 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +020066 - name: Test with pytest on POSIX
67 if: runner.os != 'Windows'
68 run: |
69 export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020070 pip install pytest
71 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +020072 - name: Test with pytest on Windows
73 if: runner.os == 'Windows'
74 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +020075 pip install pytest
76 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
77 env:
78 R_HOME: "c:/R"
79 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +020080 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +020081 - name: Build documentation un Linux
82 if: runner.os == 'Linux'
83 run: |
84 pip install pdoc3
85 pdoc KorAPClient --force --html -o build/doc
86 - name: Deploy documentation on Linux
87 if: runner.os == 'Linux'
88 uses: JamesIves/github-pages-deploy-action@releases/v3
89 with:
90 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91 BRANCH: gh-pages # The branch the action should deploy to.
92 FOLDER: build/doc # The folder the action should deploy.
93 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020094 - name: Upload check results
95 if: failure()
Marc Kupietzfaa9f652022-12-22 11:00:55 +010096 uses: actions/upload-artifact@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020097 with:
98 name: pytest-results-${{ matrix.python-version }}
99 path: junit/test-results-${{ matrix.python-version }}.xml
100