Skip to content

Commit

Permalink
Test against upgraded dependencies
Browse files Browse the repository at this point in the history
The scheduled cron job will include upgraded dependencies in the
build matrix and the workflow will allow this as an option.
  • Loading branch information
wbyoung committed Sep 16, 2024
1 parent 259d61b commit 412a959
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
44 changes: 43 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,44 @@ on:
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
upgraded:
description: "Include upgraded dependencies in build matrix"
default: false
type: boolean
schedule:
- cron: "0 0 * * *"

jobs:
build:
info:
name: Collect information & changes data
outputs:
dependencies: ${{ steps.info.outputs.dependencies }}
runs-on: ubuntu-latest
steps:
- name: Collect information
id: info
run: |
dependencies='["pinned", "upgraded"]'
if [[ "${{ github.event_name }}" == "push" ]] || \
[[ "${{ github.event_name }}" == "pull_request" ]] || \
[[ "${{ github.event.inputs.upgraded }}" == "false" ]];
then
dependencies='["pinned"]'
fi
# Output & sent to GitHub Actions
echo "dependencies: ${dependencies}"
echo "dependencies=${dependencies}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs:
- info
strategy:
fail-fast: false
matrix:
dependencies: ${{ fromJSON(needs.info.outputs.dependencies) }}
python-version: ["3.12"]

steps:
Expand All @@ -29,7 +57,21 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.dependencies }}" == "upgraded" ]];
then
echo "unpinning dependencies"
./script/unfreeze
fi
pip install -r requirements.test.txt
if [[ "${{ matrix.dependencies }}" == "upgraded" ]];
then
./script/freeze
echo "dependency changes after upgrade:"
git diff requirements.test.txt
fi
- name: Test with pytest
run: |
pytest
Expand Down
9 changes: 9 additions & 0 deletions script/unfreeze
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

cat requirements.test.txt | \
sed 's/==.*//' > requirements.test.txt.tmp && \
mv requirements.test.txt.tmp requirements.test.txt

0 comments on commit 412a959

Please sign in to comment.