-
Notifications
You must be signed in to change notification settings - Fork 16
138 lines (115 loc) · 3.56 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
name: CI
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [macos-11, windows-2022, ubuntu-22.04]
python-version: ['3.8', '3.9', '3.10']
name: Test - ${{ matrix.os }}, ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: pip install build
- name: Install wpiformat
run: |
cd wpiformat
python -m build --wheel
pip install dist/*.whl
shell: bash
- name: Install test dependencies
run: pip install tox
- name: Run unit tests
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
cd wpiformat
tox
- name: wpiformat - whole repo
run: |
cd wpiformat
python -m wpiformat -v
- name: wpiformat - one file
run: |
cd wpiformat
python -m wpiformat -f wpiformat/__init__.py -v
- name: wpiformat - absolute path to file
shell: bash
run: |
cd wpiformat
python -m wpiformat -f $GITHUB_WORKSPACE/wpiformat/wpiformat/__init__.py -v
- name: wpiformat - multiple files
run: |
cd wpiformat
python -m wpiformat -f wpiformat/__init__.py wpiformat/__main__.py -v
- name: wpiformat - directory
run: |
cd wpiformat
python -m wpiformat -f wpiformat -v
# Verify wpiformat reports an error if no master or main branch exists
- name: Git repo with no branches
shell: bash
run: |
rm -rf branch-test
mkdir branch-test && cd branch-test && git init
if wpiformat; then
exit 1
fi
# Verify wpiformat reports success if "master" exists
- name: Git repo with master branch
shell: bash
run: |
rm -rf branch-test
mkdir branch-test && cd branch-test && git init
git checkout -b master
touch .wpiformat
git add .wpiformat && git commit -q -m "Initial commit"
wpiformat
# Verify wpiformat reports success if "main" exists
- name: Git repo with main branch
shell: bash
run: |
rm -rf branch-test
mkdir branch-test && cd branch-test && git init
git checkout -b main
touch .wpiformat
git add .wpiformat && git commit -q -m "Initial commit"
wpiformat
- name: Delete branch-test folder
shell: bash
run: rm -rf branch-test
- name: Ensure formatter made no changes
run: git --no-pager diff --exit-code HEAD
publish:
name: Publish
runs-on: ubuntu-latest
needs: [test]
if: ${{ github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python dependencies
run: pip install build
- name: Build package
run: python -m build
working-directory: wpiformat
- name: Upload package to PyPi
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
packages_dir: wpiformat/dist
password: ${{ secrets.PYPI_PASSWORD }}