Skip to content

Run DID Scripts

Run DID Scripts #48

Workflow file for this run

name: Run DID Scripts
on:
workflow_dispatch:
inputs:
doubleml-py-branch:
description: 'Branch in https://github.com/DoubleML/doubleml-for-py'
required: true
default: 'main'
repository_dispatch:
types: [run-did-scripts]
jobs:
run-did-scripts:
runs-on: ubuntu-latest
strategy:
matrix:
script: [
'scripts/did/did_pa_atte_coverage.py',
'scripts/did/did_cs_atte_coverage.py',
'scripts/did/did_pa_multi.py',
]
steps:
- name: Determine branch names
id: get-branches
run: |
# Determine the DoubleML branch name
if [ -n "${{ github.event.inputs.doubleml-py-branch }}" ]; then
echo "DML_BRANCH=${{ github.event.inputs.doubleml-py-branch }}" >> $GITHUB_ENV
elif [ -n "${{ github.event.client_payload.doubleml_py_branch }}" ]; then
echo "DML_BRANCH=${{ github.event.client_payload.doubleml_py_branch }}" >> $GITHUB_ENV
else
echo "DML_BRANCH=main" >> $GITHUB_ENV
fi
# Determine the target branch
if [ -n "${{ github.event.client_payload.target_branch }}" ]; then
echo "TARGET_BRANCH=${{ github.event.client_payload.target_branch }}" >> $GITHUB_ENV
elif [ -n "${{ github.ref_name }}" ]; then
echo "TARGET_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "TARGET_BRANCH=main" >> $GITHUB_ENV
fi
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.TARGET_BRANCH }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.11"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "monte-cover/pyproject.toml"
- name: Install Monte-Cover
run: |
cd monte-cover
uv venv
uv sync
- name: Install DoubleML from correct branch
run: |
source monte-cover/.venv/bin/activate
uv pip uninstall --project monte-cover/pyproject.toml doubleml
uv pip install --project monte-cover/pyproject.toml "doubleml @ git+https://github.com/DoubleML/doubleml-for-py@${{ env.DML_BRANCH }}"
- name: Set up Git configuration
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
- name: Run scripts
run: |
source monte-cover/.venv/bin/activate
uv run ${{ matrix.script }}
- name: Commit any existing changes
run: |
git add results/did
git commit -m "Update results from script: ${{ matrix.script }}" || echo "No changed results to commit"
- name: Wait random time
run: |
WAIT_TIME=$(( RANDOM % 291 + 10 ))
echo "Waiting for $WAIT_TIME seconds..."
sleep $WAIT_TIME
- name: Pull the latest changes and push results
run: |
git pull --rebase origin ${{ env.TARGET_BRANCH }}
git push origin ${{ env.TARGET_BRANCH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}