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

Feat/integrate connections toml #298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a3d18eb
feat: add connection file path and connection name cli arguments
Oct 18, 2024
be0e37a
feat: add connections.toml options to DeployConfig and parse_cli_args.py
Oct 19, 2024
41a4995
feat: fetch snowflake_password in config object
Oct 19, 2024
660bb0a
feat: prioritize SNOWFLAKE_PRIVATE_KEY_PATH env var in DeployConfig
Oct 19, 2024
aadf7a1
feat: introduce env var and connections.toml layering into get_merged…
Oct 23, 2024
f2635a2
feat: remove get_session_from_config, opt for config.get_session_kwargs
Oct 24, 2024
7dda5de
fix: fix verbose handling in get_yaml_config_kwargs
Oct 24, 2024
fdb7554
fix: return account as session attribute
Oct 24, 2024
8046f5a
fix: account for token path newline
Oct 24, 2024
cec87a5
fix: connections.toml requires token_file_path instead of token-file-…
Oct 25, 2024
8b52000
Merge branch 'master' into feat/integrate-connections-toml
Oct 31, 2024
f9e9917
feat: swap tomllib with tomlkit
Oct 31, 2024
95fbe72
feat: avoid DeployConfig argument repetition
Oct 31, 2024
c724850
fix: clear environment variables to allow GitHub Actions tests to pass
Oct 31, 2024
addf642
fix: remove unused default_config_file_name class attribute
Oct 31, 2024
10b867c
fix: make ownership grant idempotent
Oct 31, 2024
6ee659f
feat: make tests runnable on Snowflake standard edition
Oct 31, 2024
6eaeaa9
feat: respect SNOWFLAKE_DEFAULT_CONNECTION_NAME environment variable
Oct 31, 2024
6e53452
feat: log snowflake.connector.connect arguments
Oct 31, 2024
713ae2d
feat: log get_merged_config steps
Oct 31, 2024
9fec758
fix: fix get_merged_config tests
Oct 31, 2024
19319b6
fix: fix get_merged_config tests
Oct 31, 2024
e82b3b9
fix: fix missing database reference
Oct 31, 2024
d5bf05a
docs: reference new cli arguments
Oct 31, 2024
d218e52
docs: reference new cli arguments
Oct 31, 2024
81aaeae
docs: adding to the change log
Oct 31, 2024
f659acb
feat: prioritize cli arguments over environment variables
Nov 8, 2024
db86db4
feat: prioritize cli arguments over environment variables
Nov 8, 2024
1beb3a5
feat: remove oauth-config support
Nov 8, 2024
eb8882b
feat: deprecate cli connection arguments
Nov 14, 2024
f29925a
feat: drive SnowflakeSession attributes from connection instead of ar…
Nov 14, 2024
f35f1a6
feat: defer to snowflake python connector for connection arguments
Nov 14, 2024
fb2f2a4
feat: restructure integration test
Nov 15, 2024
c07f97c
fix: fix integration tests
Nov 15, 2024
53efca1
docs: clarify integration test seup
Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ operating environment, schemachange version and python version. Whenever possibl
also include a brief, self-contained code example that demonstrates the problem.

