From 905d5d09e70f35140e1d8c764e319039526ab182 Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Fri, 24 Feb 2023 11:37:08 +0000 Subject: [PATCH 1/2] python: Use xapi's versioning scheme for XenAPI package This allows us to do releases much more frequently as pipy's policy is to have immutable packages. It also simplifies the build process quite a bit, which is neat. The current method of building allows to build the package under git and when git information is not available, using the same mechanism as xapi. (using XAPI_VERSION if it's set, with a fallback on git, or failing miserably) This is not enough to be able to buuld it in a .spec environmtent because the version schemas generated for the spec file conflict with the allowed versions of python packages. e.g. koji generates 23.5.0.19.g3657e16cb python rejects it, it would accept 23.5.0.19+g3657e16cb the autogenerated equivalent generated by python would be 23.5.0.dev19+g3657e16cb This changeset is not meant to resolve this conflict, as the current solution is good enough for its main use-case: generating a release using github actions Signed-off-by: Pau Ruiz Safont --- .github/workflows/draft-release.yml | 41 ++++---------------------- quality-gate.sh | 2 +- scripts/examples/python/Makefile | 13 ++++---- scripts/examples/python/dune | 10 ------- scripts/examples/python/pyproject.toml | 7 +++-- scripts/examples/python/setuppy_gen.ml | 7 ----- 6 files changed, 17 insertions(+), 63 deletions(-) delete mode 100644 scripts/examples/python/dune delete mode 100644 scripts/examples/python/setuppy_gen.ml diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 42ed76565c2..c5d224ea3b2 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -15,49 +15,20 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Pull configuration from xs-opam - run: | - curl --fail --silent https://raw.githubusercontent.com/xapi-project/xs-opam/master/tools/xs-opam-ci.env | cut -f2 -d " " > .env - - - name: Load environment file - id: dotenv - uses: falti/dotenv-action@v1.0.2 - - - name: Use python + - name: Use python uses: actions/setup-python@v4 with: python-version: '3.x' - - name: Retrieve date for cache key - id: cache-key - run: echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" - shell: bash - - - name: Restore opam cache - id: opam-cache - uses: actions/cache@v3 - with: - path: "~/.opam" - # invalidate cache daily, gets built daily using a scheduled job - key: ${{ steps.cache-key.outputs.date }} - - - name: Use ocaml - uses: ocaml/setup-ocaml@v1 - with: - ocaml-version: ${{ steps.dotenv.outputs.ocaml_version_full }} - opam-repository: ${{ steps.dotenv.outputs.repository }} - - - name: Install dependencies + - name: Install build dependencies run: | - opam update - opam pin add xapi-datamodel . --no-action - opam upgrade - opam install xapi-stdext-unix xapi-datamodel + pip install build + sudo apt-get install ocaml dune libfindlib-ocaml-dev libdune-ocaml-dev libcmdliner-ocaml-dev - name: Generate python package for XenAPI run: | - opam exec -- ./configure - opam exec -- make python + ./configure --xapi-version=${{ github.ref_name }} + make python - name: Draft Release ${{ github.ref_name }} id: create_release diff --git a/quality-gate.sh b/quality-gate.sh index 559a0884cc3..c42d718cbf8 100755 --- a/quality-gate.sh +++ b/quality-gate.sh @@ -25,7 +25,7 @@ verify-cert () { } mli-files () { - N=510 + N=509 # do not count ml files from the tests in ocaml/{tests/perftest/quicktest} MLIS=$(git ls-files -- '**/*.mli' | grep -vE "ocaml/tests|ocaml/perftest|ocaml/quicktest" | xargs -I {} sh -c "echo {} | cut -f 1 -d '.'" \;) MLS=$(git ls-files -- '**/*.ml' | grep -vE "ocaml/tests|ocaml/perftest|ocaml/quicktest" | xargs -I {} sh -c "echo {} | cut -f 1 -d '.'" \;) diff --git a/scripts/examples/python/Makefile b/scripts/examples/python/Makefile index 03d8d70cb6f..251f747250d 100644 --- a/scripts/examples/python/Makefile +++ b/scripts/examples/python/Makefile @@ -1,15 +1,12 @@ PROFILE=release +SETUPTOOLS_SCM_PRETEND_VERSION ?= "" .PHONY: build clean -build: setup.py - pip wheel -w dist --no-deps . - python setup.py sdist - -setup.py: - dune build --profile=$(PROFILE) ./setuppy_gen.exe - dune exec --profile=$(PROFILE) -- ./setuppy_gen.exe +build: + SETUPTOOLS_SCM_PRETEND_VERSION=$(XAPI_VERSION) python -m build --wheel . + SETUPTOOLS_SCM_PRETEND_VERSION=$(XAPI_VERSION) python -m build --sdist . clean: dune clean - rm -rf setup.py dist/ build/ XenAPI.egg-info/ + rm -rf dist/ build/ XenAPI.egg-info/ diff --git a/scripts/examples/python/dune b/scripts/examples/python/dune deleted file mode 100644 index d764aa66a66..00000000000 --- a/scripts/examples/python/dune +++ /dev/null @@ -1,10 +0,0 @@ -(executable - (modes byte exe) - (name setuppy_gen) - (libraries - dune-build-info - xapi-stdext-unix - xapi-datamodel - ) -) - diff --git a/scripts/examples/python/pyproject.toml b/scripts/examples/python/pyproject.toml index 4e50ea74011..f556f2539ab 100644 --- a/scripts/examples/python/pyproject.toml +++ b/scripts/examples/python/pyproject.toml @@ -1,3 +1,6 @@ [build-system] -requires = ["setuptools >= 38.6.0", "wheel"] -build-backend = "setuptools.build_meta:__legacy__" +requires = ["setuptools >= 38.6.0", "setuptools_scm[toml]", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +root = "../../.." diff --git a/scripts/examples/python/setuppy_gen.ml b/scripts/examples/python/setuppy_gen.ml deleted file mode 100644 index aa73befb3ac..00000000000 --- a/scripts/examples/python/setuppy_gen.ml +++ /dev/null @@ -1,7 +0,0 @@ -let filename = Filename.concat "." "setup.py" - -let setuppy = - Printf.sprintf "from setuptools import setup\n\nsetup(version='%s')\n" - Datamodel_common.api_version_string - -let () = Xapi_stdext_unix.Unixext.write_string_to_file filename setuppy From 0809d25a8b7e246ab7faa265c51ab5f322260f06 Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Fri, 24 Feb 2023 12:43:28 +0000 Subject: [PATCH 2/2] ci: use official gh cli for release workflow This is to avoid using unmaintained actions and instead use official tooling Signed-off-by: Pau Ruiz Safont --- .github/workflows/draft-release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index c5d224ea3b2..45abab99bbb 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -31,11 +31,11 @@ jobs: make python - name: Draft Release ${{ github.ref_name }} - id: create_release - uses: softprops/action-gh-release@v1 - with: - files: | - scripts/examples/python/dist/* - fail_on_unmatched_files: true - draft: true - generate_release_notes: true + run: gh release create ${{ github.ref_name }} --draft --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload artifacts + run: gh release upload ${{ github.ref_name }} scripts/examples/python/dist/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}