Skip to content

Commit

Permalink
Merge branch 'main' into add_descriptions_to_project_definition
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-turbaszek committed Jul 31, 2024
2 parents 94752a6 + 06a9ec3 commit a182d5e
Show file tree
Hide file tree
Showing 317 changed files with 18,917 additions and 10,061 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ tests/project/ @snowflakedb/snowcli @snowflakedb/nade

# No ownership to reduce friction
RELEASE-NOTES.md
src/snowflake/cli/api/errno.py # SQL error codes
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ concurrency:
cancel-in-progress: true

jobs:
define-matrix:
uses: ./.github/workflows/matrix.yaml
build:
needs: define-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/jira_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ jobs:
&& (github.event.comment.user.login == 'sfc-gh-turbaszek'
|| github.event.comment.user.login == 'sfc-gh-astus'
|| github.event.comment.user.login == 'sfc-gh-pjob'
|| github.event.comment.user.login == 'sfc-gh-jsikorski')
|| github.event.comment.user.login == 'sfc-gh-jsikorski'
|| github.event.comment.user.login == 'sfc-gh-pczajka'
|| github.event.comment.user.login == 'sfc-gh-mraba')
)
|| (github.event_name == 'issues' && github.event.pull_request.user.login != 'whitesource-for-github-com[bot]'))
steps:
Expand Down Expand Up @@ -49,7 +51,7 @@ jobs:
description: >
_Created from GitHub Action_ for ${{ github.event.issue.html_url }}
```${{ github.event.issue.body }}```
fields: '{"customfield_11401":{"id":"14723"},"labels":["dp-snowcli","github"],"parent":{"key":"SNOW-1347923"}}'
fields: '{"customfield_11401":{"id":"14723"},"labels":["dp-snowcli","github"],"parent":{"key":"SNOW-1555958"}}'

- name: Update GitHub Issue
uses: ./jira/gajira-issue-update
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
id: python
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
echo 'python=["3.8", "3.9", "3.10", "3.11", "3.12"]' >> "$GITHUB_OUTPUT"
echo 'python=["3.10", "3.11", "3.12"]' >> "$GITHUB_OUTPUT"
else
# Last supported and most frequently used
echo 'python=["3.10"]' >> "$GITHUB_OUTPUT"
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/ok_to_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# If someone with write access comments "/ok-to-test" on a pull request, emit a repository_dispatch event
name: Ok To Test

on:
issue_comment:
types: [created]

jobs:
ok-to-test:
runs-on: ubuntu-latest
environment: ok-to-test
permissions:
pull-requests: write
# Only run for PRs, not issue comments
if: ${{ github.event.issue.pull_request }}
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@13bc09769d122a64f75aa5037256f6f2d78be8c4
env:
TOKEN: ${{ steps.app-token.outputs.token }}
with:
token: ${{ env.TOKEN }}
reaction-token: ${{ secrets.GITHUB_TOKEN }}
issue-type: pull-request
commands: ok-to-test
permission: write
13 changes: 8 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ env:


jobs:
test:
runs-on: ubuntu-latest
define-matrix:
uses: ./.github/workflows/matrix.yaml
tests:
needs: define-matrix
strategy:
fail-fast: false
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
80 changes: 79 additions & 1 deletion .github/workflows/test_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- main
repository_dispatch:
types: [ok-to-test-command]
schedule:
- cron: "0 8 * * *"

Expand All @@ -19,14 +21,16 @@ concurrency:
jobs:
define-matrix:
uses: ./.github/workflows/matrix.yaml
tests:

e2e-trusted:
needs: define-matrix
strategy:
fail-fast: true
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -47,3 +51,77 @@ jobs:
SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
run: python -m hatch run e2e:test

# Repo owner has commented /ok-to-test on a (fork-based) pull request
e2e-fork:
needs: define-matrix
strategy:
fail-fast: true
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
permissions:
pull-requests: write
checks: write
if: |
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.args.named.sha != '' &&
contains(
github.event.client_payload.pull_request.head.sha,
github.event.client_payload.slash_command.args.named.sha
)
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
python -m hatch env create e2e
- name: Run end to end tests
env:
TERM: unknown
SNOWFLAKE_CONNECTIONS_INTEGRATION_HOST: ${{ secrets.SNOWFLAKE_HOST }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
run: python -m hatch run e2e:test
# Update check run called "e2e-fork"
- uses: actions/github-script@v7
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
83 changes: 81 additions & 2 deletions .github/workflows/test_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- main
repository_dispatch:
types: [ok-to-test-command]
schedule:
- cron: "0 8 * * *"

Expand All @@ -20,22 +22,66 @@ concurrency:
jobs:
define-matrix:
uses: ./.github/workflows/matrix.yaml
tests:

# Branch-based pull request
integration-trusted:
needs: define-matrix
strategy:
fail-fast: true
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
python -m hatch env create integration
- name: Run integration tests
env:
TERM: unknown
SNOWFLAKE_CONNECTIONS_INTEGRATION_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
run: python -m hatch run integration:test


# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
needs: define-matrix
strategy:
fail-fast: true
matrix:
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
python-version: ${{ fromJSON(needs.define-matrix.outputs.python) }}
runs-on: ${{ matrix.os }}
permissions:
pull-requests: write
checks: write
if: |
github.event_name == 'repository_dispatch' &&
github.event.client_payload.slash_command.args.named.sha != '' &&
contains(
github.event.client_payload.pull_request.head.sha,
github.event.client_payload.slash_command.args.named.sha
)
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
Expand All @@ -47,3 +93,36 @@ jobs:
SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
run: python -m hatch run integration:test
# Update check run called "integration-fork"
- uses: actions/github-script@v7
id: update-check-run
if: ${{ always() }}
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__pycache__
.venv
.venv*
*.egg-info
config.ini
credentials
Expand All @@ -17,6 +17,7 @@ gen_docs/
/venv/
.env
.vscode
tmp/

^app.zip
^snowflake.yml
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ repos:
(?x)
^\.github/|
tests/test_data/projects/.*|
tests_integration/test_data/projects/.*
tests_integration/test_data/projects/.*|
files: \.py$|\.pyi$
args:
- --comment-style
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ hatch shell
This will spawn new shell with virtual environment enables. To leave just press ^D.


Currently, the required Python version for development is Python 3.8+. For local development we recommend to use
Currently, the required Python version for development is Python 3.10+. For local development we recommend to use
a wrapper for virtual environments like [pyenv](https://github.com/pyenv/pyenv).

If you wish to setup environment with specific version ie. 3.8 you can use following command:
If you wish to setup environment with specific version ie. 3.10 you can use following command:

```bash
hatch env create local.py3.8```
hatch env create local.py3.10```
You can see all locally supported environments with
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ Cheatsheet: https://github.com/Snowflake-Labs/sf-cheatsheets/blob/main/snowflake

## Install Snowflake CLI

### Install with pip (PyPi)
### Install with pipx (PyPi)

Requires Python >= 3.8
We recommend installing Snowflake CLI in isolated environment using [pipx](https://pipx.pypa.io/stable/). Requires Python >= 3.10

```bash
pip install snowflake-cli-labs
pipx install snowflake-cli-labs
snow --help
```

Expand All @@ -59,7 +59,7 @@ snow --help

### Install from source

Requires Python >= 3.8 and git
Requires Python >= 3.10 and git

```bash
git clone https://github.com/snowflakedb/snowflake-cli
Expand Down
Loading

0 comments on commit a182d5e

Please sign in to comment.