Clean up PUDL CLI tools; use Click framework #448
Workflow file for this run
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
--- | |
name: zenodo-cache-sync | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 6 * * 1-5" # Weekdays at midnight on MST | |
pull_request: | |
paths: | |
- "src/pudl/workspace/datastore.py" | |
env: | |
INTERNAL_ZENODO_CACHE_BUCKET: gs://internal-zenodo-cache.catalyst.coop | |
PUBLIC_ZENODO_CACHE_BUCKET: gs://zenodo-cache.catalyst.coop | |
GITHUB_REF: ${{ github.ref_name }} # This is changed to dev if running on a schedule | |
PUDL_OUTPUT: ~/pudl-work/output | |
PUDL_INPUT: ~/pudl-work/input/ | |
jobs: | |
zenodo-cache-sync: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
fail-fast: false | |
defaults: | |
run: | |
shell: bash -l {0} | |
steps: | |
- name: Use dev branch if running on a schedule | |
if: ${{ (github.event_name == 'schedule') }} | |
run: | | |
echo "This action was triggered by a schedule." && echo "GITHUB_REF=dev" >> $GITHUB_ENV | |
- name: Log value of github ref | |
if: ${{ (github.event_name == 'pull_request') }} | |
run: | | |
echo "This action was triggered by a pull request." && echo "GITHUB_REF="${{ github.head_ref }} >> $GITHUB_ENV | |
- name: Checkout desired branch | |
uses: actions/checkout@v4 | |
- name: Install Conda environment using mamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environments/conda-lock.yml | |
environment-name: pudl-dev | |
cache-environment: true | |
- name: Log environment details | |
run: | | |
conda info | |
conda list | |
conda config --show-sources | |
conda config --show | |
printenv | sort | |
- name: Install pudl package | |
run: | | |
pip install --editable ./ | |
- name: Set default gcp credentials | |
id: gcloud-auth | |
uses: "google-github-actions/auth@v1" | |
with: | |
workload_identity_provider: "projects/345950277072/locations/global/workloadIdentityPools/gh-actions-pool/providers/gh-actions-provider" | |
service_account: "zenodo-cache-manager@catalyst-cooperative-pudl.iam.gserviceaccount.com" | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Update GCS cache with any new Zenodo archives | |
run: | | |
pudl_datastore --gcs-cache-path ${{ env.INTERNAL_ZENODO_CACHE_BUCKET }} --bypass-local-cache --loglevel DEBUG | |
- name: Sync internal and public caches | |
run: | | |
gsutil -u catalyst-cooperative-pudl -m rsync -dr ${{ env.INTERNAL_ZENODO_CACHE_BUCKET }} ${{ env.PUBLIC_ZENODO_CACHE_BUCKET }} | |
zenodo-cache-sync-notify: | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
needs: zenodo-cache-sync | |
steps: | |
- name: Inform the Codemonkeys | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: custom | |
fields: workflow,job,commit,repo,ref,author,took | |
custom_payload: | | |
{ | |
username: 'action-slack', | |
icon_emoji: ':octocat:', | |
attachments: [{ | |
color: '${{ needs.zenodo-cache-sync.result }}' === 'success' ? 'good' : '${{ needs.zenodo-cache-sync.result }}' === 'failure' ? 'danger' : 'warning', | |
text: `${process.env.AS_REPO}@${process.env.AS_REF}\n ${process.env.AS_WORKFLOW} (${process.env.AS_COMMIT})\n by ${process.env.AS_AUTHOR}\n Status: ${{ needs.zenodo-cache-sync.result }}`, | |
}] | |
} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} # required | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} # required |