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

d2x package source, reworked #58

Merged
merged 66 commits into from
Nov 1, 2024

Conversation

jlantz
Copy link
Contributor

@jlantz jlantz commented Nov 1, 2024

No description provided.

jlantz added 30 commits October 29, 2024 10:54
…rets and import models from `d2x/auth/sf/models.py`

* **Refactor**: Remove data structures and import them from `d2x/auth/sf/models.py`
* **Environment Variables**: Update token exchange logic to use environment variables for secrets

Add test cases for `d2x/auth/sf/auth_url.py` and `d2x/auth/sf/login_url.py`

* **Test Cases**: Add test cases for token exchange and authentication flow in `tests/test_auth_url.py` and `tests/test_login_url.py`

Add a workflow to run tests on push and pull request

* **GitHub Actions**: Add `.github/workflows/test.yml` to run tests on push and pull request
* **pyproject.toml**
  - Add `requests` dependency with version "^2.28.1"
  - Ensure the project builds using poetry

* **requirements.txt**
  - Add `requests` dependency with version "2.28.1"
* **`pyproject.toml`**
  - Add necessary dependencies for the project using poetry
  - Ensure the project builds using poetry

* **`requirements_dev.in`**
  - Add a requirements_dev.in file for development dependencies
  - Include pytest as a development dependency
* **Dependencies**
  - Add `rich`, `pydantic`, `cookiecutter`, and `requests` to production dependencies.
  - Add `pytest` to development dependencies.

* **Pip-compile**
  - Configure pip-compile to generate hashes and manage requirements.

Update `.github/workflows/test.yml` to install development dependencies

* Change the installation command to use `requirements_dev.txt`.

Update `requirements.txt` to include pip-compile instructions

* Add comments for pip-compile usage.
* List production dependencies.
* **.github/workflows/test.yml**
  - Correct pip install command to install both requirements and the local checked out package.

* **requirements_dev.in**
  - Add `-e .` to install the local package in development mode.
* Install poetry and use it to install dependencies
* Ensure pip installs the local package in editable mode
* **pyproject.toml**
  - Remove old requirements and add poetry configuration
  - Add generate-hashes and requirements for production and development

* **.github/workflows/test.yml**
  - Change dependency installation to use requirements.txt and requirements_dev.txt
  - Remove poetry installation and usage
* Install poetry and use it to install dependencies
* Remove pip install commands for requirements.txt and requirements_dev.txt
* **Pydantic Core**:
  - Update version to 2.23.4
  - Update hash values for various platforms
* **Poetry**:
  - Update version to 1.8.4
* Change Python version to 3.10
* Add caching for Poetry and pip dependencies using actions/cache@v2
jlantz added 27 commits October 30, 2024 18:26
* **d2x/auth/sf/login_url.py**
  - Add import for `get_environment_variable` from `d2x.api.gh`.

* **tests/test_auth_url.py**
  - Add import for `json` module.
…nction in `d2x/auth/sf/auth_url.py`

* Add a check for `debug_info` being not None before setting the error message in the exception block
* Add functions to set and get environment variables and secrets in `d2x/api/gh.py`
…Hub Environments

* **Environment Variables**
  - Implement `set_environment_variable` to set a variable in a GitHub Environment
  - Implement `get_environment_variable` to get a variable from a GitHub Environment

* **Environment Secrets**
  - Implement `set_environment_secret` to set a secret in a GitHub Environment
  - Implement `get_environment_secret` to get a secret from a GitHub Environment
* **Get GitHub Access Token**: Retrieve GitHub Access Token from the specified environment and store it in the GitHub environment variable.
* **Delete Org Session**: Delete the org session from the specified environment using the retrieved GitHub Access Token.
* **Add Job Summary**: Add a job summary to the GitHub step summary, including the environment name and status of the org session deletion.
Refactor `d2x.gen` and `d2x.parse` functions into Pydantic models and update all callers.

* **Add Pydantic Models:**
  - Add `LoginUrlModel` to `d2x/models/sf/auth.py` to replace `get_login_url_and_token` function.
  - Add `SfdxAuthUrlModel` to `d2x/models/sf/auth.py` to replace `parse_sfdx_auth_url` function.

* **Update Callers:**
  - Update `d2x/auth/sf/auth_url.py` to use `SfdxAuthUrlModel` for parsing SFDX auth URL.
  - Update `d2x/auth/sf/login_url.py` to use `LoginUrlModel` for generating login URL.
  - Update `d2x/cli/main.py` to import `LoginUrlModel` and `SfdxAuthUrlModel`.

* **Remove Deprecated Files:**
  - Delete `d2x/gen/sf/login_url.py`.
  - Delete `d2x/parse/sf/auth_url.py`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/muselab-d2x/d2x/tree/jlantz/update-auth-structure?shareId=XXXX-XXXX-XXXX-XXXX).
* **LoginUrlModel tests**
  - Test successful instantiation and method call
  - Test instantiation with missing access token
  - Test instantiation with missing login URL

* **SfdxAuthUrlModel tests**
  - Test successful instantiation and method call
  - Test instantiation with invalid URL
* **Fix `requests.put` call**
  - Update the `requests.put` call to use the correct `json` parameter.

* **Remove duplicate imports**
  - Remove duplicate imports to clean up the file.

* **Import `json` module in `tests/test_login_url.py`**
  - Import the `json` module at the beginning of the file.
* Set `DEMO` to "demo" in the `OrgType` Enum
* Import the `re` module at the top of the file
* Import the `re` module at the top of the file
* Import the `re` module at the top of the file
…empty `ret_url` parameter

* Encode `ret_url` parameter as "%2F" if it is empty
* Define a new GitHub Actions workflow for running Python tests
* Trigger the workflow on push and pull request events to the main and releases branches
* Use the starter workflow for Python tests with Python version 3.10
* Set up Python environment and install dependencies
* Run tests and generate coverage report
* Upload coverage report to Codecov
* Generate and upload test report
* Post test summary to GitHub step summary
* Add a reusable workflow for Python tests in `.github/workflows/python-test.yml`
* Update branches to include 'main' and 'releases/**'
* Remove `branches` section from `pull_request` block
* Add a `jobs` section with a `test` job that runs on `ubuntu-latest`
…d2x/d2x into jlantz/implement-two-stage-auth
Implement two-stage auth model with GitHub Environments
Refactor d2x.gen and d2x.parse as Pydantic models
@jlantz jlantz marked this pull request as ready for review November 1, 2024 21:18
@jlantz jlantz merged commit fdcd7b6 into cumulusci-next-snapshots Nov 1, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant