-
Notifications
You must be signed in to change notification settings - Fork 10
105 lines (99 loc) · 3.22 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
name: CI
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
Test:
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
os: ["ubuntu"]
continue-on-error: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup navix
run: |
pip install . -v
- name: Check code quality
run: |
pip install pylint
MESSAGE=$(pylint -ry $(git ls-files '*.py') ||:)
echo "$MESSAGE"
- name: Run unit tests with pytest
run: |
wandb offline
pytest
- name: Run examples
run: |
for example in examples/*.py; do
python $example
done
Compliance:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: PEP8 Compliance
run: |
pip install pylint
PR_BRANCH=${{ github.event.pull_request.target.ref }}
MAIN_BRANCH=origin/${{ github.event.pull_request.base.ref }}
CURRENT_DIFF=$(git diff --name-only --diff-filter=d $MAIN_BRANCH $PR_BRANCH | grep -E '\.py$' | tr '\n' ' ')
if [[ $CURRENT_DIFF == "" ]];
then MESSAGE="Diff is empty and there is nothing to pylint."
else
MESSAGE=$(pylint -ry --disable=E0401 $CURRENT_DIFF ||:)
fi
echo 'MESSAGE<<EOF' >> $GITHUB_ENV
echo "<pre><code>$MESSAGE</code></pre>" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo "Printing PR message: $MESSAGE"
- uses: mshick/add-pr-comment@v2
with:
issue: ${{ github.event.pull_request.number }}
message: ${{ env.MESSAGE }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
Check-next-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Get version from file
run: |
VERSION_FILE="navix/_version.py"
NAVIX_VERSION="$(cat navix/_version.py | grep '__version__ = ' | cut -d'=' -f2 | sed 's,\",,g' | sed "s,\',,g" | sed 's, ,,g')"
echo "Current version is:"
echo "$NAVIX_VERSION"
echo "NAVIX_VERSION=$NAVIX_VERSION" >> $GITHUB_ENV
- name: Check that git tag does not exist
run: |
NAVIX_VERSION=${{ env.NAVIX_VERSION }}
git fetch --tags
if [ $(git tag -l "$NAVIX_VERSION") ]; then
echo "Tag $NAVIX_VERSION already exists. Please update the version in navix/_version.py file."
exit 1
fi
echo "Tag $NAVIX_VERSION will be the deployed version."
deploy-docs:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Setup navix
run: |
pip install . -v --no-dependencies
pip install -r ./docs/requirements.txt
- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONFIG_FILE: ./mkdocs.yml