From c9a89172819a46f0de64000f93ae9ef03df8ecbb Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Mon, 15 Jun 2026 17:10:27 +0300 Subject: [PATCH] bugfix: cryptic error when version hash argument is missing - ciel.click_common.VersionArgument.process_value: click.MissingParameter now raised if the version is not specified and no tool metadata files are available - constrain click to <8.5, just in case - add testing to ensure download function in CI works while I'm at it --- .github/scripts/gh.py | 2 - .github/workflows/ci.yml | 87 +++++++++++++++++++++++++++++++--------- ciel/click_common.py | 7 +++- poetry.lock | 4 +- pyproject.toml | 4 +- 5 files changed, 77 insertions(+), 27 deletions(-) diff --git a/.github/scripts/gh.py b/.github/scripts/gh.py index 34948a3..f8c1416 100644 --- a/.github/scripts/gh.py +++ b/.github/scripts/gh.py @@ -108,7 +108,6 @@ def git_command(*args): branch = git_command("branch", "--show-current") os.environ["REPO_URL"] = repo_url - os.environ["BRANCH_NAME"] = branch os.environ["GITHUB_WORKSPACE"] = git_directory os.environ["GITHUB_EVENT_NAME"] = "workspace_dispatch" os.environ["GITHUB_RUN_ID"] = "mock_gha_run" @@ -127,7 +126,6 @@ def export_env_alt(key, value): **{ "run_id": os.getenv("GITHUB_RUN_ID"), "origin": origin, - "branch": os.getenv("BRANCH_NAME"), "root": os.getenv("GITHUB_WORKSPACE"), "pdk": os.getenv("PDK_ROOT"), "tool": os.getenv("TOOL"), diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09ef23a..faea086 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,53 +8,102 @@ on: pull_request: jobs: - lint_python: + lint: name: Lint Python Code runs-on: ubuntu-24.04 steps: - name: Check out Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install Linters run: make venv - name: Lint run: make lint - push_to_pypi: - name: Build (and publish, if applicable) + build: + name: Build runs-on: ubuntu-24.04 - needs: lint_python - environment: pypi - permissions: - # IMPORTANT: this permission is mandatory for Trusted Publishing - id-token: write + needs: lint + steps: + - name: Check Git repository + uses: actions/checkout@v6 + - name: Set Up Python + uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Build Distribution + run: | + make dist + - uses: actions/upload-artifact@v7 + with: + name: wheel + path: ./dist + test: + name: Test + runs-on: ubuntu-24.04 + needs: build + steps: + - name: Set Up Python + uses: actions/setup-python@v4 + with: + python-version: "3.8" + - uses: actions/download-artifact@v8 + with: + name: wheel + path: ./dist + - name: Install Ciel, jq + run: | + sudo apt-get install -y jq + pip3 install ./dist/ciel-*.whl + - name: Ensure PDK downloads work + shell: bash + run: | + for pdk in $(python3 -m ciel ls-pdks | jq -r 'keys[]' | tr '\n' ' '); do + version="$(python3 -m ciel ls-remote --pdk $pdk | head -n1)" + python3 -m ciel fetch --pdk $pdk $version + python3 -m ciel prune --pdk $pdk --yes + done + check_new_version: + name: Check for new version in pyproject.toml + runs-on: ubuntu-24.04 + if: github.event == 'push' && github.ref_name == 'main' steps: - name: Check out Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Export Repo URL run: echo "REPO_URL=https://github.com/${{ github.repository }}" >> $GITHUB_ENV - - name: Export Branch Name - run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Set Up Python uses: actions/setup-python@v4 with: python-version: "3.8" - - name: Build Distribution - run: | - make dist - name: Set default for env.NEW_TAG run: echo "NEW_TAG=NO_NEW_TAG" >> $GITHUB_ENV - name: Check for new version - if: ${{ env.BRANCH_NAME == 'main' }} run: | make venv cd ${GITHUB_WORKSPACE}/ && ./venv/bin/python3 .github/scripts/generate_tag.py + - id: new_tag + name: Set new tag as job output + run: | + echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT + publish: + name: Publish + runs-on: ubuntu-24.04 + needs: [lint, build, test, check_new_version] + if: needs.check_new_version.steps.new_tag.outputs.new_tag != 'NO_NEW_TAG' + environment: pypi + permissions: + # IMPORTANT: this permission is mandatory for Trusted Publishing + id-token: write + steps: + - uses: actions/download-artifact@v8 + with: + name: wheel + path: ./dist - name: Tag Commit - if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }} uses: tvdias/github-tagger@v0.0.1 with: - tag: "${{ env.NEW_TAG }}" + tag: "${{ needs.check_new_version.steps.new_tag.outputs.new_tag }}" repo-token: "${{ secrets.BOT_TOKEN }}" - name: Publish - if: ${{ env.NEW_TAG != 'NO_NEW_TAG' }} uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/ciel/click_common.py b/ciel/click_common.py index 9b83560..ea5a20b 100644 --- a/ciel/click_common.py +++ b/ciel/click_common.py @@ -32,7 +32,7 @@ class VersionArgument(click.Argument): def make_metavar(self, ctx: Optional[click.Context] = None): - return "" + return "" def set_tool_metadata_file_path( self, @@ -53,7 +53,10 @@ def process_value(self, ctx, value): del ctx.params["tool_metadata_file_path"] resolved = resolve_version(value, tool_metadata_file_path) except FileNotFoundError: - resolved = None + raise click.MissingParameter( + ctx=ctx, + param=self, + ) return super().process_value(ctx, resolved) diff --git a/poetry.lock b/poetry.lock index 4ff97f0..b6a7343 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.4.1 and should not be changed by hand. [[package]] name = "anyio" @@ -829,4 +829,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.1" python-versions = ">=3.8" -content-hash = "7ba3f9fa95aca669b667b7fb85a7ae5356e05900c25facdf6b747cf362a98b1e" +content-hash = "355a10911f2f95bb02ab81b75e808b5718a6a3a3a16a0a2c5da54b140139871e" diff --git a/pyproject.toml b/pyproject.toml index 9ca51ff..0694423 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ciel" -version = "2.5.0" +version = "2.5.1" description = "An PDK builder/version manager for PDKs in the open_pdks format" authors = ["Mohamed Gaber ", "Efabless Corporation"] readme = "Readme.md" @@ -16,7 +16,7 @@ classifiers = [ [tool.poetry.dependencies] python = ">=3.8" -click = ">=8,<9" +click = ">=8,<8.5" pyyaml = ">=5,<7" rich = ">=12,<15" httpx = ">=0.22.0,<0.29"