Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: native binaries #382

Merged
merged 44 commits into from Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2c5b1d1
add pyinstaller
joe-p Jun 15, 2023
96d7565
pyinstaller compilation smoke test
joe-p Jun 15, 2023
1b587e1
pyinstaller: move to dev deps, add py version
joe-p Jun 15, 2023
e6ec93d
Merge branch 'main' into pyinstaller
joe-p Oct 15, 2023
d1f18db
add --hidden-import jinja2_ansible_filters
joe-p Oct 16, 2023
b68014f
Merge branch 'main' into feat/pyinstaller
aorumbayev Jan 9, 2024
6122cce
chore: testing ci
aorumbayev Jan 9, 2024
f428dc1
chore: testing ci
aorumbayev Jan 9, 2024
2d3117d
chore: testing ci
aorumbayev Jan 9, 2024
2b1b4e8
chore: testing ci
aorumbayev Jan 10, 2024
e475f5a
chore: testing ci
aorumbayev Jan 15, 2024
02e8db3
chore: testing ci
aorumbayev Jan 15, 2024
2600fa3
chore: testing ci
aorumbayev Jan 15, 2024
4c72b2c
chore: testing ci
aorumbayev Jan 15, 2024
75382fa
chore: testing ci
aorumbayev Jan 15, 2024
9a555c2
chore: testing ci
aorumbayev Jan 15, 2024
00d75d2
chore: testing ci
aorumbayev Jan 15, 2024
13b754b
chore: testing ci
aorumbayev Jan 15, 2024
cab5181
chore: testing ci
aorumbayev Jan 15, 2024
b8f8f6c
chore: testing ci
aorumbayev Jan 15, 2024
507334f
chore: testing ci
aorumbayev Jan 15, 2024
3e93928
chore: testing ci
aorumbayev Jan 15, 2024
b6db391
chore: testing ci
aorumbayev Jan 15, 2024
97e8625
chore: testing ci
aorumbayev Jan 15, 2024
ee56516
docs: wip adr
aorumbayev Jan 15, 2024
17afb3b
chore: test
aorumbayev Jan 15, 2024
d4f610b
docs: added some points about Nuitka
negar-abbasi Jan 16, 2024
6bdf29e
chore: testing ci
aorumbayev Jan 16, 2024
ea20eef
chore: testing ci
aorumbayev Jan 16, 2024
8342ab6
chore: testing ci
aorumbayev Jan 16, 2024
4f095bd
Merge remote-tracking branch 'origin/main' into feat/pyinstaller
aorumbayev Jan 24, 2024
ee1947a
chore: adding multiple os runs for build
aorumbayev Jan 24, 2024
6e3cb7e
chore: improving build
aorumbayev Jan 24, 2024
db63726
chore: fixing tests; removing setting from vscode clashing with ruff
aorumbayev Jan 24, 2024
11f605b
chore: testing ci
aorumbayev Jan 24, 2024
d0b4c5c
chore: testing ci
aorumbayev Jan 24, 2024
c346137
chore: testing ci
aorumbayev Jan 24, 2024
fe6b524
chore: testing ci
aorumbayev Jan 24, 2024
c62fb7b
chore: testing ci
aorumbayev Jan 24, 2024
33b8a3e
cI: refining ci/cd pipelines; dumping binaries to (pre)release
aorumbayev Jan 25, 2024
a9f2dff
chore: adding new poetry action to cd
aorumbayev Jan 25, 2024
69d29ef
chore: removing old adr draft
aorumbayev Jan 26, 2024
2152d3d
chore: addressing pr comments
aorumbayev Jan 29, 2024
49bd912
chore: patching tealer
aorumbayev Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/actions/build-binaries/action.yaml
@@ -0,0 +1,67 @@
name: "Setup, Build, and Test"
description: "Set up Python with Poetry, build and test binaries"
inputs:
package_name:
description: "The name of the package to build and test"
required: true
upload_binaries:
description: "Flag to determine if this is a production release"
required: true
operating_system:
description: "Operating system to set the correct binary path and extension"
required: true
build_command:
description: "Command to build the binaries"
required: true
python_version:
description: "Python version to use"
required: true

runs:
using: "composite"
steps:
- name: Build Executable
run: ${{ inputs.build_command }}
shell: bash

