release: 2024-10-28 #486
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
name: Snowflake CI/CD | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "clouds/snowflake/**" | |
- ".github/workflows/snowflake.yml" | |
pull_request: | |
paths: | |
- "clouds/snowflake/**" | |
- ".github/workflows/snowflake.yml" | |
workflow_dispatch: | |
workflow_call: | |
env: | |
NODE_VERSION: 18.16 | |
PYTHON3_VERSION: 3.8.18 | |
VIRTUALENV_VERSION: 20.21.1 | |
GCLOUD_VERSION: 290.0.1 | |
jobs: | |
test: | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 30 | |
env: | |
SF_PREFIX: ci_${{ github.sha }}_${{ github.run_id }}_${{ github.run_attempt }}_ | |
SF_ACCOUNT: ${{ secrets.SF_ACCOUNT_CI }} | |
SF_DATABASE: ${{ secrets.SF_DATABASE_CI }} | |
SF_USER: ${{ secrets.SF_USER_CI }} | |
SF_PASSWORD: ${{ secrets.SF_PASSWORD_CI }} | |
SF_ROLE: ${{ secrets.SF_ROLE_CI }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Check diff | |
uses: technote-space/get-diff-action@v4 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Setup python 3 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON3_VERSION }} | |
- name: Setup virtualenv | |
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }} | |
- name: Run linter and tests | |
run: | | |
cd clouds/snowflake | |
make lint && \ | |
make deploy diff="$GIT_DIFF" && \ | |
make test diff="$GIT_DIFF" && \ | |
make remove | |
deploy-internal: | |
if: github.ref_name == 'main' | |
needs: test | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 20 | |
strategy: | |
matrix: | |
include: | |
- account: SF_ACCOUNT_CD | |
database: SF_DATABASE_CD | |
user: SF_USER_CD | |
password: SF_PASSWORD_CD | |
role: SF_ROLE_CD | |
env: | |
SF_ACCOUNT: ${{ secrets[matrix.account] }} | |
SF_DATABASE: ${{ secrets[matrix.database] }} | |
SF_USER: ${{ secrets[matrix.user] }} | |
SF_PASSWORD: ${{ secrets[matrix.password] }} | |
SF_ROLE: ${{ secrets[matrix.role] }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Check diff | |
uses: technote-space/get-diff-action@v4 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Run deploy | |
run: | | |
cd clouds/snowflake | |
make deploy diff="$GIT_DIFF" production=1 | |
deploy-internal-app: | |
if: github.ref_name == 'main' | |
needs: test | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 30 | |
env: | |
APP_PACKAGE_NAME: ${{ secrets.SF_NATIVE_APP_PACKAGE_NAME_CD }} | |
APP_NAME: ${{ secrets.SF_NATIVE_APP_NAME_CD }} | |
SF_ACCOUNT: ${{ secrets.SF_ACCOUNT_NATIVE_APP }} | |
SF_DATABASE: ${{ secrets.SF_DATABASE_NATIVE_APP }} | |
SF_USER: ${{ secrets.SF_USER_NATIVE_APP }} | |
SF_PASSWORD: ${{ secrets.SF_PASSWORD_NATIVE_APP }} | |
SF_ROLE: ${{ secrets.SF_ROLE_NATIVE_APP }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Check diff | |
uses: technote-space/get-diff-action@v4 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Deploy native app package | |
run: | | |
cd clouds/snowflake | |
make deploy-native-app-package production=1 | |
- name: Deploy native app locally | |
run: | | |
cd clouds/snowflake | |
make deploy-native-app production=1 | |
deploy-share: | |
if: github.ref_name == 'stable' | |
needs: test | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 20 | |
env: | |
SF_ACCOUNT: ${{ secrets.SF_ACCOUNT_SHARE }} | |
SF_DATABASE: ${{ secrets.SF_DATABASE_SHARE }} | |
SF_USER: ${{ secrets.SF_USER_SHARE }} | |
SF_PASSWORD: ${{ secrets.SF_PASSWORD_SHARE }} | |
SF_ROLE: ${{ secrets.SF_ROLE_SHARE }} | |
SF_SHARE: ${{ secrets.SF_SHARE }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Check diff | |
uses: technote-space/get-diff-action@v4 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Run deploy | |
run: | | |
cd clouds/snowflake | |
make deploy diff="$GIT_DIFF" production=1 | |
cd modules | |
make deploy-share | |
publish: | |
if: github.ref_name == 'stable' | |
needs: test | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 10 | |
env: | |
PACKAGE_BUCKET: gs://carto-analytics-toolbox-core/snowflake | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
- name: Setup node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Auth google | |
uses: google-github-actions/auth@v0 | |
with: | |
credentials_json: ${{ secrets.GCLOUD_PRODUCTION_RELEASE_SA }} | |
project_id: ${{ secrets.GCLOUD_PRODUCTION_PROJECT }} | |
create_credentials_file: true | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
version: ${{ env.GCLOUD_VERSION }} | |
project_id: ${{ secrets.GCLOUD_PRODUCTION_PROJECT }} | |
- name: Create package | |
run: | | |
cd clouds/snowflake | |
make create-package | |
- name: Publish package | |
run: | | |
cd clouds/snowflake | |
gsutil -h "Content-Type:application/zip" -m cp dist/*.zip ${{ env.PACKAGE_BUCKET }}/ | |
gsutil -h "Content-Type:application/zip" -m cp dist/*.zip ${{ env.PACKAGE_BUCKET }}/carto-analytics-toolbox-core-snowflake-latest.zip | |
gsutil -h "Content-Type:application/json" -m cp dist/*.json ${{ env.PACKAGE_BUCKET }}/ |