blob: 86791d83cc7b3e46891d19aa8a14c586a8ce2cc0 [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
Marc Kupietza2965dd2025-04-12 17:22:34 +020028 - name: Set env commands (Linux)
29 if: runner.os == 'Linux'
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020030 run: |
31 echo "VENV_ACTIVATE=source pyenv_base/bin/activate" >> $GITHUB_ENV
Marc Kupietza2965dd2025-04-12 17:22:34 +020032 echo "LD_LIBRARY_PATH=$(dirname $(find / -name libR.so 2> /dev/null)):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020033 echo "R_LIBRARY=export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
Marc Kupietza2965dd2025-04-12 17:22:34 +020034 - name: Set env commands (MacOS)
35 if: "startsWith(matrix.os, 'macos')"
36 run: |
37 echo "VENV_ACTIVATE=source pyenv_base/bin/activate" >> $GITHUB_ENV
38 echo "R_LIBRARY=$(find /Library -name libR.dylib 2> /dev/null | head -1)" >> $GITHUB_ENV
39 echo "LD_LIBRARY_PATH=$(dirname $(find /Library -name libR.dylib 2> /dev/null | head -1)):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020040 - name: Set virtualenv activation command (Windows)
41 if: startsWith(matrix.os, 'windows')
42 shell: bash
43 run: |
44 echo "VENV_ACTIVATE=pyenv_base\Scripts\activate" >> $GITHUB_ENV
45 echo "R_LIBRARY=''" >> $GITHUB_ENV
Marc Kupietz95727062025-04-07 16:55:55 +020046 - name: Patch GHA issue with macos - Missing C library
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020047 if: startsWith(matrix.os, 'macos')
Marc Kupietz95727062025-04-07 16:55:55 +020048 shell: bash
49 run: |
50 LIB_ARCHIVES=(\
51 libdeflate-1.23-darwin.20-arm64.tar.xz \
52 zstd-1.5.5-darwin.20-arm64.tar.xz \
53 )
54 for name in "${LIB_ARCHIVES[@]}"
55 do
56 curl -LO https://mac.r-project.org/bin/darwin20/arm64/"${name}"
57 sudo tar xJf "${name}" -C /
58 done
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020059 - name: Install dependencies
60 run: |
61 python -m pip install --upgrade pip
62 python -m pip install setuptools build
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020063 - name: Set up package maintainers R on Linux
64 run: |
65 sudo apt-get update -y
Marc Kupietz1e23bf52024-01-26 11:16:30 +010066 sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietz66e8d742025-01-21 12:02:05 +010067 sudo mkdir -p /usr/local/lib/R/site-library
Marc Kupietz1e23bf52024-01-26 11:16:30 +010068 sudo chown $(whoami) /usr/local/lib/R/site-library
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020069 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020070 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020071 - name: Install R dependencies
Marc Kupietz95727062025-04-07 16:55:55 +020072 run: |
73 Rscript -e "install.packages('pak')"
74 Rscript -e "pak::pak('RKorAPClient')"
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020075 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010076 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020077 with:
78 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020079 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020080 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020081 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010082 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020083 with:
84 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020085 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020086 if: runner.os != 'Linux'
Marc Kupietz95727062025-04-07 16:55:55 +020087 - name: Install package
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020088 if: runner.os != 'Windows'
89 run: |
90 pip install rpy2
91 pip install .
92 - name: Install package on Windows
93 if: runner.os == 'Windows'
Marc Kupietzf84baac2024-01-26 09:20:00 +010094 run: |
95 pip install rpy2
96 pip install .
97 env:
98 R_HOME: "c:/R"
99 R_USER: "c:/R"
Marc Kupietzccd05aa2024-01-27 12:33:40 +0100100 PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +0200101 - name: Test with pytest on POSIX
102 if: runner.os != 'Windows'
103 run: |
Marc Kupietza2965dd2025-04-12 17:22:34 +0200104 export LD_LIBRARY_PATH=$(dirname $R_LIBRARY):${LD_LIBRARY_PATH}
105 echo $LD_LIBRARY_PATH
Marc Kupietz95727062025-04-07 16:55:55 +0200106 python -m ensurepip --upgrade
107 python -m pip install pytest
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200108 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +0200109 - name: Test with pytest on Windows
110 if: runner.os == 'Windows'
111 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +0200112 pip install pytest
113 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
114 env:
115 R_HOME: "c:/R"
116 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +0200117 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200118 - name: Build documentation un Linux
119 if: runner.os == 'Linux'
120 run: |
121 pip install pdoc3
122 pdoc KorAPClient --force --html -o build/doc
123 - name: Deploy documentation on Linux
124 if: runner.os == 'Linux'
Marc Kupietz95727062025-04-07 16:55:55 +0200125 uses: JamesIves/github-pages-deploy-action@releases/v4
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200126 with:
127 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128 BRANCH: gh-pages # The branch the action should deploy to.
129 FOLDER: build/doc # The folder the action should deploy.
130 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200131 - name: Upload check results
132 if: failure()
Marc Kupietz95727062025-04-07 16:55:55 +0200133 uses: actions/upload-artifact@v4
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200134 with:
135 name: pytest-results-${{ matrix.python-version }}
136 path: junit/test-results-${{ matrix.python-version }}.xml
137