Skip to content

Commit f38b743

Browse files
Set up GitHub Actions
Co-authored-by: Austin Shalit <[email protected]>
1 parent 203f02e commit f38b743

File tree

3 files changed

+104
-114
lines changed

3 files changed

+104
-114
lines changed

.github/workflows/ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os: [macos-latest, windows-latest, ubuntu-latest]
11+
python-version: [3.6, 3.7, 3.8]
12+
name: Test - ${{ matrix.os }}, ${{ matrix.python-version }}
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Fetch all history and metadata
18+
run: |
19+
git fetch --prune --unshallow
20+
git checkout -b pr
21+
git branch -f master origin/master
22+
23+
- name: Install clang-format
24+
shell: bash
25+
run: |
26+
if [ "$RUNNER_OS" == "Linux" ]; then
27+
sudo apt-get install clang-format-10
28+
elif [ "$RUNNER_OS" == "Windows" ]; then
29+
choco install llvm --version 10.0.0
30+
elif [ "$RUNNER_OS" == "macOS" ]; then
31+
brew install clang-format
32+
else
33+
echo "$RUNNER_OS not supported"
34+
exit 1
35+
fi
36+
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install wpiformat
43+
run: |
44+
cd wpiformat
45+
pip install -e .
46+
47+
- name: Install test dependencies
48+
shell: bash
49+
run: |
50+
if [ "$RUNNER_OS" == "Windows" ]; then
51+
# This pytest dependency is installed manually with bash because the
52+
# installation prints to stderr. Prints to stderr cause Powershell to
53+
# report a nonzero return code and cause the tests to fail.
54+
pip install wheel iniconfig
55+
fi
56+
57+
- name: Run unit tests
58+
run: |
59+
git config --global user.email "[email protected]"
60+
git config --global user.name "Your Name"
61+
cd wpiformat
62+
python setup.py test
63+
64+
- name: wpiformat - whole repo
65+
run: |
66+
python -m wpiformat -v
67+
68+
- name: wpiformat - one file
69+
run: |
70+
cd wpiformat
71+
python -m wpiformat -f wpiformat/__init__.py -v
72+
73+
- name: wpiformat - absolute path to file
74+
shell: bash
75+
run: |
76+
if [ "$RUNNER_OS" == "Linux" ]; then
77+
python -m wpiformat -f /home/runner/work/styleguide/styleguide/wpiformat/wpiformat/__init__.py -v
78+
elif [ "$RUNNER_OS" == "Windows" ]; then
79+
python -m wpiformat -f /d/a/styleguide/styleguide/wpiformat/wpiformat/__init__.py -v
80+
elif [ "$RUNNER_OS" == "macOS" ]; then
81+
python -m wpiformat -f /Users/runner/work/styleguide/styleguide/wpiformat/wpiformat/__init__.py -v
82+
else
83+
echo "$RUNNER_OS not supported"
84+
exit 1
85+
fi
86+
87+
- name: wpiformat - multiple files
88+
run: |
89+
cd wpiformat
90+
python -m wpiformat -f wpiformat/__init__.py wpiformat/__main__.py -v
91+
92+
- name: wpiformat - directory
93+
run: |
94+
cd wpiformat
95+
python -m wpiformat -f wpiformat -v
96+
97+
- name: Ensure formatter made no changes
98+
run: git --no-pager diff --exit-code HEAD

azure-pipelines.yml

Lines changed: 0 additions & 114 deletions
This file was deleted.

wpiformat/wpiformat/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ def main():
287287
else:
288288
files.append(name)
289289

290+
# Throw an error if any files or directories don't exist
291+
for f in files:
292+
if not os.path.exists(f):
293+
print(f"error: {f}: No such file or directory")
294+
sys.exit(1)
295+
290296
# Convert relative paths of files to absolute paths
291297
files = [os.path.abspath(name) for name in files]
292298

0 commit comments

Comments
 (0)