Skip to content

Commit

Permalink
Use official Python docker image for helper build
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Feb 21, 2024
1 parent 2d16bf9 commit 6b0e5de
Showing 1 changed file with 102 additions and 41 deletions.
143 changes: 102 additions & 41 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,62 @@ name: Linux
on: [push, pull_request]

jobs:
build:
run-checks:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Read variables from repo
run: cat .github/workflows/env >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYVER }}

- name: Install Flutter dependencies
run: |
sudo apt-get update
sudo apt-get install -qq swig libpcsclite-dev build-essential
sudo apt-get install -qq clang cmake ninja-build pkg-config libgtk-3-dev jq
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: ${{ env.FLUTTER }}

- name: Check app versions
run: |
python3 set-version.py
git diff --exit-code
- name: Run lints/tests
run: |
export PATH=$PATH:$HOME/.local/bin
python3 -m pip install --upgrade pip
pip install poetry pre-commit
(cd helper && poetry install)
pre-commit run --all-files
flutter test
build-helper:
runs-on: ubuntu-latest
container:
image: ubuntu:20.04
image: python:3.12.2-slim-bullseye # This need to be manually updates in sync with env
env:
DEBIAN_FRONTEND: noninteractive

steps:

- uses: actions/checkout@v4
with:
sparse-checkout: .github/workflows/env

- name: Read variables from repo
run: cat .github/workflows/env >> $GITHUB_ENV

- name: Install dependencies
run: |
echo "PYVER=3.12.1" >> $GITHUB_ENV # Remove once 3.12.2 is available from PPA
export PYVER_MINOR=${PYVER%.*}
echo "PYVER_MINOR: $PYVER_MINOR"
apt-get update
apt-get install -qq curl software-properties-common libnotify-dev libayatana-appindicator3-dev patchelf
add-apt-repository -y ppa:git-core/ppa
add-apt-repository -y ppa:deadsnakes/ppa
apt-get install -qq git python$PYVER_MINOR-dev python$PYVER_MINOR-venv
git config --global --add safe.directory "$GITHUB_WORKSPACE"
ln -s `which python$PYVER_MINOR` /usr/local/bin/python
ln -s `which python$PYVER_MINOR` /usr/local/bin/python3
PYVER_TEMP=`/usr/local/bin/python --version`
cat .github/workflows/env >> $GITHUB_ENV
PYVER_TEMP=`python --version`
export PYVERINST=${PYVER_TEMP#* }
echo "PYVERINST=$PYVERINST" >> $GITHUB_ENV
echo "Installed python version: $PYVERINST"
python -m ensurepip --user
python -m pip install -U pip pipx
- name: Verify Python version
if: ${{ env.PYVERINST != env.PYVER }}
Expand All @@ -47,12 +68,63 @@ jobs:
echo "Expected: $PYVER"
exit 1
- uses: actions/checkout@v4
- name: Calculate cache key
run: echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_ENV
env:
CACHE_KEY: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }}

- name: Check app versions
- name: Cache helper
id: cache-helper
uses: actions/cache@v4
with:
path: |
build/linux/helper
assets/licenses/helper.json
key: ${{ env.CACHE_KEY }}

- name: Build the Helper
if: steps.cache-helper.outputs.cache-hit != 'true'
working-directory: ./helper
run: |
python set-version.py
git diff --exit-code
apt-get update
apt-get install -qq swig libpcsclite-dev build-essential
pip install poetry
poetry install
poetry run pyinstaller authenticator-helper.spec
find dist/helper -type f -exec chmod a-x {} +
chmod a+x dist/helper/authenticator-helper
mkdir -p ../build/linux
mv dist/helper ../build/linux/
poetry build
python -m venv .venv
.venv/bin/pip install --upgrade pip wheel
.venv/bin/pip install dist/authenticator_helper-0.1.0-py3-none-any.whl pip-licenses
mkdir licenses
.venv/bin/pip-licenses --format=json --no-license-path --with-license-file --ignore-packages authenticator-helper zxing-cpp --output-file ../assets/licenses/helper.json
build-app:

needs: build-helper
runs-on: ubuntu-latest
container:
image: ubuntu:20.04
env:
DEBIAN_FRONTEND: noninteractive

steps:

- name: Install git
run: |
apt-get update
apt-get install -qq curl software-properties-common
add-apt-repository -y ppa:git-core/ppa
apt-get install -qq git
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/checkout@v4

- name: Read variables from repo
run: cat .github/workflows/env >> $GITHUB_ENV

- name: Cache helper
id: cache-helper
Expand All @@ -63,16 +135,14 @@ jobs:
assets/licenses/helper.json
key: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }}

- name: Build the Helper
- name: Require the Helper
if: steps.cache-helper.outputs.cache-hit != 'true'
run: |
apt-get install -qq swig libpcsclite-dev build-essential cmake
export PATH=$PATH:$HOME/.local/bin # Needed to ensure pipx/poetry on PATH
pipx install poetry
./build-helper.sh
run: exit 1

- name: Install Flutter dependencies
run: |
apt-get update
apt-get install -qq libnotify-dev libayatana-appindicator3-dev patchelf
apt-get install -qq clang cmake ninja-build pkg-config libgtk-3-dev jq
- uses: subosito/flutter-action@v2
Expand All @@ -86,15 +156,6 @@ jobs:
flutter config --enable-linux-desktop
flutter --version
- name: Run lints/tests
env:
SKIP: ${{ steps.cache-helper.outputs.cache-hit == 'true' && 'mypy,flake8,black,bandit' || ''}}
run: |
export PATH=$PATH:$HOME/.local/bin # Needed to ensure pip/pre-commit on PATH
pipx install pre-commit
pre-commit run --all-files
flutter test
- name: Build the app
run: flutter build linux

Expand Down

0 comments on commit 6b0e5de

Please sign in to comment.