blob: 19d2e91de1b982f266d54103cbf5bbfc083b838c [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 Kupietz95727062025-04-07 16:55:55 +020013 python-version: ['3.11', '3.13']
Marc Kupietzf573f8f2021-10-02 21:46:22 +020014 r-version: [release]
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020015 os: [macos-15, 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 Kupietzc5d2c6d2025-04-08 13:23:12 +020029 - name: Set env commands (POSIX)
30 if: "!startsWith(matrix.os, 'windows')"
31 run: |
32 echo "VENV_ACTIVATE=source pyenv_base/bin/activate" >> $GITHUB_ENV
Marc Kupietzc015f742025-04-12 17:12:23 +020033 echo "LD_LIBRARY_PATH=$(dirname $(find / -name libR.so)):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020034 echo "R_LIBRARY=export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
35 - name: Set virtualenv activation command (Windows)
36 if: startsWith(matrix.os, 'windows')
37 shell: bash
38 run: |
39 echo "VENV_ACTIVATE=pyenv_base\Scripts\activate" >> $GITHUB_ENV
40 echo "R_LIBRARY=''" >> $GITHUB_ENV
Marc Kupietz95727062025-04-07 16:55:55 +020041 - name: Patch GHA issue with macos - Missing C library
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020042 if: startsWith(matrix.os, 'macos')
Marc Kupietz95727062025-04-07 16:55:55 +020043 shell: bash
44 run: |
45 LIB_ARCHIVES=(\
46 libdeflate-1.23-darwin.20-arm64.tar.xz \
47 zstd-1.5.5-darwin.20-arm64.tar.xz \
48 )
49 for name in "${LIB_ARCHIVES[@]}"
50 do
51 curl -LO https://mac.r-project.org/bin/darwin20/arm64/"${name}"
52 sudo tar xJf "${name}" -C /
53 done
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020054 - name: Install dependencies
55 run: |
56 python -m pip install --upgrade pip
57 python -m pip install setuptools build
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020058 - name: Set up package maintainers R on Linux
59 run: |
60 sudo apt-get update -y
Marc Kupietz1e23bf52024-01-26 11:16:30 +010061 sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietz66e8d742025-01-21 12:02:05 +010062 sudo mkdir -p /usr/local/lib/R/site-library
Marc Kupietz1e23bf52024-01-26 11:16:30 +010063 sudo chown $(whoami) /usr/local/lib/R/site-library
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020064 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020065 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020066 - name: Install R dependencies
Marc Kupietz95727062025-04-07 16:55:55 +020067 run: |
68 Rscript -e "install.packages('pak')"
69 Rscript -e "pak::pak('RKorAPClient')"
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020070 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010071 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020072 with:
73 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020074 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020075 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020076 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010077 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020078 with:
79 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020080 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020081 if: runner.os != 'Linux'
Marc Kupietz95727062025-04-07 16:55:55 +020082 - name: Install package
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020083 if: runner.os != 'Windows'
84 run: |
85 pip install rpy2
86 pip install .
87 - name: Install package on Windows
88 if: runner.os == 'Windows'
Marc Kupietzf84baac2024-01-26 09:20:00 +010089 run: |
90 pip install rpy2
91 pip install .
92 env:
93 R_HOME: "c:/R"
94 R_USER: "c:/R"
Marc Kupietzccd05aa2024-01-27 12:33:40 +010095 PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +020096 - name: Test with pytest on POSIX
97 if: runner.os != 'Windows'
98 run: |
99 export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
Marc Kupietz95727062025-04-07 16:55:55 +0200100 python -m ensurepip --upgrade
101 python -m pip install pytest
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200102 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +0200103 - name: Test with pytest on Windows
104 if: runner.os == 'Windows'
105 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +0200106 pip install pytest
107 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
108 env:
109 R_HOME: "c:/R"
110 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +0200111 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200112 - name: Build documentation un Linux
113 if: runner.os == 'Linux'
114 run: |
115 pip install pdoc3
116 pdoc KorAPClient --force --html -o build/doc
117 - name: Deploy documentation on Linux
118 if: runner.os == 'Linux'
Marc Kupietz95727062025-04-07 16:55:55 +0200119 uses: JamesIves/github-pages-deploy-action@releases/v4
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200120 with:
121 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122 BRANCH: gh-pages # The branch the action should deploy to.
123 FOLDER: build/doc # The folder the action should deploy.
124 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200125 - name: Upload check results
126 if: failure()
Marc Kupietz95727062025-04-07 16:55:55 +0200127 uses: actions/upload-artifact@v4
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200128 with:
129 name: pytest-results-${{ matrix.python-version }}
130 path: junit/test-results-${{ matrix.python-version }}.xml
131