blob: 8efae9e9487f34e81d764f1a97d872dbb8091844 [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 Kupietzda7d6a12024-01-27 19:01:02 +010015 os: [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 Kupietz1e23bf52024-01-26 11:16:30 +010027 use-public-rspm: true
28 cache-version: 2
Marc Kupietz95727062025-04-07 16:55:55 +020029 - name: Patch GHA issue with macos - Missing C library
30 shell: bash
31 run: |
32 LIB_ARCHIVES=(\
33 libdeflate-1.23-darwin.20-arm64.tar.xz \
34 zstd-1.5.5-darwin.20-arm64.tar.xz \
35 )
36 for name in "${LIB_ARCHIVES[@]}"
37 do
38 curl -LO https://mac.r-project.org/bin/darwin20/arm64/"${name}"
39 sudo tar xJf "${name}" -C /
40 done
41 if: runner.os == 'macOS'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020042 - name: Set up package maintainers R on Linux
43 run: |
44 sudo apt-get update -y
Marc Kupietz1e23bf52024-01-26 11:16:30 +010045 sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev
Marc Kupietz66e8d742025-01-21 12:02:05 +010046 sudo mkdir -p /usr/local/lib/R/site-library
Marc Kupietz1e23bf52024-01-26 11:16:30 +010047 sudo chown $(whoami) /usr/local/lib/R/site-library
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020048 export R_LIBS_USER=/usr/local/lib/R/site-library
Marc Kupietzd95b9472021-05-04 15:58:26 +020049 if: runner.os == 'Linux'
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020050 - name: Install R dependencies
Marc Kupietz95727062025-04-07 16:55:55 +020051 run: |
52 Rscript -e "install.packages('pak')"
53 Rscript -e "pak::pak('RKorAPClient')"
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020054 - name: Cache R packages on Linux
Marc Kupietzfaa9f652022-12-22 11:00:55 +010055 uses: actions/cache@v3
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020056 with:
57 path: /usr/local/lib/R/site-library
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020058 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020059 if: runner.os == 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020060 - name: Cache R packages
Marc Kupietzfaa9f652022-12-22 11:00:55 +010061 uses: actions/cache@v3
Marc Kupietz01f41602020-06-19 20:06:31 +020062 with:
63 path: ${{ env.R_LIBS_USER }}
Marc Kupietz3cb8eba2020-06-20 15:36:47 +020064 key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020065 if: runner.os != 'Linux'
Marc Kupietz01f41602020-06-19 20:06:31 +020066 - name: Install dependencies
67 run: |
68 python -m pip install --upgrade pip
Marc Kupietz95727062025-04-07 16:55:55 +020069 pip install deflate wheel
70 - name: Install package
Marc Kupietzf84baac2024-01-26 09:20:00 +010071 run: |
72 pip install rpy2
73 pip install .
74 env:
75 R_HOME: "c:/R"
76 R_USER: "c:/R"
Marc Kupietzccd05aa2024-01-27 12:33:40 +010077 PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietz01f41602020-06-19 20:06:31 +020078 - name: Test with pytest on POSIX
79 if: runner.os != 'Windows'
80 run: |
81 export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
Marc Kupietz95727062025-04-07 16:55:55 +020082 python -m ensurepip --upgrade
83 python -m pip install pytest
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +020084 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
Marc Kupietz01f41602020-06-19 20:06:31 +020085 - name: Test with pytest on Windows
86 if: runner.os == 'Windows'
87 run: |
Marc Kupietz6fc4b2a2020-06-20 17:31:24 +020088 pip install pytest
89 pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
90 env:
91 R_HOME: "c:/R"
92 R_USER: "c:/R"
Marc Kupietze8ca49f2020-06-24 14:45:10 +020093 PATH: "c:/R/bin/x64;${{ env.PATH }}"
Marc Kupietzcafdbb72020-06-27 18:54:46 +020094 - name: Build documentation un Linux
95 if: runner.os == 'Linux'
96 run: |
97 pip install pdoc3
98 pdoc KorAPClient --force --html -o build/doc
99 - name: Deploy documentation on Linux
100 if: runner.os == 'Linux'
Marc Kupietz95727062025-04-07 16:55:55 +0200101 uses: JamesIves/github-pages-deploy-action@releases/v4
Marc Kupietzcafdbb72020-06-27 18:54:46 +0200102 with:
103 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104 BRANCH: gh-pages # The branch the action should deploy to.
105 FOLDER: build/doc # The folder the action should deploy.
106 TARGET_FOLDER: doc
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200107 - name: Upload check results
108 if: failure()
Marc Kupietz95727062025-04-07 16:55:55 +0200109 uses: actions/upload-artifact@v4
Marc Kupietz1e0d3cd2020-06-19 23:38:13 +0200110 with:
111 name: pytest-results-${{ matrix.python-version }}
112 path: junit/test-results-${{ matrix.python-version }}.xml
113