-
Notifications
You must be signed in to change notification settings - Fork 9
136 lines (118 loc) · 4.21 KB
/
build_and_tests.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
name: Build, test and deploy Ragger
on:
workflow_dispatch:
push:
tags:
- '*'
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build_boilerplate_application:
name: Build boilerplate application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
app_repository: LedgerHQ/app-boilerplate
app_branch_name: master
upload_app_binaries_artifact: boilerplate_binaries
build_install_test:
name: Install and test the library
needs: [build_boilerplate_application]
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Speculos dependencies
run: sudo apt-get update && sudo apt-get install -y qemu-user-static tesseract-ocr libtesseract-dev
- name: Build & install
run: |
pip install --extra-index-url https://test.pypi.org/simple/ -U .[tests,all_backends]
pip install -U click>=8
- name: Download app binaries
uses: actions/download-artifact@v3
with:
name: boilerplate_binaries
path: ./build/
- name: Check the downloaded files
run: tree .
- name: Run tests and generate coverage
run: pytest -v --tb=short tests/ --cov ragger --cov-report xml --device all
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
name: codecov-ragger
package_and_deploy:
name: Build and deploy Ragger Python Package
runs-on: ubuntu-latest
needs: [build_install_test]
steps:
- name: Clone
uses: actions/checkout@v3
with:
fetch-depth: 0
# Fetching dependencies from test.pypi,org or pypi.org depending on the package destination:
# tag -> pypi.org, not tag -> test.pypi.org
- name: Build Ragger Python package
run: |
pip install --upgrade pip build twine
if [[ ${{ github.ref }} == "refs/tags/"* ]]; \
then \
python -m build; \
pip install .
else \
PIP_EXTRA_INDEX_URL=https://test.pypi.org/simple/ python -m build; \
pip install --extra-index-url https://test.pypi.org/simple/ .
fi
python -m twine check dist/*
echo "TAG_VERSION=$(python -c 'from ragger import __version__; print(__version__)')" >> "$GITHUB_ENV"
- name: Display current status
run: |
echo "Current status is:"
if [[ ${{ github.ref }} == "refs/tags/"* ]]; \
then \
echo "- Triggered from tag, will be deployed on pypi.org"; \
else \
echo "- Not triggered from tag, will be deployed on test.pypi.org"; \
fi
echo "- Tag version: ${{ env.TAG_VERSION }}"
- name: Check version against CHANGELOG
if: startsWith(github.ref, 'refs/tags/')
run: |
CHANGELOG_VERSION=$(grep -Po '(?<=## \[)(\d+\.)+[^\]]' CHANGELOG.md | head -n 1)
if [ "${{ env.TAG_VERSION }}" == "${CHANGELOG_VERSION}" ]; \
then \
exit 0; \
else \
echo "Tag '${{ env.TAG_VERSION }}' and CHANGELOG '${CHANGELOG_VERSION}' versions mismatch!"; \
exit 1; \
fi
- name: Publish Python package on pypi.org
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLIC_API_TOKEN }}
TWINE_NON_INTERACTIVE: 1
- name: Publish a release on the repo
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: "marvinpinto/action-automatic-releases@latest"
with:
automatic_release_tag: "v${{ env.TAG_VERSION }}"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
files: |
LICENSE
dist/
- name: Publish Python package on test.pypi.org
if: success() && github.event_name == 'push'
run: python -m twine upload --repository testpypi dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PUBLIC_API_TOKEN }}
TWINE_NON_INTERACTIVE: 1