-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (133 loc) · 5.01 KB
/
Copy pathpythonpackage.yml
File metadata and controls
137 lines (133 loc) · 5.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: PythonKorAPClient CI unit test
on: [push, pull_request]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 6
fail-fast: false
matrix:
python-version: ['3.11', '3.13']
r-version: [release]
os: [macos-15, ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # caching pip dependencies
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}
use-public-rspm: true
- name: Set env commands (Linux)
if: runner.os == 'Linux'
run: |
echo "VENV_ACTIVATE=source pyenv_base/bin/activate" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(dirname $(find / -name libR.so 2> /dev/null)):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
echo "R_LIBRARY=export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: Set env commands (MacOS)
if: "startsWith(matrix.os, 'macos')"
run: |
echo "VENV_ACTIVATE=source pyenv_base/bin/activate" >> $GITHUB_ENV
echo "R_LIBRARY=$(find /Library -name libR.dylib 2> /dev/null | head -1)" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$(dirname $(find /Library -name libR.dylib 2> /dev/null | head -1)):${LD_LIBRARY_PATH}" >> $GITHUB_ENV
- name: Set virtualenv activation command (Windows)
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
echo "VENV_ACTIVATE=pyenv_base\Scripts\activate" >> $GITHUB_ENV
echo "R_LIBRARY=''" >> $GITHUB_ENV
- name: Patch GHA issue with macos - Missing C library
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
LIB_ARCHIVES=(\
libdeflate-1.23-darwin.20-arm64.tar.xz \
zstd-1.5.5-darwin.20-arm64.tar.xz \
)
for name in "${LIB_ARCHIVES[@]}"
do
curl -LO https://mac.r-project.org/bin/darwin20/arm64/"${name}"
sudo tar xJf "${name}" -C /
done
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools build
- name: Set up package maintainers R on Linux
run: |
sudo apt-get update -y
sudo apt-get install -y libglpk-dev libsodium-dev libxml2-dev libcurl4-openssl-dev
sudo mkdir -p /usr/local/lib/R/site-library
sudo chown $(whoami) /usr/local/lib/R/site-library
export R_LIBS_USER=/usr/local/lib/R/site-library
if: runner.os == 'Linux'
- name: Install R dependencies
run: |
Rscript -e "install.packages('pak')"
Rscript -e "pak::pak('RKorAPClient')"
- name: Cache R packages on Linux
uses: actions/cache@v3
with:
path: /usr/local/lib/R/site-library
key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
if: runner.os == 'Linux'
- name: Cache R packages
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r-version }}-${{ hashFiles('DESCRIPTION') }}
if: runner.os != 'Linux'
- name: Install package
if: runner.os != 'Windows'
run: |
pip install rpy2
pip install .
- name: Install package on Windows
if: runner.os == 'Windows'
run: |
pip install rpy2
pip install .
env:
R_HOME: "c:/R"
R_USER: "c:/R"
PATH: "c:/R/bin;c:/R/bin/x64;${{ env.PATH }}"
- name: Test with pytest on POSIX
if: runner.os != 'Windows'
run: |
export LD_LIBRARY_PATH=$(dirname $R_LIBRARY):${LD_LIBRARY_PATH}
echo $LD_LIBRARY_PATH
python -m ensurepip --upgrade
python -m pip install pytest
pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
- name: Test with pytest on Windows
if: runner.os == 'Windows'
run: |
pip install pytest
pytest KorAPClient/tests --junitxml=junit/test-results-${{ matrix.python-version }}.xml
env:
R_HOME: "c:/R"
R_USER: "c:/R"
PATH: "c:/R/bin/x64;${{ env.PATH }}"
- name: Build documentation un Linux
if: runner.os == 'Linux'
run: |
pip install pdoc3
pdoc KorAPClient --force --html -o build/doc
- name: Deploy documentation on Linux
if: runner.os == 'Linux'
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: build/doc # The folder the action should deploy.
TARGET_FOLDER: doc
- name: Upload check results
if: failure()
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml