Skip to content

Commit

Permalink
support forcing test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdekstrand committed Jul 2, 2024
1 parent 053859e commit 9525e7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 55 deletions.
45 changes: 4 additions & 41 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
if gh pr diff $PR_NUMBER --name-only |grep '^lenskit.*\.py$'; then
echo "source code changed"
echo changed=yes >>"$GITHUB_OUTPUT"
elif gh pr view $PR_NUMBER --json body -t '{{.body}}' | grep 'tests: force'; then
echo "test run forced from PR text"
echo changed=yes >>"$GITHUB_OUTPUT"
else
echo "source code unchanged"
echo changed=no >>"$GITHUB_OUTPUT"
Expand All @@ -37,10 +40,6 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.number }}
- name: Inspect outputs
run: echo "$CHANGED"
env:
CHANGED: ${{steps.check-for-changes.outputs.changed}}
conda:
name: Conda Python ${{matrix.python}} on ${{matrix.platform}}
runs-on: ${{matrix.platform}}
Expand All @@ -63,10 +62,6 @@ jobs:
- macos-latest
- windows-latest
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -126,10 +121,6 @@ jobs:
- macos-latest
- windows-latest
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -180,10 +171,6 @@ jobs:
- check-changes
if: needs.check-changes.outputs.changed == 'yes'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -237,10 +224,6 @@ jobs:
- check-changes
if: needs.check-changes.outputs.changed == 'yes'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -301,10 +284,6 @@ jobs:
- '3.11'
- '3.12'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -353,10 +332,6 @@ jobs:
- check-changes
if: needs.check-changes.outputs.changed == 'yes'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -417,10 +392,6 @@ jobs:
- '3.11'
- '3.12'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -469,10 +440,6 @@ jobs:
- check-changes
if: needs.check-changes.outputs.changed == 'yes'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -530,10 +497,6 @@ jobs:
- '3.11'
- '3.12'
steps:
- name: dump test
run: echo "$CHANGED"
env:
CHANGED: ${{needs.check-changes-outputs.changed}}
- name: 🛒 Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -584,7 +547,7 @@ jobs:
shell: bash -el {0}
needs:
- check-changes
if: needs.check-changes.outputs.changed
if: needs.check-changes.outputs.changed == 'yes'
steps:
- name: 🛒 Checkout
uses: actions/checkout@v4
Expand Down
20 changes: 6 additions & 14 deletions lkdev/workflows/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,7 @@ def test_job(options: JobOptions) -> GHJob:
}

job.update(job_strategy(options)) # type: ignore
job["steps"] = [
{
"name": "dump test",
"run": 'echo "$CHANGED"',
"env": {"CHANGED": "${{needs.check-changes-outputs.changed}}"},
}
] + test_job_steps(options)
job["steps"] = test_job_steps(options)
return job


Expand All @@ -322,7 +316,7 @@ def test_eval_job() -> GHJob:
"runs-on": opts.vm_platform,
"defaults": {"run": {"shell": "bash -el {0}"}},
"needs": ["check-changes"],
"if": "needs.check-changes.outputs.changed",
"if": "needs.check-changes.outputs.changed == 'yes'",
"steps": [step_checkout(opts)]
+ steps_setup_conda(opts)
+ steps_mldata(opts, ["ml-100k", "ml-20m"])
Expand Down Expand Up @@ -384,23 +378,21 @@ def job_check_changes() -> GHJob:
if gh pr diff $PR_NUMBER --name-only |grep '^lenskit.*\\.py$'; then
echo "source code changed"
echo changed=yes >>"$GITHUB_OUTPUT"
elif gh pr view $PR_NUMBER --json body -t '{{.body}}' | grep 'tests: force'; then
echo "test run forced from PR text"
echo changed=yes >>"$GITHUB_OUTPUT"
else
echo "source code unchanged"
echo changed=no >>"$GITHUB_OUTPUT"
fi
fi
cat $GITHUB_OUTPUT
"""),
"""), # noqa: E501
"env": {
"GH_TOKEN": "${{ github.token }}",
"PR_NUMBER": "${{ github.event.number }}",
},
},
{
"name": "Inspect outputs",
"run": 'echo "$CHANGED"',
"env": {"CHANGED": "${{steps.check-for-changes.outputs.changed}}"},
},
],
}

Expand Down

0 comments on commit 9525e7d

Please sign in to comment.