-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1482571: Add CI pipeline for apps unit testing (#3)
* Create python-app.yml * change yml name * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * add changed files to the pipeline * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Create test.sh * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Delete test.sh * Update ci.yml * Update customers.sql * Update customers.sql * Update ci.yml * apply code suggestions
- Loading branch information
1 parent
bf088ca
commit eaf35b3
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
name: native-app-examples | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- labeled | ||
- unlabeled | ||
- synchronize | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- environment-file: shared_python_ci_env.yml | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Get changed files | ||
id: changed-files | ||
run: | | ||
if ${{ github.event_name == 'pull_request' }}; then | ||
echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT | ||
else | ||
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Determine tests to run | ||
uses: actions/github-script@v7 | ||
id: tests_to_run | ||
env: | ||
CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }} | ||
with: | ||
script: | | ||
const { CHANGED_FILES } = process.env; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
function getPytestPaths(dir, callback) | ||
{ | ||
const files = fs.readdirSync(dir, { withFileTypes: true }); | ||
for (const file of files) | ||
{ | ||
if (file.isDirectory()) | ||
{ | ||
getPytestPaths(path.join(dir, file.name), callback); | ||
} | ||
else | ||
{ | ||
extension = path.extname(file.name); | ||
if (extension == '.py') | ||
{ | ||
callback(dir); | ||
} | ||
} | ||
} | ||
} | ||
const paths = new Set(CHANGED_FILES.split(" ") | ||
.map(x => x.substring(0, x.indexOf("/") + 1)) | ||
.filter(x => x.length > 0 && !x.startsWith('.'))); | ||
const pytestPaths = new Set() | ||
for (const rootPath of paths) | ||
{ | ||
getPytestPaths(rootPath, x => pytestPaths.add(x)) | ||
} | ||
core.setOutput('pytestPaths', [...pytestPaths].join(' ')); | ||
core.setOutput('pytestArgs', [...paths].join(' ')); | ||
- name: Setup test environment | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
environment-file: ${{ matrix.environment-file }} | ||
- name: Install dependencies | ||
run: | | ||
printf "[pytest]\npythonpath=${{ steps.tests_to_run.outputs.pytestPaths }}" > pytest.ini | ||
python -m pip install pytest | ||
- name: Run tests | ||
run: | | ||
args=${{ steps.tests_to_run.outputs.pytestArgs }} | ||
if [ -z "${args}" ]; then | ||
echo “Nothing to test” | ||
else | ||
pytest $args | ||
fi | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is used to install packages for local testing | ||
name: native-apps-examples-testing | ||
channels: | ||
- snowflake | ||
dependencies: | ||
- python=3.8 | ||
- pip | ||
- pip: | ||
- git+https://github.com/snowflakedb/snowflake-telemetry-python.git | ||
- snowflake-native-apps-permission-stub | ||
- snowflake-snowpark-python>=1.15.0 | ||
- snowflake-cli-labs>=2.0.0 | ||
- pytest | ||
- streamlit>=1.26.0 | ||
|