- name: Test Executable
run: |
ls -l dist
./dist/${{ inputs.package_name }}/${{ inputs.package_name }}${{ inputs.operating_system == 'windows-latest' && '.exe' || '' }} --help
shell: bash
aorumbayev marked this conversation as resolved.
Show resolved Hide resolved

- name: Set release version
shell: bash
continue-on-error: true
if: ${{ inputs.upload_binaries == 'true' }}
run: |
echo "RELEASE_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
git describe --tags $(git rev-list --tags --max-count=1)

- name: Zip binaries
shell: bash
continue-on-error: true
if: ${{ inputs.upload_binaries == 'true' }}
run: |
ls -l dist
cd dist/algokit/
tar -zcvf ../../algokit-${{ env.RELEASE_VERSION }}-${{ inputs.operating_system }}-py${{ inputs.python_version }}.tar.gz *
cd ../..
ls -l

- name: Upload binary as artifact
if: ${{ inputs.upload_binaries == 'true' }}
uses: actions/upload-artifact@v4
with:
name: algokit-cli-${{ inputs.operating_system }}-py${{ inputs.python_version }}
path: algokit-${{ env.RELEASE_VERSION }}-${{ inputs.operating_system }}-py${{ inputs.python_version }}.tar.gz

- name: Append binary to release
continue-on-error: true
if: ${{ inputs.upload_binaries == 'true' }}
uses: softprops/action-gh-release@v1
with:
files: |
algokit-${{ env.RELEASE_VERSION }}-${{ inputs.operating_system }}-py${{ inputs.python_version }}.tar.gz
tag_name: ${{ env.RELEASE_VERSION }}
prerelease: ${{ contains(env.RELEASE_VERSION, 'beta') }}
22 changes: 22 additions & 0 deletions .github/actions/setup-poetry/action.yaml
@@ -0,0 +1,22 @@
name: "Python Poetry Action"
description: "An action to setup Poetry"
inputs:
poetry-version:
description: "The version of poetry to install"
required: false
default: "latest"
runs:
using: "composite"
steps:
- run: |
pip install --user pipx
pipx ensurepath
shell: bash
- if: ${{ inputs.poetry-version == 'latest' }}
run: |
pipx install poetry
shell: bash
- if: ${{ inputs.poetry-version != 'latest' }}
run: |
pipx install poetry==${{ inputs.poetry-version }}
shell: bash
135 changes: 135 additions & 0 deletions .github/workflows/build-binaries.yaml
@@ -0,0 +1,135 @@
name: Build, Test and Publish Pyinstaller Binaries

on:
workflow_call:
inputs:
upload_binaries:
required: true
type: string
python_version:
required: true
type: string

jobs:
build-binaries-ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout source code (for release)
uses: actions/checkout@v4
if: ${{ inputs.upload_binaries == 'true' }}
with:
fetch-depth: 0

- name: Checkout source code (for build)
uses: actions/checkout@v4
if: ${{ inputs.upload_binaries != 'true' }}
with:
fetch-depth: 1
aorumbayev marked this conversation as resolved.
Show resolved Hide resolved

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}

- name: Set up Poetry
uses: ./.github/actions/setup-poetry

- uses: actions/cache@v4
name: Setup poetry cache
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ runner.os }}-${{ inputs.python_version }}

- name: Install dependencies
run: poetry install --no-interaction

- name: Build linux binary
uses: ./.github/actions/build-binaries
with:
python_version: ${{ inputs.python_version }}
package_name: "algokit"
upload_binaries: ${{ inputs.upload_binaries }}
operating_system: ${{ runner.os }}
build_command: "poetry run poe package_unix"

build-binaries-windows:
runs-on: windows-latest
steps:
- name: Checkout source code (for release)
uses: actions/checkout@v4
if: ${{ inputs.upload_binaries == 'true' }}
with:
fetch-depth: 0

- name: Checkout source code (for build)
uses: actions/checkout@v4
if: ${{ inputs.upload_binaries != 'true' }}
with:
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}

- name: Set up Poetry
uses: ./.github/actions/setup-poetry

- uses: actions/cache@v4
name: Setup poetry cache
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ runner.os }}-${{ inputs.python_version }}

- name: Install dependencies
run: poetry install --no-interaction

