Skip to content

Commit

Permalink
Bla
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- committed Nov 22, 2024
1 parent d531f7f commit 1628c9e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 44 deletions.
84 changes: 44 additions & 40 deletions .github/workflows/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,63 @@ jobs:
# TODO: change to appropriate image
runs-on: ubuntu-latest
steps:
# - name: Checkout dask
# uses: actions/checkout@v4
# with:
# repository: dask/dask
# path: dask
# - name: Checkout distributed
# uses: actions/checkout@v4
# with:
# repository: dask/distributed
# path: distributed
# - name: Run
# run: |
# (cd dask; git rev-parse HEAD;
# cd ../distributed; git rev-parse HEAD) | tee commit-hashes.txt
# - name: Upload commit hashes
# uses: actions/upload-artifact@v4
# with:
# name: commit-hashes.txt
# path: commit-hashes.txt
# # TODO: This one is wrong, need to use the REST API to get the most recently uploaded artifact id.
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Checkout ourselves
uses: actions/checkout@v4
with:
path: utils
- name: Stuff
- name: Checkout dask
uses: actions/checkout@v4
with:
repository: dask/dask
path: dask
- name: Checkout distributed
uses: actions/checkout@v4
with:
repository: dask/distributed
path: distributed
- name: Run
run: |
(cd dask; git rev-parse HEAD;
cd ../distributed; git rev-parse HEAD) | tee commit-hashes.txt
- name: Upload commit hashes
uses: actions/upload-artifact@v4
with:
name: commit-hashes.txt
path: commit-hashes.txt
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Get last artifact URL from last run
id: get_last_id
run: |
pip install requests
VAL=$(python utils/get.py)
echo "${VAL}"
echo "${VAL}" >> $GITHUB_OUTPUT
- name: Look at output
run: |
echo ${{ fromJSON(steps.get_last_id.outputs.RUN_INFO) }}
- name: Download last run commit hashes
if: ${{ fromJSON(steps.get_last_id.outputs.RUN_INFO).exists }}
- name: Download artifact from last run if exists
if: ${{ fromJSON(steps.get_last_id.outputs.INFO).exists }}
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: commit-hashes.txt
path: previous-run-hashes.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ fromJSON(steps.get_last_id.outputs.RUN_INFO).id }}
# - name: Check if run needed
# run: |
# if [ ! -f previous-run-hashes.txt ]; then
# echo "No previous run hashes, need to re-run"
# elif cmp -s commit-hashes.txt previous-run-hashes.txt; then
# echo "Previous run hash same as this one, no need to re-run"
# else
# echo "Previous run hash different, need to re-run"
# fi
run-id: ${{ fromJSON(steps.get_last_id.outputs.INFO).id }}
- name: Check if test run is needed
id: check_run_needed
run: |
if [ ! -f previous-run-hashes.txt ]; then
echo "No previous run hashes, need to re-run"
echo 'INFO={"rerun": true}' >> $GITHUB_OUTPUT
elif cmp -s commit-hashes.txt previous-run-hashes.txt; then
echo "Previous run hash same as this one, no need to re-run"
echo 'INFO={"rerun": false}' >> $GITHUB_OUTPUT
else
echo "Previous run hash different, need to re-run"
echo 'INFO={"rerun": true}' >> $GITHUB_OUTPUT
fi
- name: Run tests
if: ${{ fromJSON(steps.check_run_needed.outputs.INFO).rerun }}
run: |
echo Running tests
10 changes: 6 additions & 4 deletions get.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def previous_run_id() -> str | None:
artifacts = req.json()["artifacts"]
try:
(artifact,) = artifacts
return artifact["workflow_run"]["id"]
run_id = artifact["workflow_run"]["id"]
print(f"Found artifact for workflow run {run_id}")
return run_id
except ValueError:
# Didn't get exactly one artifact, assume we must rebuild
return None
Expand All @@ -26,8 +28,8 @@ def previous_run_id() -> str | None:
if __name__ == "__main__":
run_id = previous_run_id()
if run_id is not None:
info = json.dumps({"id": run_id, "exists": False})
print(f"RUN_INFO={info}")
info = json.dumps({"id": run_id, "exists": True})
print(f"INFO={info}")
else:
info = json.dumps({"exists": False})
print(f"RUN_INFO={info}")
print(f"INFO={info}")

0 comments on commit 1628c9e

Please sign in to comment.