-
Notifications
You must be signed in to change notification settings - Fork 44
192 lines (186 loc) · 6.61 KB
/
redshift.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
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: 30
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 }}/