blob: 46870221ff4824aaf1a2a0a3bbc52523d69e4085 [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
33 echo "R_LIBRARY=export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
34 - name: Set virtualenv activation command (Windows)
35 if: startsWith(matrix.os, 'windows')
36 shell: bash
37 run: |
38 echo "VENV_ACTIVATE=pyenv_base\Scripts\activate" >> $GITHUB_ENV
39 echo "R_LIBRARY=''" >> $GITHUB_ENV
Marc Kupietz95727062025-04-07 16:55:55 +020040 - name: Patch GHA issue with macos - Missing C library
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020041 if: startsWith(matrix.os, 'macos')
Marc Kupietz95727062025-04-07 16:55:55 +020042 shell: bash
43 run: |
44 LIB_ARCHIVES=(\
45 libdeflate-1.23-darwin.20-arm64.tar.xz \
46 zstd-1.5.5-darwin.20-arm64.tar.xz \
47 )
48 for name in "${LIB_ARCHIVES[@]}"
49 do
50 curl -LO https://mac.r-project.org/bin/darwin20/arm64/"${name}"
51 sudo tar xJf "${name}" -C /
52 done
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020053 - name: Install dependencies
54 run: |
55 python -m pip install --upgrade pip
56 python -m pip install setuptools build
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020057 - name: Set up package maintainers R on Linux
58 run: |
59 sudo apt-get update -y
Marc Kupietz1e23bf52024-01-26 11:16:30 +010060 sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietz66e8d742025-01-21 12:02:05 +010061 sudo mkdir -p /usr/local/lib/R/site-library
Marc Kupietz1e23bf52024-01-26 11:16:30 +010062 sudo chown $(whoami) /usr/local/lib/R/site-library
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020063 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020064 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020065 - name: Install R dependencies
Marc Kupietz95727062025-04-07 16:55:55 +020066 run: |
67 Rscript -e "install.packages('pak')"
68 Rscript -e "pak::pak('RKorAPClient')"
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020069 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010070 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020071 with:
72 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020073 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020074 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020075 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010076 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020077 with:
78 path: ${{ env.R_LIBS_USER }}
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 Kupietz95727062025-04-07 16:55:55 +020081 - name: Install package
Marc Kupietzc5d2c6d2025-04-08 13:23:12 +020082 if: runner.os != 'Windows'
83 run: |
84 pip install rpy2
85 pip install .
86 - name: Install package on Windows
87 if: runner.os == 'Windows'
Marc Kupietzf84baac2024-01-26 09:20:00 +010088 run: |
89 pip install rpy2
90 pip install .
91 env:
92 R_HOME: "c:/R"
93 R_USER: "c:/R"
Marc Kupietzccd05aa2024-01-27 12:33:40 +010094 PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +020095 - name: Test with pytest on POSIX
96 if: runner.os != 'Windows'
97 run: |
98 export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
Marc Kupietz95727062025-04-07 16:55:55 +020099 python -m ensurepip --upgrade
100 python -m pip install pytest
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200101 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +0200102 - name: Test with pytest on Windows
103 if: runner.os == 'Windows'
104 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +0200105 pip install pytest
106 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
107 env:
108 R_HOME: "c:/R"
109 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +0200110 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200111 - name: Build documentation un Linux
112 if: runner.os == 'Linux'
113 run: |
114 pip install pdoc3
115 pdoc KorAPClient --force --html -o build/doc
116 - name: Deploy documentation on Linux
117 if: runner.os == 'Linux'
Marc Kupietz95727062025-04-07 16:55:55 +0200118 uses: JamesIves/github-pages-deploy-action@releases/v4
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200119 with:
120 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121 BRANCH: gh-pages # The branch the action should deploy to.
122 FOLDER: build/doc # The folder the action should deploy.
123 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200124 - name: Upload check results
125 if: failure()
Marc Kupietz95727062025-04-07 16:55:55 +0200126 uses: actions/upload-artifact@v4
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200127 with:
128 name: pytest-results-${{ matrix.python-version }}
129 path: junit/test-results-${{ matrix.python-version }}.xml
130