Skip to content

test_redshift

test_redshift #293

Workflow file for this run

name: Redshift CI/CD
on:
push:
branches:
- main
paths:
- "clouds/redshift/**"
- ".github/workflows/redshift.yml"
pull_request:
paths:
- "clouds/redshift/**"
- ".github/workflows/redshift.yml"
workflow_dispatch:
workflow_call:
env:
NODE_VERSION: 14
PYTHON2_VERSION: 2.7.18
PYTHON3_VERSION: 3.8.10
VIRTUALENV_VERSION: 20.15.1
GCLOUD_VERSION: 290.0.1
jobs:
test:
runs-on: ubuntu-20.04
container: python:2.7.18-buster
timeout-minutes: 3
env:
RS_PREFIX: ci_${{ github.sha }}_${{ github.run_id }}_${{ github.run_attempt }}_
RS_HOST: ${{ secrets.RS_HOST_CI }}
RS_DATABASE: ${{ secrets.RS_DATABASE_CI }}
RS_USER: ${{ secrets.RS_USER_CI }}
RS_PASSWORD: ${{ secrets.RS_PASSWORD_CI }}
RS_BUCKET: ${{ secrets.RS_BUCKET_CI }}
AWS_ACCESS_KEY_ID: ${{ secrets.RS_AWS_ACCESS_KEY_ID_CI }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RS_AWS_SECRET_ACCESS_KEY_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 yarn
run: npm install -g yarn
- name: Install dependencies
run: |
apt-get update
apt-get -y install rsync zip unzip curl glibc-source groff less
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.RS_AWS_ACCESS_KEY_ID_CI }}
aws-secret-access-key: ${{ secrets.RS_AWS_SECRET_ACCESS_KEY_CI }}
aws-region: ${{ secrets.RS_REGION_CI }}
- name: Run linter and tests
run: |
cd clouds/redshift
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
container: python:2.7.18-buster
timeout-minutes: 20
strategy:
matrix:
include:
- host: RS_HOST_CD
database: RS_DATABASE_CD
user: RS_USER_CD
password: RS_PASSWORD_CD
bucket: RS_BUCKET_CD
region: RS_REGION_CD
aws_access_key_id: RS_AWS_ACCESS_KEY_ID_CD
aws_secret_access_key: RS_AWS_SECRET_ACCESS_KEY_CD
- host: RS_HOST_CI
database: RS_DATABASE_CI
user: RS_USER_CI
password: RS_PASSWORD_CI
bucket: RS_BUCKET_CI
region: RS_REGION_CI
aws_access_key_id: RS_AWS_ACCESS_KEY_ID_CI
aws_secret_access_key: RS_AWS_SECRET_ACCESS_KEY_CI
env:
RS_HOST: ${{ secrets[matrix.host] }}
RS_DATABASE: ${{ secrets[matrix.database] }}
RS_USER: ${{ secrets[matrix.user] }}
RS_PASSWORD: ${{ secrets[matrix.password] }}
RS_BUCKET: ${{ secrets[matrix.bucket] }}
RS_REGION: ${{ secrets[matrix.region] }}
AWS_ACCESS_KEY_ID: ${{ secrets[matrix.aws_access_key_id] }}
AWS_SECRET_ACCESS_KEY: ${{ secrets[matrix.aws_secret_access_key] }}
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 yarn
run: npm install -g yarn
- name: Install dependencies
run: |
apt-get update
apt-get -y install rsync zip unzip curl glibc-source groff less
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.RS_REGION }}
- name: Run deploy
run: |
cd clouds/redshift
make deploy diff="$GIT_DIFF" production=1
publish:
if: github.ref_name == 'stable'
needs: test
runs-on: ubuntu-20.04
container: python:2.7.18-buster
timeout-minutes: 10
env:
PACKAGE_BUCKET: gs://carto-analytics-toolbox-core/redshift
LIBS_URL: https://storage.googleapis.com/carto-analytics-toolbox-core/redshift/latest/libs
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup yarn
run: npm install -g yarn
- name: Setup virtualenv
run: pip install virtualenv==${{ env.VIRTUALENV_VERSION }}
- name: Install dependencies
run: |
apt-get update
apt-get -y install rsync zip unzip curl glibc-source groff less
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
- 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/redshift
make create-package
- name: Publish package
run: |
cd clouds/redshift
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-redshift-latest.zip
gsutil -h "Content-Type:application/zip" -m cp build/libs/*.zip ${{ env.PACKAGE_BUCKET }}/latest/libs/
gsutil -h "Content-Type:application/json" -m cp dist/*.json ${{ env.PACKAGE_BUCKET }}/