Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new workflow #462

Merged
merged 13 commits into from
Jul 26, 2024
96 changes: 48 additions & 48 deletions .github/workflows/ci-cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,59 +66,59 @@ jobs:
- id: "get-credentials"
uses: "google-github-actions/get-gke-credentials@v2"
with:
cluster_name: "us-central1-test-hubble-2-5f1f2dbf-gke"
cluster_name: "us-central1-test-hubble-43c3e190-gke"
location: "us-central1"

- name: Pytest
run: pytest dags/

deploy-to-dev:
runs-on: ubuntu-latest
needs: [tests]
# deploy to dev occurs every time
# someone submits a pr targeting `master`
# from a branch at `stellar/stellar-etl-airflow` repo
if: github.repository == 'stellar/stellar-etl-airflow'
# known caveats:
# if there's more than 1 person working
# in the same file this won't behave nicely

steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
pip install --upgrade pip
pip install google-cloud-storage==2.1.0

- name: Authenticate to test-hubble GCP
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.CREDS_TEST_HUBBLE }}"

- name: Upload files to dev GCS bucket
run: python dags/stellar_etl_airflow/add_files_to_composer.py --bucket $BUCKET
env:
GOOGLE_CLOUD_PROJECT: test-hubble-319619
BUCKET: us-central1-test-hubble-2-5f1f2dbf-bucket

- name: Update Airflow variables
uses: actions-hub/gcloud@master
env:
PROJECT_ID: test-hubble-319619
APPLICATION_CREDENTIALS: "${{ secrets.CREDS_TEST_HUBBLE }}"
COMPOSER_ENVIRONMENT: test-hubble-2
LOCATION: us-central1
with:
args: >
components install kubectl && gcloud composer environments run
$COMPOSER_ENVIRONMENT --location $LOCATION variables import
-- gcsfuse/actual_mount_path/variables.json
# deploy-to-dev:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented code copy and pasted to the new cicd? If so do you think it's worthwhile to keep it commented here or just delete it? We can also always look at git commit history for the file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep it is part of new workflow. We can 🔪 it for once

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bc4e563

# runs-on: ubuntu-latest
# needs: [tests]
# # deploy to dev occurs every time
# # someone submits a pr targeting `master`
# # from a branch at `stellar/stellar-etl-airflow` repo
# if: github.repository == 'stellar/stellar-etl-airflow'
# # known caveats:
# # if there's more than 1 person working
# # in the same file this won't behave nicely

# steps:
# - uses: actions/checkout@v3

# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: 3.8

# - name: Install dependencies
# run: |
# pip install --upgrade pip
# pip install google-cloud-storage==2.1.0

# - name: Authenticate to test-hubble GCP
# uses: google-github-actions/auth@v1
# with:
# credentials_json: "${{ secrets.CREDS_TEST_HUBBLE }}"

# - name: Upload files to dev GCS bucket
# run: python dags/stellar_etl_airflow/add_files_to_composer.py --bucket $BUCKET
# env:
# GOOGLE_CLOUD_PROJECT: test-hubble-319619
# BUCKET: us-central1-test-hubble-2-5f1f2dbf-bucket

# - name: Update Airflow variables
# uses: actions-hub/gcloud@master
# env:
# PROJECT_ID: test-hubble-319619
# APPLICATION_CREDENTIALS: "${{ secrets.CREDS_TEST_HUBBLE }}"
# COMPOSER_ENVIRONMENT: test-hubble-2
# LOCATION: us-central1
# with:
# args: >
# components install kubectl && gcloud composer environments run
# $COMPOSER_ENVIRONMENT --location $LOCATION variables import
# -- gcsfuse/actual_mount_path/variables.json

promote-to-prod:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- id: "get-credentials"
uses: "google-github-actions/get-gke-credentials@v2"
with:
cluster_name: "us-central1-test-hubble-2-5f1f2dbf-gke"
cluster_name: "us-central1-test-hubble-43c3e190-gke"
location: "us-central1"

- name: Pytest
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Deploy

on:
workflow_dispatch:
inputs:
envName:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to confirm; does envName get converted to inputs.env_name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uff no. That's my bad. Let me change it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in bc4e563

description: "Deploy Environment"
default: "dev"
required: true
type: choice
options:
- dev
- prod

jobs:
log:
runs-on: ubuntu-latest

steps:
- name: Display Environment Name
run: echo "Hello ${{ inputs.env_name }}"

tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
cat airflow_variables_dev.json | sed -e s/\\/home\\/airflow\\/gcs\\/dags\\/// > airflow_variables_ci.json
python -m pip install --upgrade pip
pip install -r requirements-ci.txt

- name: Init Airflow SQLite database
run: airflow db init

- name: Import Airflow variables
run: airflow variables import airflow_variables_ci.json

- name: Authenticate to test-hubble GCP
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.CREDS_TEST_HUBBLE }}"

- id: "get-credentials"
uses: "google-github-actions/get-gke-credentials@v2"
with:
cluster_name: "us-central1-test-hubble-43c3e190-gke"
location: "us-central1"

- name: Pytest
run: pytest dags/

deploy-to-dev:
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
pip install --upgrade pip
pip install google-cloud-storage==2.1.0

- name: Authenticate to test-hubble GCP
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.CREDS_TEST_HUBBLE }}"

- name: Upload files to dev GCS bucket
run: python dags/stellar_etl_airflow/add_files_to_composer.py --bucket $BUCKET
env:
GOOGLE_CLOUD_PROJECT: test-hubble-319619
BUCKET: us-central1-test-hubble-43c3e190-bucket

- name: Update Airflow variables
uses: actions-hub/gcloud@master
env:
PROJECT_ID: test-hubble-319619
APPLICATION_CREDENTIALS: "${{ secrets.CREDS_TEST_HUBBLE }}"
COMPOSER_ENVIRONMENT: test-hubble
LOCATION: us-central1
with:
args: >
components install kubectl && gcloud composer environments run
$COMPOSER_ENVIRONMENT --location $LOCATION variables import
-- gcsfuse/actual_mount_path/variables.json
2 changes: 1 addition & 1 deletion airflow_variables_dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"due to concurrent update"
]
},
"gcs_exported_data_bucket_name": "us-central1-test-hubble-2-5f1f2dbf-bucket",
"gcs_exported_data_bucket_name": "us-central1-test-hubble-43c3e190-bucket",
"gcs_exported_object_prefix": "dag-exported",
"image_name": "stellar/stellar-etl:741ee9b",
"image_output_path": "/etl/exported_data/",
Expand Down
Loading