Skip to content

Commit

Permalink
Add toltec hooks (#39)
Browse files Browse the repository at this point in the history
* Add app reload hook

* Fix tests with bash 5.2.21

* Add patch_rm2fb

* Add install-lib hook

* Add python 3.12

* Change standalone to pyinstaller so that hooks can still work

* Add pip package build

* Add pypi upload

* Add unit tests for strip hook


* Do a quick sanity check of built executables

* Update release with artifacts
  • Loading branch information
Eeems authored Jan 3, 2024
1 parent 4aeca56 commit fe4ee54
Show file tree
Hide file tree
Showing 20 changed files with 796 additions and 178 deletions.
163 changes: 163 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Check and Build
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
release:
types: [released]
permissions: read-all
jobs:
format:
name: Check formatting
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python: ['3.11', '3.12']
steps:
- name: Checkout the Git repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Check formatting
run: make format
lint:
name: Check for erroneous constructs
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python: ['3.11', '3.12']
steps:
- name: Checkout the Git repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Check for erroneous constructs
run: make lint
links:
name: Check Markdown links
runs-on: ubuntu-20.04
steps:
- name: Checkout the Git repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Check Markdown links
run: |
npm install -g markdown-link-check
make links
test:
name: Run tests
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python: ['3.11', '3.12']
steps:
- name: Checkout the Git repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Run tests
run: make test
build:
name: Make pip packages
runs-on: ubuntu-20.04
needs: [format, lint, test]
steps:
- name: Checkout the Git repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- name: Building toltecmk
run: make build
- uses: actions/upload-artifact@v4
with:
name: pip
path: dist/*
if-no-files-found: error
standalone:
name: Make Standalone
runs-on: ubuntu-20.04
needs: [format, lint, test]
steps:
- name: Checkout the Git repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- name: Building toltecmk
run: make standalone
- name: Sanity check
run: ./toltecmk --help
- uses: actions/upload-artifact@v4
with:
name: toltecmk
path: toltecmk
if-no-files-found: error
publish:
name: Publish to PyPi
runs-on: ubuntu-20.04
needs: [build, links]
if: github.repository == 'toltec-dev/build' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/toltecmk
steps:
- name: Download pip packages
id: download
uses: actions/download-artifact@v4
with:
name: pip
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ steps.download.outputs.download-path }}
release:
name: Add ${{ matrix.artifact }} to release
if: github.repository == 'toltec-dev/build' && github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
needs: [standalone, build]
runs-on: ubuntu-latest
strategy:
matrix:
artifact:
- 'pip'
- 'toltecmk'
permissions:
contents: write
steps:
- name: Checkout the Git repository
uses: actions/checkout@v4
- name: Download executable
id: download
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist
- name: Upload to release
run:
find . -type f | xargs -rI {} gh release upload "$TAG" {} --clobber
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event.release.tag_name }}
working-directory: ${{ steps.download.outputs.download-path }}
84 changes: 0 additions & 84 deletions .github/workflows/checks.yml

This file was deleted.

12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export USAGE
help:
@echo "$$USAGE"

.venv-build/bin/activate:
.venv-build/bin/activate: requirements.build.txt
@echo "Setting up development virtual env in .venv"
python -m venv .venv-build; \
. .venv-build/bin/activate; \
python -m pip install -r requirements.build.txt

.venv-runtime/bin/activate:
.venv-runtime/bin/activate: requirements.txt
@echo "Setting up development virtual env in .venv"
python -m venv .venv-runtime; \
. .venv-runtime/bin/activate; \
Expand All @@ -54,13 +54,7 @@ build: .venv-build/bin/activate

standalone: .venv-build/bin/activate
. .venv-build/bin/activate; \
python -m nuitka \
--follow-imports --enable-plugin=anti-bloat \
--enable-plugin=pylint-warnings \
--onefile --linux-onefile-icon=media/overview.svg \
--assume-yes-for-downloads \
-o toltecmk \
toltec
python -m PyInstaller --distpath . toltecmk.spec

test: .venv-runtime/bin/activate
. .venv-runtime/bin/activate; \
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "toltecmk"
version = "0.2.1"
version = "0.3.0"
authors = [
{ name="Mattéo Delabre", email="[email protected]" },
{ name="Eeems", email="[email protected]" },
Expand Down Expand Up @@ -40,9 +40,9 @@ packages = [
]

[tool.setuptools.package-data]
toltec = ["*.py.typed"]
"toltec.recipe_parsers" = ["*.py.typed"]
"toltec.hooks" = ["*.py.typed"]
toltec = ["py.typed", "*.py.typed"]
"toltec.recipe_parsers" = ["py.typed", "*.py.typed"]
"toltec.hooks" = ["py.typed", "*.py.typed"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
Expand Down
7 changes: 3 additions & 4 deletions requirements.build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
build==0.6.0.post1
packaging==23.1
pep517==0.13.0
nuitka==1.7.10
pyinstaller==6.3.0
black==23.7.0
astroid==2.15.6
certifi==2023.7.22
charset-normalizer==3.2.0
idna==3.4
isort==5.12.0
lazy-object-proxy==1.9.0
mccabe==0.7.0
mypy==1.5.1
mypy==1.7.1
mypy-extensions==1.0.0
pylint==2.17.5
pylint==3.0.3
pyparsing==3.1.1
six==1.16.0
toml==0.10.2
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
docker==6.1.3
python-dateutil==2.8.2
pyelftools==0.29
pyelftools==0.30
9 changes: 9 additions & 0 deletions tests/fixtures/hello/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2023 The Toltec Contributors
// SPDX-License-Identifier: MIT

#include <stdio.h>

int main() {
printf("Hello, World!");
return 0;
}
25 changes: 25 additions & 0 deletions tests/fixtures/hello/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Copyright (c) 2023 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(hello)
pkgdesc="Hello World!"
timestamp=2023-12-27T00:58Z
maintainer="Eeems <[email protected]>"
url="https://github.com/toltec-dev/build"
license=MIT
pkgver=0.0.1-1
section="utils"
flags=()

image=base:v2.1
source=(hello.c)
sha256sums=(SKIP)

build() {
export CC="${CROSS_COMPILE}gcc"
"$CC" -o hello hello.c
}
package() {
install -D -m 755 "$srcdir"/hello "$pkgdir"/opt/bin/hello
}
Loading

0 comments on commit fe4ee54

Please sign in to comment.