Skip to content

Commit

Permalink
Merge pull request #21 from yasirroni/auto_updater_on_fail
Browse files Browse the repository at this point in the history
merge build and update into single file
  • Loading branch information
yasirroni authored Jun 26, 2024
2 parents bafae85 + 88dd3de commit dc4e7bd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 64 deletions.
4 changes: 3 additions & 1 deletion .github/scripts/update_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ for version in "${PYTHON_VERSIONS[@]}"; do
# Install pru into the virtual environment
pip install pru

# Calculate checksums before running pru
# Get minor version
minor_version=$(python${version} -c "import sys; print(f'{sys.version_info.minor}')")

# Calculate checksums before running pru
checksum_before_single=$(md5sum "pytests/requirements/3_${minor_version}/requirements_single_updated.txt" | cut -d ' ' -f 1)
checksum_before_mix=$(md5sum "pytests/requirements/3_${minor_version}/requirements_mix_updated.txt" | cut -d ' ' -f 1)

Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,32 @@ jobs:
- name: Fail the job if tests fail
if: steps.pytest.outcome != 'success' && steps.pytest2.outcome != 'success'
run: exit 1

update:
needs: build
if: needs.build.result != 'success'
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Check out repository
uses: actions/checkout@v4

- name: Run requirements updater script
id: run_pru
run: |
bash .github/scripts/update_requirements.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Commit and push changes
if: steps.run_pru.outputs.updated == 'true'
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add .
git commit -m "Update requirements based on failed tests at $(date)"
git push origin HEAD
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ jobs:
- name: Install package
run: pip install -e ."[dev]"

- name: Test package
- name: Run tests
id: pytest
run: |
python3 -m pytest . -c pyproject.toml
continue-on-error: true

- name: Test package 2
- name: Run tests with last failed
id: pytest2
if: steps.pytest.outcome != 'success'
run: |
Expand Down
61 changes: 0 additions & 61 deletions .github/workflows/update.yml

This file was deleted.

0 comments on commit dc4e7bd

Please sign in to comment.