-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (102 loc) · 3.84 KB
/
build-python.yml
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
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow
# https://docs.github.com/fr/actions/using-workflows/workflow-syntax-for-github-actions#exemple--inclusion-de-chemins-dacc%C3%A8s
name: Full CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# Concurrency : auto-cancel "old" jobs ie when pushing again
# https://docs.github.com/fr/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build-python:
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Do not stop when any job fails
matrix:
python-version: ["3.10", "3.11"]
os: [ubuntu-latest]
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
continue-on-error: false # https://ncorti.com/blog/howto-github-actions-build-matrix
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Check disk space
run: |
df -h
- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo rm -rf /usr/local/lib/android
docker rmi $(docker image ls -aq)
sudo apt update && sudo apt remove -y \
google-cloud-cli microsoft-edge-stable dotnet-sdk-* llvm-* google-chrome-stable temurin-*
sudo apt autoremove -y
sudo apt autoclean -y
- name: Check new disk space
run: |
df -h
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: false # Removing cache, as it's not worth for now (around 3min to restore + time to save vs 3 min to clean install)
- name: Install dependencies
run: pdm install -G :all
- name: Ensure opencv contrib is working
run: |
pdm run pip uninstall -y opencv-contrib-python
pdm run pip install opencv-contrib-python
- name: Ensure torch is installed correctly on gh runner
run: |
pdm run pip install -U torch==2.1.0+cu121 torchvision==0.16.0+cu121 --index-url https://download.pytorch.org/whl/cu121
- name: Verify linting, format
run: pdm check-format
- name: Cache test resources
uses: actions/cache@v3
if: ${{ github.event_name == 'pull_request' }}
with:
path: ~/.giskard
key: ${{ matrix.os }}-python-${{ matrix.python-version }}-test-resources # TODO: Separate fixtures and for hashing
restore-keys: ${{ matrix.os }}-python-${{ matrix.python-version }}-test-resources
- name: Test code
run: pdm test
- name: Test notebooks
run: pdm check-notebook
- name: Build
run: pdm build
- name: "Python client: archive built artifacts"
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
uses: actions/upload-artifact@v3
with:
path: dist/*whl
install-pip:
name: "Check if wheel can be installed with pip"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: "3.10"
cache: false
- name: Build wheel
run: pdm build
- name: Create new project, install wheel and import (Pip)
run: |
python -m venv .venv-test-pip
source .venv-test-pip/bin/activate
python -m pip install "$(ls ./dist/*.whl)"
python -c "import giskard_vision"