Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Move build configuration from setup.py to pyproject.toml; apply various repo/CI refactors #602

Merged
merged 7 commits into from
Apr 26, 2024

Conversation

lgarber-akamai
Copy link
Contributor

@lgarber-akamai lgarber-akamai commented Apr 23, 2024

📝 Description

This change makes the following build system improvements to the Linode CLI:

  • Moving away from setup.py in favor of setuptools in pyproject.toml
  • Moving away from the baked_version construct in favor of injecting the version into a new version.py file.
  • Removing requirements.txt and requirements-dev.txt in favor of pyproject.toml
  • Removing the logic to automatically bake and install bash completions to /etc/bash_completion.d
    • This was discussed internally as a team
  • Removing the Jenkinsfile (no longer used)
  • Updating GHA workflows and Dockerfiles accordingly
  • Updating the OCI publish workflow to not rely on the version script (which was previously removed)

✔️ How to Test

The following test steps assume you have pulled down this PR locally.

Testing Workflows

For convenience I tested all workflows on the main branch of my fork; they can be viewed here:

Testing the Build & Install Process

  1. Run the following command to build & install the CLI:
make install
  1. Ensure the CLI has installed successfully and the installed version matches v0.0.0.dev:
linode-cli --version

# linode-cli 0.0.0.dev0
# Built from spec version 4.174.0
  1. Install the CLI with an overridden version:
LINODE_CLI_VERSION=1.2.3 make install
  1. Ensure the CLI has installed correctly and the installed version matches v0.0.0.dev:
linode-cli --version

# linode-cli 1.2.3
# Built from spec version 4.174.0

Testing the Dockerfile Changes

  1. Create a read-only GitHub Personal Access Token and export it under the GITHUB_TOKEN environment variable.

  2. Run the following command to build the CLI OCI image:

docker build -t local-linode-cli --build-arg linode_cli_version=1.2.3 --build-arg github_token=$GITHUB_TOKEN .
  1. Attempt to execute a CLI command, for example:
docker run --rm -it -e LINODE_CLI_TOKEN=$LINODE_TOKEN local-linode-cli linodes ls
  1. Ensure the command runs as expected.

Unit Testing

make testunit

Integration Testing

make testint

@lgarber-akamai lgarber-akamai added the improvement for improvements in existing functionality in the changelog. label Apr 23, 2024
@@ -112,7 +109,7 @@ def main(): # pylint: disable=too-many-branches,too-many-statements
if not parsed.command:
# print version info and exit - but only if no command was given
print(f"linode-cli {VERSION}")
print(f"Built off spec version {cli.spec_version}")
print(f"Built from spec version {cli.spec_version}")
Copy link
Contributor Author

@lgarber-akamai lgarber-akamai Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really relevant to the rest of these changes but I think this wording is a tiny bit less awkward 🙂

VERSION = version("linode-cli")
except:
VERSION = "building"
VERSION = __version__
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be much more reliable than grabbing the version from the package itself.

@@ -34,13 +34,18 @@ jobs:
# This is necessary as we want to ensure that version tags
# are properly formatted before passing them into the
# DockerFile.
- name: Get CLI version
Copy link
Contributor Author

@lgarber-akamai lgarber-akamai Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly have no clue how this worked in the last release given we removed the version script beforehand. Regardless, I moved it over to a more reliable solution 🙂

@@ -2,6 +2,51 @@
requires = ["setuptools", "wheel", "packaging"]
build-backend = "setuptools.build_meta"

[project]
name = "linode-cli"
authors = [{ name = "Akamai Technologies Inc.", email = "developers@linode.com" }]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note, I swapped this from Linode to Akamai Technologies Inc.

@lgarber-akamai lgarber-akamai marked this pull request as ready for review April 23, 2024 17:47
@lgarber-akamai lgarber-akamai requested a review from a team as a code owner April 23, 2024 17:47
@lgarber-akamai lgarber-akamai requested review from ykim-akamai and yec-akamai and removed request for a team April 23, 2024 17:47
@lgarber-akamai lgarber-akamai changed the title ref: Move build configuration from setup.py to pyproject.toml; drop Jenkinsfile and requirements.txt ref: Move build configuration from setup.py to pyproject.toml; apply various repo/CI refactors Apr 23, 2024
@lgarber-akamai lgarber-akamai added repo-ci-improvement for improvements in the repository or CI workflow in the changelog. and removed improvement for improvements in existing functionality in the changelog. labels Apr 23, 2024
Makefile Outdated Show resolved Hide resolved
Copy link
Member

@zliang-akamai zliang-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! The code base is much cleaner now. 🎉

Copy link
Contributor

@ykim-akamai ykim-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactor! LGTM

@lgarber-akamai lgarber-akamai merged commit f41b131 into linode:dev Apr 26, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repo-ci-improvement for improvements in the repository or CI workflow in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants