Nightly Data Source Cleanup #1
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
# Script(s) to clean up any loose data left behind from test runs. | |
# These can primarily happen if CI is stopped while tests are running | |
# for big query, etc. | |
name: Nightly Data Source Cleanup | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 6 * * *" | |
jobs: | |
cleanup-big-query: | |
runs-on: ubuntu-latest | |
env: | |
GE_TEST_GCP_CREDENTIALS: ${{secrets.GE_TEST_GCP_CREDENTIALS}} | |
GE_TEST_GCP_PROJECT: ${{secrets.GE_TEST_GCP_PROJECT}} | |
GE_TEST_BIGQUERY_DATASET: ${{secrets.GE_TEST_BIGQUERY_DATASET}} | |
GOOGLE_APPLICATION_CREDENTIALS: "gcp-credentials.json" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
cache-dependency-path: | | |
requirements-types.txt | |
reqs/requirements-dev-contrib.txt | |
- name: Install dependencies | |
run: pip install -r requirements-types.txt -r reqs/requirements-dev-contrib.txt -e . | |
- name: Create JSON file GCP | |
run: | | |
echo "$GE_TEST_GCP_CREDENTIALS" > gcp-credentials.json | |
- name: Install and setup Google Cloud SDK | |
run: | | |
# this is recommended by the Google documentation for CI/CD https://cloud.google.com/sdk/docs/install#other_installation_options | |
curl -sS https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-370.0.0-linux-x86_64.tar.gz > ./google-cloud-sdk-370.0.0-linux-x86_64.tar.gz && tar -xf ./google-cloud-sdk-370.0.0-linux-x86_64.tar.gz | |
./google-cloud-sdk/install.sh --usage-reporting=False --path-update=True --quiet --install-python=False | |
# creating new named configuration | |
./google-cloud-sdk/bin/gcloud config configurations create ge-oss-ci-cd-configurations | |
# setting account config using project and service account info | |
./google-cloud-sdk/bin/gcloud config set account account-for-azure-tests --project=$GE_TEST_GCP_PROJECT --access-token-file=$GOOGLE_APPLICATION_CREDENTIALS | |
# Pass the configured Cloud SDK authentication to gsutil. | |
./google-cloud-sdk/bin/gcloud config set pass_credentials_to_gsutil True | |
# Authorize access to Google Cloud with a service account | |
./google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS | |
- name: Cleanup | |
run: | | |
python ./scripts/cleanup/cleanup_big_query.py |