We have
included [issue templates](https://github.com/Snowflake-Labs/schemachange/issues/new/choose) for reporting bugs, requesting features and seeking clarifications. Choose the appropriate issue template to contribute to the repository.
included [issue templates](https://github.com/Snowflake-Labs/schemachange/issues/new/choose) for reporting bugs,
requesting features and seeking clarifications. Choose the appropriate issue template to contribute to the repository.

## Contributing code

Expand All @@ -22,8 +23,6 @@ Thank you for your interest in contributing code to schemachange!

### Guide to contributing to schemachange

> **IMPORTANT** : You will need to follow the [provisioning and schemachange setup instructions](../demo/README.MD) to ensure you can run GitHub actions against your Snowflake account before placing a PR with main schemachange repository so that your PR can be merged into schemachange master branch.

1. If you are a first-time contributor
+ Go to [Snowflake-Labs/Schemachange](https://github.com/Snowflake-Labs/schemachange) and click the "fork" button to
create your own copy of the project.
Expand Down Expand Up @@ -53,8 +52,8 @@ Thank you for your interest in contributing code to schemachange!
+ [Pull](https://github.com/git-guides/git-pull) the latest changes from upstream, including tags:

```shell
git checkout main
git pull upstream main --tags
git checkout master
git pull upstream master --tags
```

2. Create and Activate a Virtual Environment
Expand Down Expand Up @@ -98,24 +97,32 @@ Thank you for your interest in contributing code to schemachange!

+ Commit locally as you progress ( [git add](https://github.com/git-guides/git-add)
and [git commit](https://github.com/git-guides/git-commit) ). Use a properly formatted commit message. Be sure to
document any changed behavior in the [CHANGELOG.md](../CHANGELOG.md) file to help us collate the changes for a specific release.
document any changed behavior in the [CHANGELOG.md](../CHANGELOG.md) file to help us collate the changes for a
specific release.

4. Test your contribution locally

```bash
python -m pytest
```
PS: Please add test cases to the features you are developing so that over time, we can capture any lapse in functionality changes.
PS: Please add test cases to the features you are developing so that over time, we can capture any lapse in
functionality changes.

5. Perform integration tests on your branch from your fork
- Follow the [provisioning and schemachange setup instructions](../demo/README.MD) to configure your Snowflake
account for testing.
- Follow [these](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow)
instructions to manually run the `master-pytest` workflow on your fork of the repo, targeting your feature branch.

5. Push your contribution to GitHub
6. Push your contribution to GitHub

[Push](https://github.com/git-guides/git-push) your changes back to your fork on GitHub
[Push](https://github.com/git-guides/git-push) your changes back to your fork on GitHub

```shell
git push origin update-build-library-dependencies
```

6. Raise a Pull Request to merge your contribution into the a Schemachange Release
7. Raise a Pull Request to merge your contribution into the a Schemachange Release
+ Go to GitHub. The new branch will show up with a
green [Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#initiating-the-pull-request)
button. Make sure the title and message are clear, concise and self-explanatory. Then click the button to submit
Expand Down
60 changes: 50 additions & 10 deletions .github/workflows/master-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
runs-on: ${{ matrix.os }}
if: ${{ github.event.label.name == 'ci-run-tests' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
env:
SNOWFLAKE_PASSWORD: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_PASSWORD }}
SNOWFLAKE_USER: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_USER }}
SNOWFLAKE_ACCOUNT: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_DATABASE: SCHEMACHANGE_DEMO
SNOWFLAKE_WAREHOUSE: SCHEMACHANGE_DEMO_WH
SNOWFLAKE_USER: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_USER }}
SNOWFLAKE_ROLE: SCHEMACHANGE_DEMO-DEPLOY
SNOWFLAKE_WAREHOUSE: SCHEMACHANGE_DEMO_WH
SNOWFLAKE_DATABASE: SCHEMACHANGE_DEMO
MY_TARGET_SCHEMA: ${{ matrix.scenario-name }}_${{ github.run_number }}_${{ strategy.job-index }}
SNOWFLAKE_PASSWORD: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_PASSWORD }}
SCENARIO_NAME: ${{ matrix.scenario-name }}
steps:
- uses: actions/checkout@v4
Expand All @@ -58,6 +58,18 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Create and populate connections.toml
run: |
touch ./connections.toml
echo [default] >> ./connections.toml
echo account = \"${SNOWFLAKE_ACCOUNT}\" >> ./connections.toml
echo user = \"${SNOWFLAKE_USER}\" >> ./connections.toml
echo role = \"${SNOWFLAKE_ROLE}\" >> ./connections.toml
echo warehouse = \"${SNOWFLAKE_WAREHOUSE}\" >> ./connections.toml
echo database = \"${SNOWFLAKE_DATABASE}\" >> ./connections.toml
echo password = \"${SNOWFLAKE_PASSWORD}\" >> ./connections.toml
echo "cat connections.toml"
cat ./connections.toml
- name: Test with pytest
id: pytest
run: |
Expand All @@ -66,16 +78,36 @@ jobs:
- name: Test Schemachange on ${{ matrix.os }} targeting ${{ env.SNOWFLAKE_DATABASE }}.${{ env.MY_TARGET_SCHEMA }} schema
run: |
echo "::group::Setting up ${MY_TARGET_SCHEMA}"
schemachange deploy --config-folder ./demo/setup/${SCENARIO_NAME}
schemachange deploy \
--config-folder ./demo \
--config-file-name schemachange-config-setup.yml \
--root-folder ./demo/${SCENARIO_NAME}/1_setup \
--connection-name default \
--connections-file-path ./connections.toml \
--verbose
echo "::endgroup::"

echo "::group::Testing Rendering to ${MY_TARGET_SCHEMA}"
schemachange render --config-folder ./demo/${SCENARIO_NAME} ./demo/${SCENARIO_NAME}/A__render.sql
schemachange render --config-folder ./demo/${SCENARIO_NAME} ./demo/${SCENARIO_NAME}/R__render.sql
schemachange render --config-folder ./demo/${SCENARIO_NAME} ./demo/${SCENARIO_NAME}/V1.0.0__render.sql

schemachange render \
--config-folder ./demo/${SCENARIO_NAME} \
./demo/${SCENARIO_NAME}/2_test/A__render.sql
schemachange render \
--config-folder ./demo/${SCENARIO_NAME} \
./demo/${SCENARIO_NAME}/2_test/R__render.sql
schemachange render \
--config-folder ./demo/${SCENARIO_NAME} \
./demo/${SCENARIO_NAME}/2_test/V1.0.0__render.sql
echo "::endgroup::"

echo "::group::Testing Deployment using ${MY_TARGET_SCHEMA}"
set +e
schemachange deploy --config-folder ./demo/${SCENARIO_NAME}
schemachange deploy \
--config-folder ./demo/${SCENARIO_NAME} \
--connection-name default \
--connections-file-path ./connections.toml \
--root-folder ./demo/${SCENARIO_NAME}/2_test \
--verbose
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "Deployment Completed!"
Expand All @@ -84,9 +116,17 @@ jobs:
fi
echo "::endgroup::"
set -e

echo "::group::Tearing down up ${MY_TARGET_SCHEMA}"
schemachange deploy --config-folder ./demo/teardown/${SCENARIO_NAME}
schemachange deploy \
--config-folder ./demo \
--config-file-name schemachange-config-teardown.yml \
--connection-name default \
--connections-file-path ./connections.toml \
--root-folder ./demo/${SCENARIO_NAME}/3_teardown \
--verbose
echo "::endgroup::"

if [ $RESULT -ne 0 ]; then
exit 1
fi
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ All notable changes to this project will be documented in this file.
### Added
- Use of `structlog~=24.1.0` for standard log outputs
- Verified Schemachange against Python 3.12
- Support for connections.toml configurations
- Support for supplying the authenticator, private key path, token path, connections file path, and connection name via the YAML and command-line configurations.

### Changed
- Refactored the main cli.py into multiple modules - config, session.
- Updated contributing guidelines and demo readme content to help contributors setup local snowflake account to run the github actions in their fork before pushing the PR to upstream repository.
- Removed tests against Python 3.8 [End of Life on 2024-10-07](https://devguide.python.org/versions/#supported-versions)

- Command-line vars are now merged into YAML vars instead of overwriting them entirely

## [3.7.0] - 2024-07-22
### Added
Expand Down
Loading