Skip to content

README

README #101

Workflow file for this run

name: Python Test Workflow
on:
push:
branches:
- main
- citest
jobs:
test-and-deploy:
runs-on: ubuntu-22.04
steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r pipeline/requirements.txt
# Step 4: Run tests and generate coverage report
- name: Run tests
run: |
pip install coverage
coverage run -m pytest pipeline/airflow/tests --maxfail=2 --disable-warnings
coverage html
coverage xml
# Step 5: Upload coverage report as artifact
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: htmlcov/
# Step 6: Upload XML coverage report as artifact
- name: Upload XML coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-xml
path: coverage.xml
# Step 7: Install Google Cloud CLI
- name: Install Google Cloud CLI
run: |
sudo apt-get update
sudo apt-get install -y google-cloud-cli
# Step 8: Decode GCP Service Account Key
- name: Decode and Write GCP Service Account Key
run: |
echo "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}" | base64 -d > /tmp/gcp-key.json
shell: bash
# Step 9: Authenticate with GCP using the Temporary File
- name: Authenticate with GCP
env:
GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp-key.json
run: gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS}
# Step 10: Set GCP Project ID
- name: Set GCP Project ID
run: gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
# Step 11: Build Docker Image
- name: Build Docker Image
run: |
gcloud auth configure-docker us-east1-docker.pkg.dev
docker build -t us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/gcf-artifacts/python-test-workflow:${{ github.run_id }} .
# Step 12: Push Docker Image to Artifact Registry
- name: Push Docker Image
run: |
docker push us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/gcf-artifacts/python-test-workflow:${{ github.run_id }}