]> git.k1024.org Git - pyxattr.git/blob - .github/workflows/ci.yml
Restrict permissions for github token
[pyxattr.git] / .github / workflows / ci.yml
1 on:
2   # Trigger the workflow on push or
3   # pull request, but only for the
4   # main branch.
5   push:
6     branches:
7       - main
8   pull_request:
9     branches:
10       - main
11   # Allow manual triggering
12   workflow_dispatch:
13   # Weekly run to account for
14   # changed dependencies.
15   schedule:
16     - cron: '17 03 * * 0'
17
18 name: CI
19
20 permissions:  # added using https://github.com/step-security/secure-repo
21   contents: read
22
23 jobs:
24   build:
25     name: Build and test
26     runs-on: ${{ matrix.os }}
27     strategy:
28       matrix:
29         os: [ubuntu-22.04, macos-12]
30         python-version:
31           - '3.7'
32           - '3.8'
33           - '3.9'
34           - '3.10'
35           - 'pypy-3.7'
36           - 'pypy-3.8'
37           - 'pypy-3.9'
38       fail-fast: false
39
40     steps:
41       - name: Checkout
42         uses: actions/checkout@v2
43
44       - name: Set up Python ${{ matrix.python-version }}
45         uses: actions/setup-python@v2
46         with:
47           python-version: ${{ matrix.python-version }}
48
49       - name: Cache pip
50         uses: actions/cache@v2
51         with:
52           # This path is specific to Ubuntu
53           path: ~/.cache/pip
54           # Look to see if there is a cache hit for the corresponding requirements file
55           key: v2-pip-${{ runner.os }}-${{ matrix.python-version }}
56           restore-keys: |
57             v2-pip-${{ runner.os }}
58             v2-pip-
59
60       - name: Install dependencies
61         run: |
62           pip install pytest
63           pip install sphinx
64           pip install recommonmark
65
66       - name: Build the code
67         run: python ./setup.py build_ext -i
68
69       - name: Run tests
70         run: python -m pytest tests
71
72       - name: Cleanup
73         run: make clean
74
75       - name: Re-build with coverage info
76         run: CFLAGS="-coverage" python ./setup.py build_ext -i
77
78       - name: Test with coverage
79         run: python -m pytest tests
80
81       - name: Upload coverage to Codecov
82         uses: codecov/codecov-action@v3
83         with:
84           #files: ./coverage1.xml,./coverage2.xml
85           #directory: ./coverage/reports/
86           #flags: unittests
87           #env_vars: OS,PYTHON
88           name: codecov-python-${{ matrix.python-version }}
89           #fail_ci_if_error: true
90           #verbose: true
91           gcov: true
92
93       - name: Build documentation
94         run: make doc