IEBH-286: Upgrade to python 3.10 (#187) #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: HDC test, build and push | |
on: | |
push: | |
branches: | |
- hdc | |
pull_request: | |
branches: | |
- hdc | |
jobs: | |
tests: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10.14 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.3.2 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Set up cache | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ hashFiles('**/poetry.lock') }} | |
- name: Ensure cache is healthy | |
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true' | |
run: timeout 10s poetry run pip --version || rm -rf .venv | |
- name: Install dependencies | |
run: poetry install --no-interaction --no-root | |
- name: Run pre-commit hooks | |
uses: pre-commit/action@v3.0.0 | |
- name: Run tests | |
run: poetry run pytest -vvv --exitfirst --cov=app --cov-report=term --cov-report=xml --cov-fail-under=23 | |
- name: Coverage report comment | |
uses: mishakav/pytest-coverage-comment@v1.1.42 | |
with: | |
pytest-xml-coverage-path: ./coverage.xml | |
coverage-path-prefix: app/ | |
extract-branch-name: | |
runs-on: ubuntu-20.04 | |
needs: [ tests ] | |
outputs: | |
branch: ${{steps.extract_branch.outputs.branch}} | |
steps: | |
- name: Extract Branch Name | |
id: extract_branch | |
shell: bash | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
push-binary: | |
needs: [ extract-branch-name ] | |
if: ${{ needs.extract-branch-name.outputs.branch == 'hdc' }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.extract-branch-name.outputs.branch }} | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.10.14 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.3.2 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Set up cache | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ hashFiles('**/poetry.lock') }} | |
- name: Ensure cache is healthy | |
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true' | |
run: timeout 10s poetry run pip --version || rm -rf .venv | |
- name: Install dependencies | |
run: poetry install --no-interaction --no-root | |
- name: Build binary | |
run: poetry run pyinstaller -F --distpath ./app/bundled_app/linux --specpath ./app/build/linux --workpath ./app/build/linux --paths=./.venv/lib/python3.9/site-packages ./app/pilotcli.py -n ${{ github.sha }} | |
- name: Set version in env | |
run: poetry run echo "TAG_VERSION=`poetry version --short`" >> $GITHUB_ENV | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: ${{ env.TAG_VERSION }}-${{ needs.extract-branch-name.outputs.branch }} | |
release_name: Release ${{ needs.extract-branch-name.outputs.branch }} ${{ env.TAG_VERSION }} | |
body: ${{ github.event.head_commit.message }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Binary | |
id: upload-release-binary | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ./app/bundled_app/linux/${{ github.sha }} | |
asset_name: pilotcli | |
asset_content_type: application/octet-stream |