Skip to content

Commit 6b0e5de

Browse files
committed
Use official Python docker image for helper build
1 parent 2d16bf9 commit 6b0e5de

File tree

1 file changed

+102
-41
lines changed

1 file changed

+102
-41
lines changed

.github/workflows/linux.yml

Lines changed: 102 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,62 @@ name: Linux
33
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
run-checks:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Read variables from repo
13+
run: cat .github/workflows/env >> $GITHUB_ENV
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ env.PYVER }}
19+
20+
- name: Install Flutter dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -qq swig libpcsclite-dev build-essential
24+
sudo apt-get install -qq clang cmake ninja-build pkg-config libgtk-3-dev jq
25+
26+
- uses: subosito/flutter-action@v2
27+
with:
28+
channel: 'stable'
29+
flutter-version: ${{ env.FLUTTER }}
30+
31+
- name: Check app versions
32+
run: |
33+
python3 set-version.py
34+
git diff --exit-code
35+
36+
- name: Run lints/tests
37+
run: |
38+
export PATH=$PATH:$HOME/.local/bin
39+
python3 -m pip install --upgrade pip
40+
pip install poetry pre-commit
41+
(cd helper && poetry install)
42+
pre-commit run --all-files
43+
flutter test
744
45+
build-helper:
846
runs-on: ubuntu-latest
947
container:
10-
image: ubuntu:20.04
48+
image: python:3.12.2-slim-bullseye # This need to be manually updates in sync with env
1149
env:
1250
DEBIAN_FRONTEND: noninteractive
1351

1452
steps:
53+
1554
- uses: actions/checkout@v4
16-
with:
17-
sparse-checkout: .github/workflows/env
1855

1956
- name: Read variables from repo
20-
run: cat .github/workflows/env >> $GITHUB_ENV
21-
22-
- name: Install dependencies
2357
run: |
24-
echo "PYVER=3.12.1" >> $GITHUB_ENV # Remove once 3.12.2 is available from PPA
25-
export PYVER_MINOR=${PYVER%.*}
26-
echo "PYVER_MINOR: $PYVER_MINOR"
27-
apt-get update
28-
apt-get install -qq curl software-properties-common libnotify-dev libayatana-appindicator3-dev patchelf
29-
add-apt-repository -y ppa:git-core/ppa
30-
add-apt-repository -y ppa:deadsnakes/ppa
31-
apt-get install -qq git python$PYVER_MINOR-dev python$PYVER_MINOR-venv
32-
git config --global --add safe.directory "$GITHUB_WORKSPACE"
33-
ln -s `which python$PYVER_MINOR` /usr/local/bin/python
34-
ln -s `which python$PYVER_MINOR` /usr/local/bin/python3
35-
PYVER_TEMP=`/usr/local/bin/python --version`
58+
cat .github/workflows/env >> $GITHUB_ENV
59+
PYVER_TEMP=`python --version`
3660
export PYVERINST=${PYVER_TEMP#* }
3761
echo "PYVERINST=$PYVERINST" >> $GITHUB_ENV
38-
echo "Installed python version: $PYVERINST"
39-
python -m ensurepip --user
40-
python -m pip install -U pip pipx
4162
4263
- name: Verify Python version
4364
if: ${{ env.PYVERINST != env.PYVER }}
@@ -47,12 +68,63 @@ jobs:
4768
echo "Expected: $PYVER"
4869
exit 1
4970
50-
- uses: actions/checkout@v4
71+
- name: Calculate cache key
72+
run: echo "CACHE_KEY=$CACHE_KEY" >> $GITHUB_ENV
73+
env:
74+
CACHE_KEY: ${{ runner.os }}-py${{ env.PYVER }}-${{ hashFiles('helper/**') }}
5175

52-
- name: Check app versions
76+
- name: Cache helper
77+
id: cache-helper
78+
uses: actions/cache@v4
79+
with:
80+
path: |
81+
build/linux/helper
82+
assets/licenses/helper.json
83+
key: ${{ env.CACHE_KEY }}
84+
85+
- name: Build the Helper
86+
if: steps.cache-helper.outputs.cache-hit != 'true'
87+
working-directory: ./helper
5388
run: |
54-
python set-version.py
55-
git diff --exit-code
89+
apt-get update
90+
apt-get install -qq swig libpcsclite-dev build-essential
91+
pip install poetry
92+
poetry install
93+
poetry run pyinstaller authenticator-helper.spec
94+
find dist/helper -type f -exec chmod a-x {} +
95+
chmod a+x dist/helper/authenticator-helper
96+
mkdir -p ../build/linux
97+
mv dist/helper ../build/linux/
98+
poetry build
99+
python -m venv .venv
100+
.venv/bin/pip install --upgrade pip wheel
101+
.venv/bin/pip install dist/authenticator_helper-0.1.0-py3-none-any.whl pip-licenses
102+
mkdir licenses
103+
.venv/bin/pip-licenses --format=json --no-license-path --with-license-file --ignore-packages authenticator-helper zxing-cpp --output-file ../assets/licenses/helper.json
104+
105+
build-app:
106+
107+
needs: build-helper
108+
runs-on: ubuntu-latest
109+
container:
110+
image: ubuntu:20.04
111+
env:
112+
DEBIAN_FRONTEND: noninteractive
113+
114+
steps:
115+
116+
- name: Install git
117+
run: |
118+
apt-get update
119+
apt-get install -qq curl software-properties-common
120+
add-apt-repository -y ppa:git-core/ppa
121+
apt-get install -qq git
122+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
123+
124+
- uses: actions/checkout@v4
125+
126+
- name: Read variables from repo
127+
run: cat .github/workflows/env >> $GITHUB_ENV
56128

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

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

74142
- name: Install Flutter dependencies
75143
run: |
144+
apt-get update
145+
apt-get install -qq libnotify-dev libayatana-appindicator3-dev patchelf
76146
apt-get install -qq clang cmake ninja-build pkg-config libgtk-3-dev jq
77147
78148
- uses: subosito/flutter-action@v2
@@ -86,15 +156,6 @@ jobs:
86156
flutter config --enable-linux-desktop
87157
flutter --version
88158
89-
- name: Run lints/tests
90-
env:
91-
SKIP: ${{ steps.cache-helper.outputs.cache-hit == 'true' && 'mypy,flake8,black,bandit' || ''}}
92-
run: |
93-
export PATH=$PATH:$HOME/.local/bin # Needed to ensure pip/pre-commit on PATH
94-
pipx install pre-commit
95-
pre-commit run --all-files
96-
flutter test
97-
98159
- name: Build the app
99160
run: flutter build linux
100161

0 commit comments

Comments
 (0)