blob: 85bc282c295fe688065c186b4e5020576ffcebc9 [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 Kupietz1e7ac302022-12-22 11:00:22 +010013 python-version: ['3.9', '3.10', '3.11']
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 Kupietzfaa9f652022-12-22 11:00:55 +010017 - uses: actions/checkout@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020018 - name: Set up Python ${{ matrix.python-version }}
Marc Kupietzfaa9f652022-12-22 11:00:55 +010019 uses: actions/setup-python@v4
Marc Kupietz01f41602020-06-19 20:06:31 +020020 with:
21 python-version: ${{ matrix.python-version }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020022 - name: Cache pip
Marc Kupietzfaa9f652022-12-22 11:00:55 +010023 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020024 with:
25 # This path is specific to Ubuntu
26 path: ~/.cache/pip
27 # Look to see if there is a cache hit for the corresponding requirements file
28 key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
29 restore-keys: |
30 ${{ runner.os }}-pip-
31 ${{ runner.os }}-
Marc Kupietz01f41602020-06-19 20:06:31 +020032 - name: Set up R ${{ matrix.r-version }}
Marc Kupietzfaa9f652022-12-22 11:00:55 +010033 uses: r-lib/actions/setup-r@v2
Marc Kupietz01f41602020-06-19 20:06:31 +020034 with:
35 r-version: ${{ matrix.r-version }}
Marc Kupietzd95b9472021-05-04 15:58:26 +020036 if: runner.os != 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020037 - name: Set up package maintainers R on Linux
38 run: |
39 sudo apt-get update -y
Marc Kupietzd95b9472021-05-04 15:58:26 +020040 sudo apt-get install -y libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020041 sudo chown $USER /usr/local/lib/R/site-library
42 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020043 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020044 - name: Install R dependencies
45 run: Rscript -e "install.packages('RKorAPClient')"
46 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010047 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020048 with:
49 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020050 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020051 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020052 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010053 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020054 with:
55 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020056 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020057 if: runner.os != 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020058 - name: Install dependencies
59 run: |
60 python -m pip install --upgrade pip
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020061 pip install wheel
Marc Kupietz01f41602020-06-19 20:06:31 +020062 - name: Install package
63 run: |
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020064 pip install .
Marc Kupietz01f41602020-06-19 20:06:31 +020065 - name: Test with pytest on POSIX
66 if: runner.os != 'Windows'
67 run: |
68 export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020069 pip install pytest
70 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +020071 - name: Test with pytest on Windows
72 if: runner.os == 'Windows'
73 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +020074 pip install pytest
75 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
76 env:
77 R_HOME: "c:/R"
78 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +020079 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +020080 - name: Build documentation un Linux
81 if: runner.os == 'Linux'
82 run: |
83 pip install pdoc3
84 pdoc KorAPClient --force --html -o build/doc
85 - name: Deploy documentation on Linux
86 if: runner.os == 'Linux'
87 uses: JamesIves/github-pages-deploy-action@releases/v3
88 with:
89 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90 BRANCH: gh-pages # The branch the action should deploy to.
91 FOLDER: build/doc # The folder the action should deploy.
92 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020093 - name: Upload check results
94 if: failure()
Marc Kupietzfaa9f652022-12-22 11:00:55 +010095 uses: actions/upload-artifact@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020096 with:
97 name: pytest-results-${{ matrix.python-version }}
98 path: junit/test-results-${{ matrix.python-version }}.xml
99