Skip to content

Commit

Permalink
override workflows from main
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pczajka committed Aug 22, 2024
1 parent 154dc67 commit e8d3ecb
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 187 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,10 @@ on:

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip hatch
python -m hatch env create e2e
- name: Run cleaunp
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:cleanup
uses: ./.github/workflows/test_trusted.yaml
with:
runs-on: ubuntu-latest
python-version: "3.11"
python-env: e2e
hatch-run: e2e:cleanup
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/jira_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,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
15 changes: 14 additions & 1 deletion .github/workflows/test_cli_action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@ jobs:
with:
cli-version: "latest"
default-config-file-path: "tests_integration/config/connection_configs.toml"
- name: Set up key (Ubuntu / MacOS)
env:
SNOWFLAKE_CONNECTIONS_INTEGRATION_PRIVATE_KEY: ${{ secrets.SNOWFLAKE_PRIVATE_KEY }}
run: |
PARENT_DIR=$(dirname "${{ github.workspace }}")
PRIVATE_KEY_PATH=$PARENT_DIR/.ssh/key.p8
echo "PARENT_DIR=$PARENT_DIR" >> $GITHUB_ENV
echo "PRIVATE_KEY_PATH=$PRIVATE_KEY_PATH" >> $GITHUB_ENV
mkdir $PARENT_DIR/.ssh
echo "${SNOWFLAKE_CONNECTIONS_INTEGRATION_PRIVATE_KEY}" > $PRIVATE_KEY_PATH
sudo chmod 600 $PRIVATE_KEY_PATH
- name: Test connection
env:
TERM: unknown
SNOWFLAKE_CONNECTIONS_INTEGRATION_AUTHENTICATOR: SNOWFLAKE_JWT
SNOWFLAKE_CONNECTIONS_INTEGRATION_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_CONNECTIONS_INTEGRATION_PRIVATE_KEY_PATH: ${{ env.PRIVATE_KEY_PATH }}
run: snow connection test -c integration | grep Status
90 changes: 14 additions & 76 deletions .github/workflows/test_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,14 @@ jobs:
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 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
uses: ./.github/workflows/test_trusted.yaml
with:
runs-on: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
python-env: e2e
hatch-run: e2e:test
secrets: inherit

# Repo owner has commented /ok-to-test on a (fork-based) pull request
e2e-fork:
Expand All @@ -60,7 +46,6 @@ jobs:
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
Expand All @@ -71,57 +56,10 @@ jobs:
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;
uses: ./.github/workflows/test_fork.yaml
with:
runs-on: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
python-env: e2e
hatch-run: e2e:test
secrets: inherit
91 changes: 15 additions & 76 deletions .github/workflows/test_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,18 @@ jobs:
integration-trusted:
needs: define-matrix
strategy:
fail-fast: true
fail-fast: false
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

uses: ./.github/workflows/test_trusted.yaml
with:
runs-on: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
python-env: integration
hatch-run: integration:test
secrets: inherit

# Repo owner has commented /ok-to-test on a (fork-based) pull request
integration-fork:
Expand All @@ -62,7 +48,6 @@ jobs:
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
Expand All @@ -73,56 +58,10 @@ jobs:
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 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
# 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;
uses: ./.github/workflows/test_fork.yaml
with:
runs-on: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
python-env: integration
hatch-run: integration:test
secrets: inherit
26 changes: 15 additions & 11 deletions scripts/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import typing as t
from datetime import datetime, timedelta

from snowflake.cli._app.snow_connector import update_connection_details_with_private_key
from snowflake.snowpark.session import Session


Expand Down Expand Up @@ -49,18 +50,21 @@ def remove_resources(single: str, plural: str, known_instances: t.List[str], rol


if __name__ == "__main__":
role = "INTEGRATION_TESTS"
session = Session.builder.configs(
{
"account": os.getenv("SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT"),
"user": os.getenv("SNOWFLAKE_CONNECTIONS_INTEGRATION_USER"),
"password": os.getenv("SNOWFLAKE_CONNECTIONS_INTEGRATION_PASSWORD"),
"database": "SNOWCLI_DB",
"role": role,
}
).create()
role = os.getenv("SNOWFLAKE_CONNECTIONS_INTEGRATION_ROLE", "INTEGRATION_TESTS")
config = {
"authenticator": "SNOWFLAKE_JWT",
"account": os.getenv("SNOWFLAKE_CONNECTIONS_INTEGRATION_ACCOUNT"),
"user": os.getenv("SNOWFLAKE_CONNECTIONS_INTEGRATION_USER"),
"private_key_path": os.getenv(
"SNOWFLAKE_CONNECTIONS_INTEGRATION_PRIVATE_KEY_PATH"
),
"database": "SNOWCLI_DB",
"role": role,
}
update_connection_details_with_private_key(config)
session = Session.builder.configs(config).create()

session.use_role("INTEGRATION_TESTS")
session.use_role(role)

known_objects: t.Dict[t.Tuple[str, str], t.List[str]] = {
("database", "databases"): [
Expand Down

0 comments on commit e8d3ecb

Please sign in to comment.