ci: automate fork updates and wheel validation
VSG fork CI A VSG fork check failed.
MadGobblins/vhdl-style-guide/pipeline/head There was a failure building this commit
Details
VSG fork CI A VSG fork check failed.
MadGobblins/vhdl-style-guide/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
0270900c47
commit
e39afd28a0
|
|
@ -18,6 +18,11 @@ release_notes.txt
|
|||
# IDE files
|
||||
.idea/
|
||||
.vscode/
|
||||
.venv/
|
||||
.uv-cache/
|
||||
.uv-python/
|
||||
.ci-*/
|
||||
.package-build/
|
||||
|
||||
# Ignore external repos used for tests
|
||||
tests/external_repos/repos
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
// Add the Gitea webhook configured for this Jenkins installation.
|
||||
|
||||
pipeline {
|
||||
agent { label 'rust_no_docker' }
|
||||
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
skipDefaultCheckout(true)
|
||||
}
|
||||
|
||||
environment {
|
||||
PYTHONUNBUFFERED = '1'
|
||||
UV_CACHE_DIR = "${WORKSPACE}/.uv-cache"
|
||||
UV_PYTHON_INSTALL_DIR = "${WORKSPACE}/.uv-python"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
deleteDir()
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Set up development environment') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
command -v uv >/dev/null 2>&1 || {
|
||||
echo "ERROR: uv is required on the Jenkins worker." >&2
|
||||
exit 1
|
||||
}
|
||||
uv --version
|
||||
uv venv --python 3.12 .venv
|
||||
uv pip install --python .venv/bin/python -e '.[tests,dev]'
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Style') {
|
||||
steps {
|
||||
sh 'uv run --no-sync pre-commit run --all-files'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Tests') {
|
||||
steps {
|
||||
sh 'uv run --no-sync python -m unittest'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build package') {
|
||||
steps {
|
||||
sh './build-package.sh'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Wheel install with pip') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
wheel="$(find dist -maxdepth 1 -type f -name 'vsg-*.whl' -print -quit)"
|
||||
test -n "${wheel}" || {
|
||||
echo "ERROR: built wheel was not found." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
python3 -m venv .ci-pip-venv
|
||||
.ci-pip-venv/bin/python -m pip install "${wheel}"
|
||||
|
||||
output="$(
|
||||
printf 'entity smoke is\nend entity smoke;\n' |
|
||||
.ci-pip-venv/bin/vsg --stdin --stdout --fix --style jcl --no-failure
|
||||
)"
|
||||
printf '%s\n' "${output}" | grep -F 'entity SMOKE is'
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Wheel install with uv') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
wheel="$(find dist -maxdepth 1 -type f -name 'vsg-*.whl' -print -quit)"
|
||||
test -n "${wheel}" || {
|
||||
echo "ERROR: built wheel was not found." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
uv venv --python 3.12 .ci-uv-venv
|
||||
uv pip install --python .ci-uv-venv/bin/python "${wheel}"
|
||||
|
||||
output="$(
|
||||
printf 'entity smoke is\nend entity smoke;\n' |
|
||||
.ci-uv-venv/bin/vsg --stdin --stdout --fix --style jcl --no-failure
|
||||
)"
|
||||
printf '%s\n' "${output}" | grep -F 'entity SMOKE is'
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Archive package') {
|
||||
steps {
|
||||
archiveArtifacts artifacts: 'dist/*', fingerprint: true, onlyIfSuccessful: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
publishChecks(
|
||||
conclusion: 'SUCCESS',
|
||||
name: 'VSG fork CI',
|
||||
summary: 'VSG tests and package installation checks passed.',
|
||||
text: 'The wheel was tested through both pip and uv, including stdin/stdout formatting.',
|
||||
title: 'Build Successful'
|
||||
)
|
||||
}
|
||||
failure {
|
||||
publishChecks(
|
||||
conclusion: 'FAILURE',
|
||||
name: 'VSG fork CI',
|
||||
summary: 'A VSG fork check failed.',
|
||||
text: 'Review the Jenkins log for style, tests, build, or wheel installation failures.',
|
||||
title: 'Build Failed'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
32
README.rst
32
README.rst
|
|
@ -148,6 +148,38 @@ Build locally, artifacts will appear in ``dist`` directory.
|
|||
|
||||
tox
|
||||
|
||||
Fork installation and packaging
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This fork adds ``--stdout`` for stream-based formatting and ``--no-failure``
|
||||
for editor integrations. Install the current fork directly with uv:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
uv venv
|
||||
uv pip install "git+https://proxy.dandaedre.com/gitea/Dandaedre/vhdl-style-guide.git"
|
||||
|
||||
To build an installable wheel and source distribution locally:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
./build-package.sh
|
||||
uv pip install dist/vsg-*.whl
|
||||
|
||||
After those artifacts are published to the Dandaedre Gitea package registry,
|
||||
they can instead be installed with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
uv pip install --index https://proxy.dandaedre.com/gitea/api/packages/Dandaedre/pypi/simple/ vsg
|
||||
|
||||
The additional Gitea index is checked first for ``vsg`` while PyPI remains
|
||||
available for dependencies such as PyYAML.
|
||||
|
||||
Use ``./update-fork.sh`` to fetch upstream tags and rebase the small fork patch
|
||||
series onto the latest upstream ``master``. The script requires a clean
|
||||
worktree and automatically aborts a failed rebase.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel 2>/dev/null)" || {
|
||||
echo "ERROR: build-package.sh must run inside a Git worktree." >&2
|
||||
exit 1
|
||||
}
|
||||
cd "${repo_root}"
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "ERROR: uv is required to build the package." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x .venv/bin/python ]; then
|
||||
echo "Creating the required local virtual environment..."
|
||||
uv venv --python 3.12 .venv
|
||||
fi
|
||||
|
||||
readonly build_dir=".package-build"
|
||||
if [ -e "${build_dir}" ]; then
|
||||
rm -rf -- "${build_dir}"
|
||||
fi
|
||||
|
||||
echo "Building the source distribution and wheel..."
|
||||
uv build --no-sources --out-dir "${build_dir}"
|
||||
|
||||
shopt -s nullglob
|
||||
artifacts=("${build_dir}"/vsg-*.tar.gz "${build_dir}"/vsg-*.whl)
|
||||
if [ "${#artifacts[@]}" -lt 2 ]; then
|
||||
echo "ERROR: uv build completed without producing both expected package formats." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p dist
|
||||
built_artifacts=()
|
||||
for artifact in "${artifacts[@]}"; do
|
||||
destination="dist/${artifact##*/}"
|
||||
cp -- "${artifact}" "${destination}"
|
||||
built_artifacts+=("${destination}")
|
||||
done
|
||||
rm -rf -- "${build_dir}"
|
||||
|
||||
echo "Built package artifacts:"
|
||||
printf ' %s\n' "${built_artifacts[@]}"
|
||||
echo
|
||||
echo "Install the wheel into a uv environment with:"
|
||||
printf ' uv pip install %q\n' "${built_artifacts[-1]}"
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
readonly upstream_url="${1:-https://github.com/jeremiah-c-leary/vhdl-style-guide.git}"
|
||||
readonly upstream_branch="${2:-master}"
|
||||
readonly upstream_ref="refs/remotes/upstream/${upstream_branch}"
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel 2>/dev/null)" || {
|
||||
echo "ERROR: update-fork.sh must run inside a Git worktree." >&2
|
||||
exit 1
|
||||
}
|
||||
cd "${repo_root}"
|
||||
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "ERROR: refusing to rebase a dirty worktree." >&2
|
||||
git status --short >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$(git symbolic-ref --quiet --short HEAD)" ]; then
|
||||
echo "ERROR: refusing to rebase a detached HEAD." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
abort_rebase() {
|
||||
exit_status=$?
|
||||
trap - EXIT HUP INT TERM
|
||||
|
||||
if git rev-parse --verify --quiet REBASE_HEAD >/dev/null; then
|
||||
echo "ERROR: upstream rebase failed; aborting it now." >&2
|
||||
if ! git rebase --abort; then
|
||||
echo "FATAL: git rebase --abort also failed; manual recovery is required." >&2
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
echo "ERROR: fork update failed before a rebase was started." >&2
|
||||
fi
|
||||
|
||||
exit "${exit_status}"
|
||||
}
|
||||
trap abort_rebase EXIT HUP INT TERM
|
||||
|
||||
echo "Fetching ${upstream_branch} and release tags from ${upstream_url}..."
|
||||
git fetch --tags "${upstream_url}" "${upstream_branch}:${upstream_ref}"
|
||||
|
||||
upstream_commit="$(git rev-parse "${upstream_ref}")"
|
||||
echo "Rebasing fork commits onto ${upstream_commit}..."
|
||||
git rebase "${upstream_commit}"
|
||||
|
||||
trap - EXIT HUP INT TERM
|
||||
echo "Fork update completed successfully."
|
||||
Loading…
Reference in New Issue