Skip to content

Commit 166ee7f

Browse files
authored
Conda package CI pipeline on GitHub Actions (#515)
1 parent 50979ea commit 166ee7f

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

.github/workflows/conda-package.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Conda package
2+
3+
on: push
4+
5+
env:
6+
PACKAGE_NAME: dpctl
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set pkgs_dirs
17+
run: |
18+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
19+
- name: Cache conda packages
20+
uses: actions/cache@v2
21+
env:
22+
CACHE_NUMBER: 0 # Increase to reset cache
23+
with:
24+
path: ~/.conda/pkgs
25+
key:
26+
${{ runner.os }}-conda-build-${{ env.CACHE_NUMBER }}-${{hashFiles('**/meta.yaml') }}
27+
28+
- name: Add conda to system path
29+
run: echo $CONDA/bin >> $GITHUB_PATH
30+
- name: Install conda-build
31+
run: conda install conda-build
32+
- name: Build conda package
33+
run: |
34+
CHANNELS="-c intel -c defaults --override-channels"
35+
VERSIONS="--python 3.8"
36+
TEST="--no-test"
37+
38+
conda build \
39+
$TEST \
40+
$VERSIONS \
41+
$CHANNELS \
42+
conda-recipe
43+
- name: Upload artifact
44+
uses: actions/upload-artifact@v2
45+
with:
46+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }}
47+
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2
48+
49+
test:
50+
needs: build
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Download artifact
54+
uses: actions/download-artifact@v2
55+
with:
56+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }}
57+
- name: Add conda to system path
58+
run: echo $CONDA/bin >> $GITHUB_PATH
59+
- name: Install conda-build
60+
run: conda install conda-build
61+
- name: Create conda channel
62+
run: |
63+
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
64+
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64
65+
conda index $GITHUB_WORKSPACE/channel
66+
# Test channel
67+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
68+
- name: Collect dependencies
69+
run: |
70+
CHANNELS="-c $GITHUB_WORKSPACE/channel -c intel -c defaults --override-channels"
71+
conda install $PACKAGE_NAME $CHANNELS --only-deps --dry-run > lockfile
72+
- name: Set pkgs_dirs
73+
run: |
74+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
75+
- name: Cache conda packages
76+
uses: actions/cache@v2
77+
env:
78+
CACHE_NUMBER: 0 # Increase to reset cache
79+
with:
80+
path: ~/.conda/pkgs
81+
key:
82+
${{ runner.os }}-conda-test-${{ env.CACHE_NUMBER }}-${{hashFiles('lockfile') }}
83+
- name: Install ${{ env.PACKAGE_NAME }}
84+
run: |
85+
CHANNELS="-c $GITHUB_WORKSPACE/channel -c intel -c defaults --override-channels"
86+
conda install $PACKAGE_NAME pytest $CHANNELS
87+
# Test installed packages
88+
conda list
89+
- name: Run tests
90+
run: |
91+
# echo "libintelocl.so" | tee /etc/OpenCL/vendors/intel-cpu.icd
92+
export OCL_ICD_FILENAMES=libintelocl.so
93+
python -m pytest --pyargs $PACKAGE_NAME
94+
95+
upload:
96+
needs: test
97+
if: ${{ github.ref == 'refs/heads/main' }}
98+
runs-on: ubuntu-latest
99+
steps:
100+
- name: Download artifact
101+
uses: actions/download-artifact@v2
102+
with:
103+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }}
104+
105+
- name: Install anaconda-client
106+
run: conda install anaconda-client
107+
- name: Add conda to system path
108+
run: echo $CONDA/bin >> $GITHUB_PATH
109+
110+
- name: Upload
111+
env:
112+
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
113+
run: |
114+
conda install anaconda-client
115+
anaconda --token $ANACONDA_TOKEN upload --user dppy --label dev ${PACKAGE_NAME}-*.tar.bz2

0 commit comments

Comments
 (0)