forked from lucasponce/iter8-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (75 loc) · 2.45 KB
/
python-app.yaml
File metadata and controls
84 lines (75 loc) · 2.45 KB
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
# This workflow installs Python dependencies for testing and linting
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Unit tests
on:
release:
types: [published]
push:
# Publish `master` as Docker `latest` image.
branches:
- master
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r test-requirements.txt
pip install -e .
- name: Lint with pylint
run: |
# stop the build if Pylint score is too low
pip install pylint --upgrade
pylint --fail-under=9.1 iter8_analytics --reports=y
- name: Test
run: |
echo $(pwd)
coverage run --source=iter8_analytics --omit="*/__init__.py" -m pytest
build-and-push:
# Ensure test job passes before pushing image.
needs: build-and-test
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
# registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_SECRET }}
- name: Get version
run: |
tarref=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tagref
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
echo "VERSION=$(echo $tarref | sed -e 's/^v//')" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == *"master" ]]; then
echo "VERSION=latest" >> $GITHUB_ENV
fi
- name: Get owner and repo
run: |
ownerrepo=${{ github.repository }}
owner=$(echo $ownerrepo | cut -f1 -d/)
if [[ "$owner" == "iter8-tools" ]]; then
owner=iter8
fi
echo "OWNER=$owner" >> $GITHUB_ENV
echo "REPO=$(echo $ownerrepo | cut -f2 -d/)" >> $GITHUB_ENV
- uses: docker/build-push-action@v2
with:
context: .
tags: ${{ env.OWNER }}/${{ env.REPO }}:${{ env.VERSION }}
push: true