-
Notifications
You must be signed in to change notification settings - Fork 4
145 lines (139 loc) · 5.24 KB
/
build.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
name: CI pipeline
on:
- push
- pull_request
jobs:
lint:
runs-on: ubuntu-latest
outputs:
score: ${{ steps.pylint.outputs.score }}
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pylint
- name: Lint with pylint
id: pylint
run: |
mkdir -p ./build
pylint backpack --exit-zero --output-format=text | tee build/pylint.txt
echo ::set-output name=score::$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' build/pylint.txt)
- name: Upload lint report artifact
uses: actions/upload-artifact@v2
with:
name: lint-report
path: build
unittest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7']
outputs:
coverage: ${{ steps.tox.outputs.coverage }}
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
id: tox
run: |
tox
echo ::set-output name=coverage::$(jq '.totals.percent_covered' build/coverage.json)
- name: Upload coverage report artifact
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
path: build
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install dependencies
run: |
sudo sed -i 's/azure\.//' /etc/apt/sources.list
sudo apt-get update -y
sudo apt install -y libunwind-dev
sudo apt-get install -y --no-install-recommends libgirepository1.0-dev libgstreamer1.0-dev libgstrtspserver-1.0-dev
python -m pip install --upgrade pip
python -m pip install opencv-python boto3 PyGObject python-dotenv
python -m pip install sphinx sphinx-rtd-theme m2r2
- name: Generate documentation with Sphinx
working-directory: ./docs
run: |
make html
- name: Upload documentation artifact
uses: actions/upload-artifact@v2
with:
name: documentation
path: ./docs/_build/html
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Upload artifacts to S3
run: aws s3 sync ./docs/_build/html s3://github-ci.experiments.neosperience.com/Neosperience/backpack/docs/ --delete --acl public-read
report:
needs: [lint, unittest, docs]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install anybadge
mkdir -p ./build
- name: Create lint badge
if: ${{ needs.lint.result == 'success' }}
run: anybadge --value="${{ needs.lint.outputs.score }}" --file="build/pylint.svg" pylint
- name: Create lint n/a badge
if: ${{ needs.lint.result != 'success' }}
run: anybadge --label="pylint" --value="n/a" --file="build/pylint.svg" --color gray
- name: Create coverage badge
if: ${{ needs.unittest.result == 'success' }}
run: anybadge --label "coverage" --value=$(printf "%.1f%%" ${{ needs.unittest.outputs.coverage }}) --file="build/coverage.svg"
- name: Create coverage n/a badge
if: ${{ needs.unittest.result != 'success' }}
run: anybadge --label="coverage" --value="n/a" --file="build/coverage.svg" --color gray
- name: Create pipeline success badge
if: ${{ needs.unittest.result == 'success' && needs.lint.result == 'success' }}
run: anybadge --label="pipeline" --value="passing" --file="build/pipeline.svg" passing=green failing=red
- name: Create pipeline failure badge
if: ${{ needs.unittest.result != 'success' || needs.lint.result != 'success' }}
run: anybadge --label="pipeline" --value="failing" --file="build/pipeline.svg" passing=green failing=red
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Download lint artifact
if: ${{ needs.lint.result == 'success' }}
uses: actions/download-artifact@v3
with:
name: lint-report
path: ./build/lint
- name: Download coverage artifact
if: ${{ needs.unittest.result == 'success' }}
uses: actions/download-artifact@v3
with:
name: code-coverage-report
path: ./build/coverage
- name: Upload artifacts to S3
run: aws s3 sync ./build s3://github-ci.experiments.neosperience.com/Neosperience/backpack/build/ --delete --acl public-read --cache-control no-cache