Skip to content

Commit

Permalink
Try using access token output
Browse files Browse the repository at this point in the history
  • Loading branch information
aazuspan committed Jan 29, 2025
1 parent 2452e18 commit bcdf675
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ jobs:
with:
workload_identity_provider: 'projects/569867470362/locations/global/workloadIdentityPools/github-actions/providers/github-actions'
service_account: '[email protected]'

token_format: 'access_token'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Test with pytest
env:
EE_SERVICE_ACCOUNT: ${{ secrets.EE_SERVICE_ACCOUNT }}
GOOGLE_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }}
run: |
hatch run test:all
Expand Down
14 changes: 13 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import warnings
from collections import UserDict
from pathlib import Path
Expand Down Expand Up @@ -69,7 +70,18 @@ def pytest_sessionstart(session):


def _init_ee_for_tests():
ee.Initialize()
# Use the Github Service Account for CI tests
if os.environ.get("GITHUB_ACTIONS"):
key_data = os.environ.get("GOOGLE_ACCESS_TOKEN")
project_id = json.loads(key_data).get("project_id")
credentials = ee.ServiceAccountCredentials(None, key_data=key_data)
# Use stored persistent credentials for local tests
else:
# Project should be parsed from credentials
project_id = None
credentials = "persistent"

ee.Initialize(credentials, project=project_id)


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit bcdf675

Please sign in to comment.