forked from wpilibsuite/styleguide
-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (129 loc) · 4.17 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
148
149
150
151
152
name: CI
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: [3.6, 3.7, 3.8]
name: Test - ${{ matrix.os }}, ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Install clang-format
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get install clang-format-10
elif [ "$RUNNER_OS" == "Windows" ]; then
choco install --allow-downgrade llvm --version 10.0.0
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install clang-format
else
echo "$RUNNER_OS not supported"
exit 1
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install wpiformat
run: |
cd wpiformat
pip install -e .
- name: Install test dependencies
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
# This pytest dependency is installed manually with bash because the
# installation prints to stderr. Prints to stderr cause Powershell to
# report a nonzero return code and cause the tests to fail.
pip install wheel iniconfig
fi
- name: Run unit tests
run: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
cd wpiformat
python setup.py test
- name: wpiformat - whole repo
run: |
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: |
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 .styleguide
git add .styleguide && 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 .styleguide
git add .styleguide && 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@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install Python dependencies
run: pip install wheel
- name: Build package
run: python setup.py bdist_wheel
working-directory: wpiformat
- name: Upload package to PyPi
uses: pypa/[email protected]
with:
packages_dir: wpiformat/dist
password: ${{ secrets.PYPI_PASSWORD }}