Skip to content

Commit e2e0f41

Browse files
committed
Improve provenance checking (gh)
1 parent b4072dd commit e2e0f41

3 files changed

Lines changed: 52 additions & 22 deletions

File tree

.github/workflows/wheel-builder.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ jobs:
240240
CIBW_ENVIRONMENT: >
241241
SKBUILD_CMAKE_ARGS='--preset conan-default;--log-level=VERBOSE;-DLUXCORE_VERSION=${{ steps.output-version.outputs.version }};-G Ninja Multi-Config'
242242
SKBUILD_CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
243+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
243244
CIBW_ENVIRONMENT_PASS_LINUX: |
244245
CC
245246
CXX
@@ -264,14 +265,25 @@ jobs:
264265
dnf install -y epel-release
265266
dnf install -y almalinux-release-devel
266267
dnf install -y ccache
267-
dnf install -y sudo # for gtk3...
268268
dnf install -y perl-IPC-Cmd perl-Digest-SHA
269269
270-
# Manylinux_2_34 compatibility
270+
# Install gh (via conda)
271+
dnf install -y wget
272+
mkdir -p miniconda3
273+
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda3/miniconda.sh
274+
bash miniconda3/miniconda.sh -b -u -p miniconda3
275+
rm miniconda3/miniconda.sh
276+
source miniconda3/bin/activate
277+
conda init --all
278+
conda install gh --channel conda-forge -y
279+
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
280+
281+
# Manylinux_2_34 compatibility (for future use)
271282
if [[ ${{ env.GLIBC_VERSION }} != 2_28 ]]; then
272283
dnf install -y perl-FindBin perl-lib
273284
fi
274285
286+
# Install dependencies
275287
pip install conan && make deps
276288
277289
CIBW_BEFORE_ALL_MACOS: |

cmake/make_deps.py

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import tempfile
99
from urllib.request import urlretrieve
10-
from urllib.parse import urlparse, urlsplit
10+
from urllib.parse import urlparse
1111
from pathlib import Path
1212
from zipfile import ZipFile
1313
import subprocess
@@ -18,11 +18,11 @@
1818
import platform
1919
import sys
2020
from functools import cache
21+
from dataclasses import dataclass
2122

2223

2324
CONAN_ALL_PACKAGES = '"*"'
2425

25-
OUTPUT_DIR = os.getenv("OUTPUT_DIR", "out")
2626

2727
logger = logging.getLogger("LuxCore Dependencies")
2828

@@ -36,7 +36,9 @@
3636
}
3737

3838

39+
@dataclass
3940
class Colors:
41+
"""Colors for terminal output."""
4042
HEADER = "\033[95m"
4143
OKBLUE = "\033[94m"
4244
OKCYAN = "\033[96m"
@@ -135,11 +137,22 @@ def download(url, destdir):
135137
# Check attestation
136138
logger.info("Checking '%s'", local_filename)
137139