- name: Build windows binary
uses: ./.github/actions/build-binaries
with:
python_version: ${{ inputs.python_version }}
package_name: "algokit"
upload_binaries: ${{ inputs.upload_binaries }}
operating_system: ${{ runner.os }}
build_command: "poetry run poe package_windows"

build-binaries-macos:
runs-on: macos-latest
steps:
- name: Checkout source code (for release)
uses: actions/checkout@v4
if: ${{ inputs.upload_binaries == 'true' }}
with:
fetch-depth: 0

- name: Checkout source code (for build)
uses: actions/checkout@v4
if: ${{ inputs.upload_binaries != 'true' }}
with:
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python_version }}

- name: Set up Poetry
uses: ./.github/actions/setup-poetry

- uses: actions/cache@v4
name: Setup poetry cache
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ runner.os }}-${{ inputs.python_version }}

- name: Install dependencies
run: poetry install --no-interaction

- name: Build macos binary
uses: ./.github/actions/build-binaries
with:
python_version: ${{ inputs.python_version }}
package_name: "algokit"
upload_binaries: ${{ inputs.upload_binaries }}
operating_system: ${{ runner.os }}
build_command: "poetry run poe package_unix"
38 changes: 26 additions & 12 deletions .github/workflows/build-python.yaml
Expand Up @@ -6,35 +6,49 @@ jobs:
build-python:
strategy:
matrix:
#os: ["ubuntu-latest", "macos-latest", "windows-latest"]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
# Mac and Windows chew through build minutes - waiting until repo is public to enable
os: ["ubuntu-latest", "windows-latest"]
python: ["3.10"]
python: ["3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python ${{ matrix.python }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: "poetry"

- name: Set up Poetry
uses: ./.github/actions/setup-poetry

- uses: actions/cache@v4
name: Setup poetry cache
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ matrix.os }}-${{ matrix.python }}

- name: Install dependencies
run: poetry install --no-interaction && pipx install tealer==0.1.1
# TODO: remove fixed pipx dependency once 3.12 compatibility is addressed
# track here -> https://github.com/crytic/tealer/pull/209
run: poetry install --no-interaction && pipx install git+https://github.com/algorandfoundation/tealer@3-12

- name: pytest + coverage
shell: bash
run: |
set -o pipefail
poetry run pytest -n auto --junitxml=pytest-junit.xml --cov-report=term-missing:skip-covered --cov=src | tee pytest-coverage.txt
id: pytest

- name: Upload received snapshots (in case of failure)
if: failure() && steps.pytest.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{ matrix.os }}-python${{ matrix.python }}
path: tests/**/*.received.txt

- name: pytest coverage comment - using Python 3.10 on ubuntu-latest
if: matrix.python == '3.10' && matrix.os == 'ubuntu-latest'
- name: pytest coverage comment - using Python 3.12 on ubuntu-latest
if: matrix.python == '3.12' && matrix.os == 'ubuntu-latest'
continue-on-error: true # forks fail to add a comment, so continue any way
uses: MishaKav/pytest-coverage-comment@main
with:
Expand Down
23 changes: 17 additions & 6 deletions .github/workflows/cd.yaml
Expand Up @@ -38,17 +38,19 @@ jobs:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Set up Poetry
uses: ./.github/actions/setup-poetry

- uses: actions/cache@v4
name: Setup poetry cache
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ runner.os }}-3.10

- name: Get branch name
shell: bash
Expand Down Expand Up @@ -112,6 +114,15 @@ jobs:
path: dist/algokit*-py3-none-any.whl
if-no-files-found: error

upload-binaries:
name: Build and Upload Binaries
if: ${{ github.ref_name == 'main' }}
uses: ./.github/workflows/build-binaries.yaml
needs: release
with:
upload_binaries: "true"
python_version: "3.12"

cd-publish-release-packages:
name: Publish Release Packages
needs: release
Expand Down
19 changes: 12 additions & 7 deletions .github/workflows/check-python.yaml
Expand Up @@ -8,16 +8,21 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python 3.10
- name: Set up Python 3.12
aorumbayev marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "poetry"
python-version: "3.12"

- name: Set up Poetry
uses: ./.github/actions/setup-poetry

- uses: actions/cache@v4
name: Setup poetry cache
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ runner.os }}-3.12

- name: Install dependencies
run: poetry install --no-interaction
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/issue_closed.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/issue_commented.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/issue_labelled.yml

This file was deleted.