Skip to content

Update actions/checkout action to v7 #988

Update actions/checkout action to v7

Update actions/checkout action to v7 #988

Workflow file for this run

on:
push:
branches:
- "master"
- "renovate/**"
pull_request:
workflow_dispatch: # Always allow manual runs
jobs:
build_wheels:
runs-on: "ubuntu-24.04"
strategy:
fail-fast: false
matrix:
package: ["cadquery-ocp-novtk", "lib3mf"]
build_type: ["Release", "Debug"]
include: # Extends and overrides the matrix for specific configurations
- build_type: "Release"
cflags: "-O3"
cxxflags: "-O3"
ldflags: "-O3"
- build_type: "Debug"
cflags: "-Og -g"
cxxflags: "-Og -g"
ldflags: "-Og -g -gsource-map=inline"
- pyodide_args: ""
- package: "cadquery-ocp-novtk"
pyodide_args: "--exports=pyinit" # Avoids missing symbols due to custom emscripten exports
- package: "cadquery-ocp-novtk"
build_type: "Release"
ldflags: "-O1" # XXX: See repair_wasm.py invocation in CMakeLists.txt
- package: "cadquery-ocp-novtk"
build_type: "Debug"
ldflags: "-Og -g2 -gseparate-dwarf" # Smaller debug files, default is too big for CI. The usual g3 level also crashes CI.
steps:
- uses: "actions/checkout@v7"
with:
fetch-depth: 0 # Fetch all history for caching purposes
- id: "xbuildenv_data"
shell: bash
run: ".github/scripts/xbuildenv_data.sh"
- uses: "actions/setup-python@v6"
with:
python-version: "${{ steps.xbuildenv_data.outputs.python_version }}"
cache: "pip"
- name: "Download cached build artifact"
shell: bash
run: |
ARTIFACT_NAME="build-${{ matrix.package }}-${{ matrix.build_type }}"
try_download() {
local runs="$1" delete_old="$2"
for RUN in $runs; do
echo "Attempting download from run $RUN"
TMP=$(mktemp -d)
if gh run download "$RUN" --name "$ARTIFACT_NAME" --dir "$TMP" 2>/dev/null; then
mv "$TMP"/* "${{ matrix.package }}/" 2>/dev/null || true
echo "✓ Downloaded cache from run $RUN. Output directory contents:"
find "${{ matrix.package }}" -mindepth 1 -maxdepth 2
if [ "$delete_old" = 1 ]; then
for OLD_RUN in $runs; do
[ "$OLD_RUN" = "$RUN" ] && continue
gh api repos/${{ github.repository }}/actions/runs/$OLD_RUN/artifacts \
--jq '.artifacts[] | select(.name == "'"$ARTIFACT_NAME"'") | .id' |
xargs -r -I {} gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/{}
done
fi
rm -rf "$TMP"
return 0
fi
rm -rf "$TMP"
done
return 1
}
SAME_BRANCH_RUNS=$(gh run list \
--workflow="${{ github.workflow }}" \
--branch="${{ github.ref_name }}" \
--limit=50 \
--json databaseId \
-q '.[].databaseId')
try_download "$SAME_BRANCH_RUNS" 1 && exit 0
ALL_RUNS=$(gh run list \
--workflow="${{ github.workflow }}" \
--limit=50 \
--json databaseId \
-q '.[].databaseId')
try_download "$ALL_RUNS" 0 && exit 0
echo "::warning::No usable artifact found, continuing with fresh build..."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: sigoden/install-binary@v1
with:
repo: WebAssembly/binaryen
name: wasm-opt
- uses: hendrikmuhs/ccache-action@v1.2
- working-directory: "${{ matrix.package }}"
shell: bash
run: | # Install dependencies
pip install -r ../requirements.txt
pyodide xbuildenv install "${{ steps.xbuildenv_data.outputs.xbuildenv_version }}"
pip install $(python -c 'import tomllib; cfg = tomllib.load(open("pyproject.toml", "rb")); print(*cfg["build-system"]["requires"])')
git clone https://github.com/emscripten-core/emsdk emsdk-tmp
shopt -s dotglob
mkdir -p emsdk && mv emsdk-tmp/* emsdk && rm -rf emsdk-tmp
mkdir -p emsdk/upstream/emscripten/cache && find emsdk/upstream/emscripten/cache -type f -exec touch {} +
- working-directory: "${{ matrix.package }}"
shell: bash
run: |
cd emsdk && PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) && ./emsdk install ${PYODIDE_EMSCRIPTEN_VERSION} && ./emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION} && source emsdk_env.sh && cd ..
ccache --show-stats --evict-older-than 3d --zero-stats -vv && ccache --show-stats -vv
pyodide build ${{ matrix.pyodide_args }}
ccache --show-stats -vv
env:
SKBUILD_CMAKE_BUILD_TYPE: "${{ matrix.build_type }}"
CFLAGS: "${{ matrix.cflags }}"
CXXFLAGS: "${{ matrix.cxxflags }}"
LDFLAGS: "${{ matrix.ldflags }}"
#CMAKE_BUILD_PARALLEL_LEVEL: 2
_FORCE_OLD_SOURCES: "TRUE"
CCACHE_DIR: "${{ github.workspace }}/${{ matrix.package }}/ccache"
CCACHE_COMPILERCHECK: "content" # We are re-downloading the compiler on every run, so avoid timestamp-based checks that will always miss
timeout-minutes: 310
- working-directory: "${{ matrix.package }}"
shell: bash
run: |
pip install change-wheel-version
whl=(dist/*.whl)
if [ ${#whl[@]} -ne 1 ]; then
echo "Error: Expected exactly one wheel in dist/, found ${#whl[@]}" >&2
exit 1
fi
VERSION="$(basename "${whl[0]}" .whl | cut -d- -f2 | sed 's/\.post[0-9]*$//')"
TYPE="dev" # For debug wheels, use .dev suffix so they sort before release versions
if [ "${{ matrix.build_type }}" = "Release" ]; then
TYPE="post"
fi
change_wheel_version "${whl[0]}" \
--version "${VERSION}.${TYPE}$(date -u +%Y%m%d%H%M)" \
--delete-old-wheel
- if: "!cancelled()"
uses: "actions/upload-artifact@v7"
with:
name: "build-${{ matrix.package }}-${{ matrix.build_type }}"
include-hidden-files: true
path: |
${{ matrix.package }}/build
${{ matrix.package }}/emsdk/upstream/emscripten/cache
${{ matrix.package }}/ccache*
- uses: "actions/upload-artifact@v7"
with:
name: "wheel-${{ matrix.package }}-${{ matrix.build_type }}"
path: "${{ matrix.package }}/dist/*.whl"
test_build123d_integration:
needs: "build_wheels"
runs-on: "ubuntu-24.04"
steps:
- uses: "actions/checkout@v7"
- uses: "actions/download-artifact@v8"
with:
pattern: "wheel-*-Debug" # Debug wheels have better crash reporting, so we prefer them for testing
path: "_wheels"
merge-multiple: true
- id: "xbuildenv_data"
shell: bash
run: ".github/scripts/xbuildenv_data.sh"
- uses: "actions/setup-python@v6"
with:
python-version: "${{ steps.xbuildenv_data.outputs.python_version }}"
cache: "pip"
- working-directory: "build123d"
shell: bash
run: |
set -ex -o pipefail
# Install pyodide build environment
pip install -r ../requirements.txt
pyodide xbuildenv install "${{ steps.xbuildenv_data.outputs.xbuildenv_version }}"
pyodide venv .venv-pyodide
. .venv-pyodide/bin/activate
function run_tests() {
local branch="$1"
echo "Testing build123d branch: $branch"
# Reinitialize venv for each test to avoid version conflicts
type deactivate >/dev/null 2>&1 && deactivate
[ -f .venv-pyodide/bin/activate ] && rm -rf .venv-pyodide/
pyodide venv .venv-pyodide
. .venv-pyodide/bin/activate
# Install the just-built wheels. They WILL be used for the dev tests.
# If stable requests older versions, they will be installed on top of the dev wheels from PyPI, which is fine.
for whl in ../_wheels/*.whl; do
pip install "$whl"
done
# XXX: There is a bug causing async tests to stop at a random point,
# so retry until the output contains the proper completion statement or we give up (assume okay then)
local max_retries=50
local attempt=1
while [ $attempt -le $max_retries ]; do
FORCE_COLOR=1 python test.py "$branch" | tee -a "test-$branch.log"
if grep -q "All tests passed successfully!" "test-$branch.log"; then
echo "Tests finished successfully on attempt $attempt"
return
fi
echo "Retrying failed async completion ($attempt/$max_retries)"
attempt=$((attempt + 1))
done
echo "Warning: test completion marker missing after retries"
}
echo "### Running dev test"
run_tests dev
echo "### Running stable test"
run_tests stable
- uses: "actions/upload-artifact@v7"
if: "always()"
with:
name: "test-build123d-integration-log"
path: "build123d/test-*.log"
deploy_to_pypi:
needs:
- test_build123d_integration
runs-on: "ubuntu-24.04"
if: |
github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
environment: "publish"
strategy:
matrix:
package: ["cadquery-ocp-novtk", "lib3mf"]
steps:
- uses: "actions/download-artifact@v8"
with:
pattern: "wheel-${{ matrix.package }}-*" # Debug and Release wheels!
path: "dist"
merge-multiple: true
- name: "List wheels"
shell: bash
run: find dist -type f
- name: "Publish Release wheels to PyPI"
uses: "pypa/gh-action-pypi-publish@release/v1"
with:
packages-dir: "dist"