forked from dyvenia/viadot
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (106 loc) · 3.67 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
name: build
on:
push:
branches:
- "main"
- "dev"
pull_request:
branches:
- "main"
- "dev"
env:
IMAGE_NAME: viadot
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# 3.8+. 3.9 should be supported by late 2021.
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
id: cache-pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -r requirements.txt
if: steps.cache.outputs.cache-hit != 'true'
continue-on-error: false
- name: Lint with flake8
if: always()
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics --ignore=E203
- name: Format imports with isort
if: always()
run: |
pip install isort
isort --profile black .
- name: Format with black
id: blackCheck
if: always()
run: |
pip install black
black --check .
continue-on-error: true
- name: Commit Black changes to the pull request
if: ${{ always() && steps.blackCheck.outcome == 'failure' }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
black .
git checkout $GITHUB_HEAD_REF
git commit -am "🎨 Format Python code with Black"
git push
- name: Test with pytest
if: always()
env:
VIADOT_CONFIG_PATH: .config/credentials.json.template
run: |
pip install pytest
sudo apt install libsqliteodbc
pytest tests/unit
# - name: Generate coverage report
# run: |
# pytest --cov-report xml --cov=viadot tests/
# - name: Upload coverage report to Codecov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
publish_docker:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Build image
run: export DOCKER_BUILDKIT=1 && docker build . --file docker/Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Publish with the `dev` label
echo IMAGE_ID=$IMAGE_ID
docker tag $IMAGE_NAME $IMAGE_ID:dev
docker push $IMAGE_ID:dev