-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (70 loc) · 2.29 KB
/
ci-dev-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
name: CI for a new dev push
on:
push:
branches: [ dev ]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Set up Python
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.7'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
# Install pip dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install setuptools wheel twine pytest
# Execute tests
- name: Execute pytest
run: python -m pytest -o junit_family=xunit2 --doctest-modules --junitxml=junit/test-results.xml test/
# Push test results
- name: Archive code coverage results
uses: actions/upload-artifact@v1
with:
name: pytest-results
path: junit/test-results.xml
# Change dev version
- name: Change version number
run: sed -i -e "s/__dev_version__/.dev$(date '+%y%m%d%H%M')/g" setup.py
# Get version number
- name: Get version number
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: echo "::set-env name=PACKAGE_VERSION::$(grep -oP "VERSION = \"\K\d\.\d[.ba\d]+\.dev\d{10}" setup.py)"
# Build wheel and publish it
- name: Build and publish to PyPI Test
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
# Push wheel as an artifact
- name: Archive wheel
uses: actions/upload-artifact@v1
with:
name: dist
path: dist
# Check the package
- name: Check the PyPI test package
run: |
set -eux
declare -r HOST="https://test.pypi.org/project/SentiLeak/$PACKAGE_VERSION/"
wait-for-url() {
echo "Testing $1"
timeout -s TERM 45 bash -c \
'while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' ${0})" != "200" ]];\
do echo "Waiting for ${0}" && sleep 2;\
done' ${1}
echo "OK!"
sleep 5
curl -I $1
}
wait-for-url ${HOST}