Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Jan 27, 2025
1 parent c83cc43 commit be1f157
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
35 changes: 24 additions & 11 deletions .github/actions/decision/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,40 @@ runs:
python3 CI/run.py --decision | tee -a $GITHUB_OUTPUT
- run: |
cat<<'EOF'
${{ toJSON(steps.decision.outputs) }}
${{ toJSON(fromJSON(steps.decision.outputs.data)) }}
EOF
shell: bash
- uses: actions/setup-node@v3
if: ${{ steps.dependencies.outputs.data }}
if: ${{ steps.decision.outputs.data }}
with:
node-version: '20.x'
- shell: bash
if: ${{ steps.dependencies.outputs.data }}
if: ${{ steps.decision.outputs.data }}
run: npm install @actions/cache
- name: Check dependencies
if: ${{ steps.dependencies.outputs.data }}
id: filtered
if: ${{ steps.decision.outputs.data }}
uses: actions/github-script@v7
with:
script: |
const cache = require('@actions/cache');
const data = ${{ toJSON(fromJSON(steps.decision.outputs.data)) }};
for (const mount of data) {
if (await cache.restoreCache([path.basename(mount.artifact)], mount.key, [], { lookupOnly: true }, true)) {
console.log(`Cache restored from key: ${mount.key}`);
} else {
core.setFailed(`Failed to restore cache from key: ${mount.key}`);
}
}
const filtered = await Promise.all(
Object.entries(data).map(async ([name, items]) => {
const filtered_items = [];
for (const item of items) {
if (!('key' in item) || await cache.restoreCache([item.artifact], item.key, [], { lookupOnly: true }, true)) {
const { key, paths, ...filtered_item } = item;
filtered_items.push(filtered_item);
}
}
return [name, filtered_items];
})
);
return Object.fromEntries(filtered);
- run: |
cat<<'EOF'
${{ toJSON(steps.filtered.outputs) }}
EOF
exit 1
shell: bash
17 changes: 13 additions & 4 deletions CI/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,26 @@ def main():
}
matrix = {}
for t in Task.by_id.values():
name = t.task.get("metadata", {})["name"]
task = t.task
payload = task.get("payload", {})
name = task.get("metadata", {})["name"]
job_name = name.split()[0]
if job_name == "hg" and name.startswith("hg clone"):
job_name = "hg-clone"
if job_name in ("docker", "msys2") and "base" in name:
job_name = f"{job_name}-base"
job_name = JOB_NAME.get(job_name, job_name)
matrix.setdefault(job_name, []).append({
item = {
"task": name,
"runner": RUNNER[t.task["workerType"]],
})
"runner": RUNNER[task["workerType"]],
}
if "routes" in task:
item["paths"] = [
os.path.basename(artifact["name"])
for artifact in payload.get("artifacts", [])
]
item["key"] = task.get("routes")[0]
matrix.setdefault(job_name, []).append(item)
for m in matrix.values():
m.sort(key=lambda x: x["task"])
print_output("data", matrix)
Expand Down

0 comments on commit be1f157

Please sign in to comment.