138-
gh_app = shutil.which("gh")
139-
if not gh_app:
140-
logger.error(Colors.FAIL + "SIGNATURE CHECKING ERROR" + Colors.ENDC)
141-
msg = "Cannot find 'gh'application - Dependencies origin cannot be checked."
142-
logger.error(Colors.FAIL + msg + Colors.ENDC)
140+
if not (gh_app := shutil.which("gh")):
141+
msg = (
142+
Colors.WARNING,
143+
"SIGNATURE CHECKING ERROR",
144+
Colors.ENDC,
145+
)
146+
msg = "".join(msg)
147+
logger.warning(msg)
148+
msg = (
149+
Colors.WARNING,
150+
"Cannot find 'gh'application - ",
151+
"Dependencies origin cannot be checked.",
152+
Colors.ENDC,
153+
)
154+
msg = ''.join(msg)
155+
logger.warning(msg)
143156
else:
144157
gh_cmd = [
145158
gh_app,
@@ -153,11 +166,13 @@ def download(url, destdir):
153166
try:
154167
gh_output = subprocess.check_output(gh_cmd, text=True)
155168
except subprocess.CalledProcessError as err:
156-
logger.error(Colors.FAIL + "SIGNATURE CHECKING ERROR" + Colors.ENDC)
157-
logger.error("gh return code: %s", err.returncode)
158-
logger.error(err.output)
169+
msg = f"{Colors.WARNING}SIGNATURE CHECKING ERROR{Colors.ENDC}"
170+
logger.warning(msg)
171+
logger.warning("gh return code: %s", err.returncode)
172+
logger.warning(err.output)
159173
else:
160-
logger.info(Colors.OKGREEN + "'%s': found certificate - OK" + Colors.ENDC, filename)
174+
msg = f"{Colors.OKGREEN}'%s': found certificate - OK{Colors.ENDC}"
175+
logger.info(msg, filename)
161176
signature, *_ = json.loads(gh_output)
162177
certificate = signature["verificationResult"]["signature"]["certificate"]
163178
logger.debug(json.dumps(certificate, indent=2))
@@ -201,18 +216,19 @@ def copy_conf(dest):
201216

202217
def main(call_args=None):
203218
"""Entry point."""
204-
global OUTPUT_DIR
219+
output_dir = os.getenv("output_dir", "out")
205220

206221
# Set-up logger
207222
logger.setLevel(logging.INFO)
208223
logging.basicConfig(level=logging.INFO)
209-
logger.info(Colors.OKBLUE + "BEGIN" + Colors.ENDC)
224+
msg = f"{Colors.OKBLUE}BEGIN{Colors.ENDC}"
225+
logger.info(msg)
210226

211227
# Get settings
212228
logger.info("Reading settings")
213229
with open("luxcore.json", encoding="utf-8") as f:
214230
settings = json.load(f)
215-
logger.info("Output directory: %s", OUTPUT_DIR)
231+
logger.info("Output directory: %s", output_dir)
216232

217233
# Get optional command-line parameters
218234
# Nota: --local option is used by LuxCoreDeps CI
@@ -248,7 +264,7 @@ def main(call_args=None):
248264
if args.verbose:
249265
logger.setLevel(logging.DEBUG)
250266
if args.output:
251-
OUTPUT_DIR = args.output
267+
output_dir = args.output
252268

253269
# Process
254270
with tempfile.TemporaryDirectory() as tmpdir:
@@ -315,24 +331,25 @@ def main(call_args=None):
315331
"--build=missing",
316332
f"--profile:all={get_profile_name()}",
317333
"--deployer=full_deploy",
318-
f"--deployer-folder={OUTPUT_DIR}/dependencies",
319-
f"--output-folder={OUTPUT_DIR}",
334+
f"--deployer-folder={output_dir}/dependencies",
335+
f"--output-folder={output_dir}",
320336
"--settings=build_type=Release",
321337
"--conf:all=tools.cmake.cmaketoolchain:generator=Ninja Multi-Config",
322338
]
323339
build_types = ["Debug", "Release"]
324340
if args.extended:
325341
build_types += ["RelWithDebInfo", "MinSizeRel"]
326342
for build_type in build_types:
327-
logger.info(f"Generating '{build_type}'")
343+
logger.info("Generating '%s'", build_type)
328344
end_block = [f"--settings=&:build_type={build_type}", "."]
329345
run_conan(main_block + end_block)
330346

331347
# Show presets
332-
subprocess.run(["cmake", "--list-presets=build"])
348+
subprocess.run(["cmake", "--list-presets=build"], check=False)
333349
print("", flush=True)
334350

335-
logger.info(Colors.OKBLUE + "END" + Colors.ENDC)
351+
msg = Colors.OKBLUE + "END" + Colors.ENDC
352+
logger.info(msg)
336353

337354

338355
if __name__ == "__main__":

utils/debug_wheels.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
python_version_minor=$(python -c 'import sys; print(sys.version_info[1])')
1414

1515
act workflow_dispatch \
16+
--pull \
1617
--action-offline-mode \
1718
--workflows ".github/workflows/wheel-builder.yml" \
1819
-s GITHUB_TOKEN="$(gh auth token)" \

0 commit comments

Comments
 (0)