-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (129 loc) · 3.96 KB
/
ci.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: ci
on:
push:
branches-ignore: [release]
paths:
- "src/**"
- "testdata/**"
- "tests/**"
- "pyproject.toml"
- "setup.py"
- "tox.ini"
- ".github/workflows/ci.yml"
pull_request:
branches: [main]
paths:
- "src/**"
- "testdata/**"
- "tests/**"
- "pyproject.toml"
- "setup.py"
workflow_dispatch:
inputs:
python-version:
required: false
type: string
workflow_call:
inputs:
python-version:
required: false
type: string
event-type:
required: true
type: string
jobs:
setup:
runs-on: ubuntu-latest
outputs:
python-version: ${{ steps.vars.outputs.python-version }}
steps:
- name: Checkout code to determine the minimum supported python version
if: ${{ inputs.python-version == '' }}
uses: actions/checkout@v4
with:
repository: pkgcraft/pkgcraft-python
- name: Set python versions to test against
id: vars
run: |
if [[ -n "${{ inputs.python-version }}" ]]; then
echo "python-version=$(jq 'split(",")' -Rc <(echo '${{ inputs.python-version }}'))" >> $GITHUB_OUTPUT
else
# pull minimum supported python version from pyproject.toml
min_ver=$(sed -rn '/^requires-python\s*=/ s/^.*=\s*">=([0-9]\.[0-9]+).*/\1/p' pyproject.toml)
echo "python-version=['${min_ver}', '3.x']" >> $GITHUB_OUTPUT
fi
test:
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ${{ fromJson(needs.setup.outputs.python-version) }}
steps:
- name: Set pkgcraft dir env var
run: echo pkgcraft_dir=~/pkgcraft >> $GITHUB_ENV
- name: Download pkgcraft-c library from most recent run
if: ${{ inputs.event-type == '' }}
uses: dawidd6/action-download-artifact@v8
with:
github_token: ${{ secrets.PKGCRAFT_CI_TOKEN }}
repo: pkgcraft/pkgcraft
branch: main
workflow: pkgcraft-c.yml
workflow_conclusion: ""
search_artifacts: true
name: pkgcraft-c-${{ runner.os }}
- name: Download pkgcraft-c library from running workflow
if: ${{ inputs.event-type != '' }}
uses: actions/download-artifact@v4
with:
name: pkgcraft-c-${{ runner.os }}
- name: Unpack library
run: |
mkdir -p "${pkgcraft_dir}"
tar -Jxf pkgcraft-c.tar.xz -C "${pkgcraft_dir}"
- name: Checkout code
uses: actions/checkout@v4
with:
repository: pkgcraft/pkgcraft-python
# checkout full history for setuptools-scm
fetch-depth: 0
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'pyproject.toml'
- name: Install dependencies
run: pip install tox
- name: Override build variables
run: |
echo "PKG_CONFIG_PATH=${pkgcraft_dir}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${pkgcraft_dir}" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${pkgcraft_dir}" >> $GITHUB_ENV
- name: Run tests
run: tox -c tox.ini -e coverage
- name: Upload build artifacts
if: ${{ inputs.event-type == '' && matrix.python-version == '3.x' }}
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.xml
if-no-files-found: error
coverage:
if: ${{ inputs.event-type == '' && github.ref_name == 'main' }}
needs: test
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/coverage.xml
fail_ci_if_error: true